Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Add step definitions for "world" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jbpros committed Oct 12, 2011
1 parent 45b7b02 commit f897348
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions step_definitions/cucumber_stepdefs.rb
Expand Up @@ -27,6 +27,14 @@
write_failing_mapping_with_message(step_name, message)
end

Given /^a World variable initialized to (\d+)$/ do |value|
write_world_variable_with_numeric_value(value)
end

Given /^a World function$/ do
write_world_function
end

When /^Cucumber executes the scenario "([^"]*)"$/ do |scenario_name|
run_scenario(scenario_name)
end
Expand All @@ -41,6 +49,45 @@
run_scenario(@scenario_name)
end

When /^Cucumber executes a scenario that increments the World variable by (\d+)$/ do |increment_value|
write_mapping_incrementing_world_variable_by_value("I increment", increment_value)
write_mapping_logging_world_variable_value("I log the variable value")
write_feature <<-EOF
Feature:
Scenario:
When I increment
Then I log the variable value
EOF
run_feature
end

When /^Cucumber executes two scenarios that increment the World variable by (\d+)$/ do |increment_value|
write_mapping_incrementing_world_variable_by_value("I increment", increment_value)
write_mapping_logging_world_variable_value("I log the variable value", "1")
write_mapping_logging_world_variable_value("I log the variable value again", "2")
write_feature <<-EOF
Feature:
Scenario:
When I increment
Then I log the variable value
Scenario:
When I increment again
Then I log the variable value again
EOF
run_feature
end

#"
When /^Cucumber executes a scenario that calls the World function$/ do
write_mapping_calling_world_function("I call the world function")
write_feature <<-EOF
Feature:
Scenario:
When I call the world function
EOF
run_feature
end

Then /^the scenario passes$/ do
assert_passing_scenario
end
Expand Down Expand Up @@ -82,3 +129,12 @@
assert_partial_output(message, all_output)
assert_success false
end

Then /^the World variable should have contained (\d+) at the end of the (|first |second )scenario$/ do |value, scenario_number|
time = scenario_number == "2" ? 2 : 1
assert_world_variable_held_value_at_time value, time
end

Then /^the World function should have been called$/ do
assert_world_function_called
end

0 comments on commit f897348

Please sign in to comment.