Skip to content

Commit

Permalink
Deprecate i18n methods in RbWorld cucumber#68
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwynne committed Oct 16, 2011
1 parent f2af0e6 commit b8b8533
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 8 deletions.
5 changes: 5 additions & 0 deletions History.md
@@ -1,3 +1,8 @@
## In Git

### Changed features
* Deprecated i18n methods in World, and added a new #step method to use instead. ([#68](https://github.com/cucumber/cucumber/issues/68) Matt Wynne)

## [v1.1.0](https://github.com/cucumber/cucumber/compare/v1.0.6...v1.1.0)

### Changed features
Expand Down
60 changes: 60 additions & 0 deletions features/nested_steps.feature
@@ -0,0 +1,60 @@
Feature: Nested Steps


Background:
Given a scenario with a step that looks like this:
"""gherkin
Given two turtles
"""
And a step definition that looks like this:
"""ruby
Given /a turtle/ do
puts "turtle!"
end
"""

Scenario: Use #steps to call several steps at once
Given a step definition that looks like this:
"""ruby
Given /two turtles/ do
steps %{
Given a turtle
And a turtle
}
end
"""
When I run the feature with the progress formatter
Then the output should contain:
"""
turtle!
turtle!
"""

Scenario: Use #step to call a single step
Given a step definition that looks like this:
"""ruby
Given /two turtles/ do
step "a turtle"
step "a turtle"
end
"""
When I run the feature with the progress formatter
Then the output should contain:
"""
turtle!
turtle!
"""

Scenario: Use deprecated i18n methods
Given a step definition that looks like this:
"""ruby
Given /two turtles/ do
Given "a turtle"
end
"""
When I run the feature with the progress formatter
Then the output should contain "WARNING"
2 changes: 1 addition & 1 deletion legacy_features/call_steps_from_stepdefs.feature
Expand Up @@ -46,7 +46,7 @@ Feature: http://gist.github.com/221223
end
Given /^I use keyword to call a multiline string with (.*)$/ do |s| x=1
Given 'a multiline string:', "Hello\n#{s}"
step 'a multiline string:', "Hello\n#{s}"
end
Given /^I call a table with (.*)$/ do |s| x=1
Expand Down
2 changes: 1 addition & 1 deletion legacy_features/step_definitions/cucumber_steps.rb
Expand Up @@ -75,7 +75,7 @@
unless combined_output.index(output)
combined_output.should == output
end
Then("it should #{success}")
step("it should #{success}")
end

Then /^the output should contain "([^"]*)"$/ do |text|
Expand Down
10 changes: 7 additions & 3 deletions lib/cucumber/rb_support/rb_world.rb
Expand Up @@ -17,12 +17,16 @@ def Transform(arg)
rb = @__cucumber_step_mother.load_programming_language('rb')
rb.execute_transforms([arg]).first
end

attr_writer :__cucumber_step_mother, :__natural_language

# Call a step from within a step definition. This method is aliased to
# the same i18n as RbDsl.
def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
STDERR.puts failed + "WARNING: i18n methods within step definitions are deprecated. Use #step instead:" + caller[0] + reset
@__cucumber_step_mother.invoke(name, multiline_argument)
end

# Invoke a single step.
def step(name, multiline_argument=nil)
@__cucumber_step_mother.invoke(name, multiline_argument)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/cucumber/rb_support/rb_step_definition_spec.rb
Expand Up @@ -22,7 +22,7 @@ module RbSupport

it "should allow calling of other steps" do
dsl.Given /Outside/ do
Given "Inside"
step "Inside"
end
dsl.Given /Inside/ do
$inside = true
Expand All @@ -34,7 +34,7 @@ module RbSupport

it "should allow calling of other steps with inline arg" do
dsl.Given /Outside/ do
Given "Inside", Cucumber::Ast::Table.new([['inside']])
step "Inside", Cucumber::Ast::Table.new([['inside']])
end
dsl.Given /Inside/ do |table|
$inside = table.raw[0][0]
Expand All @@ -46,7 +46,7 @@ module RbSupport

it "should raise Undefined when inside step is not defined" do
dsl.Given /Outside/ do
Given 'Inside'
step 'Inside'
end

lambda do
Expand Down

0 comments on commit b8b8533

Please sign in to comment.