Skip to content

Commit

Permalink
Merge pull request cucumber#891 from cucumber/pass-docstring-as-string
Browse files Browse the repository at this point in the history
Pass DocString as String
  • Loading branch information
mattwynne committed Aug 7, 2015
2 parents c1768eb + 4e5bd49 commit 65f5023
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
25 changes: 3 additions & 22 deletions features/docs/defining_steps/nested_steps_with_second_arg.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Feature: Nested Steps with either table or doc string
"""

Scenario: Use #step with docstring
Scenario: Use #step with Doc String
Given a step definition that looks like this:
"""ruby
Given /two turtles/ do
Expand All @@ -44,30 +44,11 @@ Feature: Nested Steps with either table or doc string
And a step definition that looks like this:
"""ruby
Given /turtles:/ do |text|
puts text
puts "#{text}:#{text.class}"
end
"""
When I run the feature with the progress formatter
Then the output should contain:
"""
Sturm and Lioville
"""

Scenario: Use #step with docstring and content-type
Given a step definition that looks like this:
"""ruby
Given /two turtles/ do
step %{turtles:}, doc_string('Sturm and Lioville','math')
end
"""
And a step definition that looks like this:
"""ruby
Given /turtles:/ do |text|
puts text.content_type
end
"""
When I run the feature with the progress formatter
Then the output should contain:
"""
math
Sturm and Lioville:String
"""
10 changes: 5 additions & 5 deletions features/docs/gherkin/doc_strings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ Feature: Doc strings
Three
"""

Scenario: DocString with interesting content type
Scenario: DocString passed as String
Given a scenario with a step that looks like this:
"""gherkin
Given I have some code for you:
\"\"\"ruby
# hello
\"\"\"
hello
\"\"\"
"""
And a step definition that looks like this:
"""ruby
Given /code/ do |text|
puts text.content_type
puts text.class
end
"""
When I run the feature with the progress formatter
Then the output should contain:
"""
ruby
String
"""
3 changes: 1 addition & 2 deletions lib/cucumber/multiline_argument/doc_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ module Cucumber
module MultilineArgument
class DocString < SimpleDelegator
def append_to(array)
array << self
array << self.to_s
end
end
end
end

3 changes: 2 additions & 1 deletion lib/cucumber/rb_support/rb_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def table(text_or_table, file=nil, line_offset=0)
# puts "this is ruby code"
# %}, 'ruby')
def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
STDERR.puts AnsiEscapes.failed + "WARNING: #doc_string is deprecated. Just pass a regular String instead:" + caller[0] + AnsiEscapes.reset
# TODO: rename this method to multiline_string
@__cucumber_runtime.doc_string(string_without_triple_quotes, content_type, line_offset)
end
Expand All @@ -89,7 +90,7 @@ def announce(*messages)
# @note Cucumber might surprise you with the behaviour of this method. Instead
# of sending the output directly to STDOUT, Cucumber will intercept and cache
# the message until the current step has finished, and then display it.
#
#
# If you'd prefer to see the message immediately, call {Kernel.puts} instead.
def puts(*messages)
@__cucumber_runtime.puts(*messages)
Expand Down

0 comments on commit 65f5023

Please sign in to comment.