Module: Spec::Story::Extensions::Main
- Defined in:
- lib/gems/rspec-1.1.12/lib/spec/story/extensions/main.rb
Defined Under Namespace
Modules: StoryRunnerStepGroupAdapter
Instance Method Summary collapse
-
#run_story(*args, &block) ⇒ Object
Calling this deprecated is silly, since it hasn’t been released yet.
-
#steps_for(tag, &block) ⇒ Object
Creates (or appends to an existing) a namespaced group of steps for use in Stories.
- #Story(title, narrative, params = {}, &body) ⇒ Object
-
#with_steps_for(*tags, &block) ⇒ Object
Creates a context for running a Plain Text Story with specific groups of Steps.
Instance Method Details
#run_story(*args, &block) ⇒ Object
Calling this deprecated is silly, since it hasn’t been released yet. But, for those who are reading this - this will be deleted before the 1.1 release.
11 12 13 14 15 |
# File 'lib/gems/rspec-1.1.12/lib/spec/story/extensions/main.rb', line 11 def run_story(*args, &block) runner = Spec::Story::Runner::PlainTextStoryRunner.new(*args) runner.instance_eval(&block) if block runner.run end |
#steps_for(tag, &block) ⇒ Object
Creates (or appends to an existing) a namespaced group of steps for use in Stories
Examples
# Creating a new group
steps_for :forms do
When("user enters $value in the $field field") do ... end
When("user submits the $form form") do ... end
end
26 27 28 29 30 |
# File 'lib/gems/rspec-1.1.12/lib/spec/story/extensions/main.rb', line 26 def steps_for(tag, &block) steps = rspec_story_steps[tag] steps.instance_eval(&block) if block steps end |
#Story(title, narrative, params = {}, &body) ⇒ Object
5 6 7 |
# File 'lib/gems/rspec-1.1.12/lib/spec/story/extensions/main.rb', line 5 def Story(title, narrative, params = {}, &body) ::Spec::Story::Runner.story_runner.Story(title, narrative, params, &body) end |
#with_steps_for(*tags, &block) ⇒ Object
Creates a context for running a Plain Text Story with specific groups of Steps. Also supports adding arbitrary steps that will only be accessible to the Story being run.
Examples
# Run a Story with one group of steps
with_steps_for :checking_accounts do
run File.dirname(__FILE__) + "/withdraw_cash"
end
# Run a Story, adding steps that are only available for this Story
with_steps_for :accounts do
Given "user is logged in as account administrator"
run File.dirname(__FILE__) + "/reconcile_accounts"
end
# Run a Story with steps from two groups
with_steps_for :checking_accounts, :savings_accounts do
run File.dirname(__FILE__) + "/transfer_money"
end
# Run a Story with a specific Story extension
with_steps_for :login, :navigation do
run File.dirname(__FILE__) + "/user_changes_password", :type => RailsStory
end
58 59 60 61 62 63 64 65 |
# File 'lib/gems/rspec-1.1.12/lib/spec/story/extensions/main.rb', line 58 def with_steps_for(*, &block) steps = Spec::Story::StepGroup.new do extend StoryRunnerStepGroupAdapter end .each {|tag| steps << rspec_story_steps[tag]} steps.instance_eval(&block) if block steps end |