I've been playing with rSpec's text stories in Merb but I couldn't find a way to make a rake task that would take an argument for a particular story to run. e.g.
rake story:run my_storySo I've done the next best thing. I scan my directory for story files and create the rake tasks dynamically. Now I can use:
rake story:run:my_storyAs well as
rake story:run:allThe code to make this dream a reality is
# Allows all found stories to be run individually by using
# rake story:run:story_name
namespace :story do
namespace :run do
all_stories = []
Dir.glob('stories/stories/**/*.rb').each do |path|
story = path.split("/").last[0..-4]
desc "Run spec story #{story}"
task "#{story}".to_sym do
sh %{ruby stories/stories/#{story}.rb}
end
all_stories << story
end
desc 'Run all stories'
task :all do
all_stories.each do |story|
puts
sh %{ruby stories/stories/#{story}.rb}
end
end
end
end