Skip to content

Commit

Permalink
Update tests to document new errors for undefined dynamic steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
tooky committed Mar 19, 2015
1 parent c947dbe commit 144a8d6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 63 deletions.
49 changes: 49 additions & 0 deletions features/docs/defining_steps/nested_steps.feature
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,52 @@ Feature: Nested Steps
1 scenario (1 failed)
1 step (1 failed)
"""

Scenario: Undefined nested step
Given a file named "features/call_undefined_step_from_step_def.feature" with:
"""
Feature: Calling undefined step
Scenario: Call directly
Given a step that calls an undefined step
Scenario: Call via another
Given a step that calls a step that calls an undefined step
"""
And a file named "features/step_definitions/steps.rb" with:
"""
Given /^a step that calls an undefined step$/ do
step 'this does not exist'
end
Given /^a step that calls a step that calls an undefined step$/ do
step 'a step that calls an undefined step'
end
"""
When I run `cucumber -q features/call_undefined_step_from_step_def.feature`
Then it should fail with exactly:
"""
Feature: Calling undefined step
Scenario: Call directly
Given a step that calls an undefined step
Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
features/call_undefined_step_from_step_def.feature:4:in `Given a step that calls an undefined step'
Scenario: Call via another
Given a step that calls a step that calls an undefined step
Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
./features/step_definitions/steps.rb:6:in `/^a step that calls a step that calls an undefined step$/'
features/call_undefined_step_from_step_def.feature:7:in `Given a step that calls a step that calls an undefined step'
Failing Scenarios:
cucumber features/call_undefined_step_from_step_def.feature:3
cucumber features/call_undefined_step_from_step_def.feature:6
2 scenarios (2 failed)
2 steps (2 failed)
0m0.012s
"""
61 changes: 0 additions & 61 deletions features/docs/report_called_undefined_steps.feature

This file was deleted.

17 changes: 15 additions & 2 deletions spec/cucumber/rb_support/rb_step_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ module RbSupport
let(:user_interface) { double('user interface') }
let(:support_code) { Cucumber::Runtime::SupportCode.new(user_interface) }
let(:rb) { support_code.load_programming_language('rb') }
let(:scenario) { double('scenario', iso_code: 'en').as_null_object }
let(:dsl) do
rb
Object.new.extend(Cucumber::RbSupport::RbDsl)
end

before do
rb.begin_scenario(double('scenario').as_null_object)
rb.begin_scenario(scenario)
$inside = nil
end

Expand Down Expand Up @@ -87,7 +88,7 @@ def step_match(text)

it "has the correct location" do
dsl.Given /With symbol/, :with_symbol
expect(step_match("With symbol").file_colon_line).to eq "spec/cucumber/rb_support/rb_step_definition_spec.rb:89"
expect(step_match("With symbol").file_colon_line).to eq "spec/cucumber/rb_support/rb_step_definition_spec.rb:#{__LINE__-1}"
end
end

Expand All @@ -101,6 +102,18 @@ def step_match(text)
}).to raise_error(Cucumber::UndefinedDynamicStep)
end

it "raises UndefinedDynamicStep when an undefined step is parsed dynamically" do
dsl.Given(/Outside/) do
steps %{
Given Inside
}
end

expect(-> {
run_step "Outside"
}).to raise_error(Cucumber::UndefinedDynamicStep)
end

it "allows forced pending" do
dsl.Given(/Outside/) do
pending("Do me!")
Expand Down

0 comments on commit 144a8d6

Please sign in to comment.