Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass DocString as String #891

Merged
merged 2 commits into from
Aug 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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