How to change alternative words from cucumber to turnip?

39 views
Skip to first unread message

hai nguyen ngoc

unread,
Jul 31, 2014, 3:00:27 PM7/31/14
to ruby-...@googlegroups.com

- base on turnip tutorial:

You can also specify alternative words and optional parts of words, like this:

step "there is/are :count monster(s)" do |count|
  @monsters = Array.new(count) { Monster.new }
end
- In spreewald gem, we have like this:
Then(/^the "(.*?)" field should (not )?contain:$/) do |label, negate, expected_string|
  patiently do
    field = find_field(label)
    field.value.chomp.send(negate ? :should_not : :should, contain_with_wildcards(expected_string))
  end
end

so if I want to use this step in turnip, I will change like this?

step "the :label field :should/should_not contain" do |label, negate, expected_string|
patiently do
    field = find_field(label)
    field.value.chomp.send(negate ? :should_not : :should, contain_with_wildcards(expected_string))
  end
end

Wataru MIYAGUNI

unread,
Jul 31, 2014, 5:04:13 PM7/31/14
to ruby-...@googlegroups.com
Hi.

How about this code?

step "the :label field :whether contain:" do |label, whether, expected_string|

  patiently
do
    field
= find_field(label)

    field
.value.chomp.send(whether.to_sym, contain_with_wildcards(expected_string))
 
end
end

  Then the text field should contain:
   
"""
    foo
    """

   
And the text field should_not contain:
   
"""
    bar
    """


In first step, `whether` is "should", and in second step, `whether` is "should_not".
Message has been deleted

hai nguyen ngoc

unread,
Jul 31, 2014, 8:15:54 PM7/31/14
to ruby-...@googlegroups.com
Nice, that's my need.
Thanks so much
Reply all
Reply to author
Forward
0 new messages