Skip to content

Commit

Permalink
Pass DocString as String
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jul 14, 2015
1 parent ff6e291 commit 0463ab6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 43 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

15 changes: 1 addition & 14 deletions lib/cucumber/rb_support/rb_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,6 @@ def table(text_or_table, file=nil, line_offset=0)
@__cucumber_runtime.table(text_or_table, file, line_offset)
end

# Create an {Cucumber::Ast::DocString} object
#
# Useful in conjunction with the #step method, when
# want to specify a content type.
# @example Create a multiline string
# code = multiline_string(%{
# puts "this is ruby code"
# %}, 'ruby')
def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
# TODO: rename this method to multiline_string
@__cucumber_runtime.doc_string(string_without_triple_quotes, content_type, line_offset)
end

# @deprecated Use {#puts} instead.
def announce(*messages)
STDERR.puts AnsiEscapes.failed + "WARNING: #announce is deprecated. Use #puts instead:" + caller[0] + AnsiEscapes.reset
Expand All @@ -89,7 +76,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 0463ab6

Please sign in to comment.