- 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 dofield = find_field(label)field.value.chomp.send(negate ? :should_not : :should, contain_with_wildcards(expected_string))endendso 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 dofield = find_field(label)field.value.chomp.send(negate ? :should_not : :should, contain_with_wildcards(expected_string))endend
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
"""