5 def Story(title, narrative, params = {}, &body)
6 ::Spec::Story::Runner.story_runner.Story(title, narrative, params, &body)
9 # Calling this deprecated is silly, since it hasn't been released yet. But, for
10 # those who are reading this - this will be deleted before the 1.1 release.
11 def run_story(*args, &block)
12 runner = Spec::Story::Runner::PlainTextStoryRunner.new(*args)
13 runner.instance_eval(&block) if block
17 # Creates (or appends to an existing) a namespaced group of steps for use in Stories
21 # # Creating a new group
23 # When("user enters $value in the $field field") do ... end
24 # When("user submits the $form form") do ... end
26 def steps_for(tag, &block)
27 steps = rspec_story_steps[tag]
28 steps.instance_eval(&block) if block
32 # Creates a context for running a Plain Text Story with specific groups of Steps.
33 # Also supports adding arbitrary steps that will only be accessible to
34 # the Story being run.
38 # # Run a Story with one group of steps
39 # with_steps_for :checking_accounts do
40 # run File.dirname(__FILE__) + "/withdraw_cash"
43 # # Run a Story, adding steps that are only available for this Story
44 # with_steps_for :accounts do
45 # Given "user is logged in as account administrator"
46 # run File.dirname(__FILE__) + "/reconcile_accounts"
49 # # Run a Story with steps from two groups
50 # with_steps_for :checking_accounts, :savings_accounts do
51 # run File.dirname(__FILE__) + "/transfer_money"
54 # # Run a Story with a specific Story extension
55 # with_steps_for :login, :navigation do
56 # run File.dirname(__FILE__) + "/user_changes_password", :type => RailsStory
58 def with_steps_for(*tags, &block)
59 steps = Spec::Story::StepGroup.new do
60 extend StoryRunnerStepGroupAdapter
62 tags.each {|tag| steps << rspec_story_steps[tag]}
63 steps.instance_eval(&block) if block
69 module StoryRunnerStepGroupAdapter
70 def run(path, options={})
71 runner = Spec::Story::Runner::PlainTextStoryRunner.new(path, options)
77 def rspec_story_steps # :nodoc:
78 $rspec_story_steps ||= Spec::Story::StepGroupHash.new
86 include Spec::Story::Extensions::Main