diff --git a/examples/sinatra_app/features/field_fail.feature b/examples/sinatra_app/features/field_fail.feature index 6a25177..3affd9c 100644 --- a/examples/sinatra_app/features/field_fail.feature +++ b/examples/sinatra_app/features/field_fail.feature @@ -19,6 +19,11 @@ Feature: Field failure test Then the "First name" field should contain "Alexy" + Scenario: Field should not contain (FAIL) + When I fill in "First name" with "Ivan" + Then the "First name" field should not contain "Ivan" + + Scenario: Fill in a single field (FAIL) When I fill in "Middle name" with "Fyodorovitch" diff --git a/features/kelp_step_definitions.feature b/features/kelp_step_definitions.feature index 8d27023..3c00b6c 100644 --- a/features/kelp_step_definitions.feature +++ b/features/kelp_step_definitions.feature @@ -86,14 +86,18 @@ Feature: Kelp Step Definitions Expected 'First name' to contain 'Alexy' Got 'Dmitry' (Kelp::Unexpected) + Scenario: Field should not contain (FAIL) + Did not expect 'First name' to contain 'Ivan' + Got 'Ivan' (Kelp::Unexpected) + Scenario: Fill in a single field (FAIL) No field with id, name, or label 'Middle name' found (Kelp::FieldNotFound) Scenario: Fill in multiple fields (FAIL) Field 'Height' has no option 'Diminutive' (Kelp::OptionNotFound) - 5 scenarios (5 failed) - 13 steps (5 failed, 8 passed) + 6 scenarios (6 failed) + 16 steps (6 failed, 10 passed) """ Scenario: Visibility test diff --git a/spec/field_spec.rb b/spec/field_spec.rb index e5f98d9..353c261 100644 --- a/spec/field_spec.rb +++ b/spec/field_spec.rb @@ -102,6 +102,58 @@ end +describe Kelp::Field, "field_should_not_contain" do + before(:each) do + visit('/form') + end + + context "passes when" do + context "field with id" do + it "has a different value" do + fill_in "first_name", :with => "Brian" + field_should_not_contain "first_name", "Stewie" + end + + it "is empty" do + field_should_not_contain "first_name", "Stewie" + end + end + + context "field with label" do + it "has a different value" do + fill_in "First name", :with => "Brian" + field_should_not_contain "First name", "Stewie" + end + + it "is empty" do + field_should_not_contain "First name", "Stewie" + end + end + end + + context "fails when" do + context "field with id" do + it "has the given value" do + fill_in "first_name", :with => "Judith" + lambda do + field_should_not_contain "first_name", "Judith" + end.should raise_error(Kelp::Unexpected) + end + end + + context "field with label" do + it "has the given value" do + fill_in "First name", :with => "Judith" + lambda do + field_should_not_contain "First name", "Judith" + end.should raise_error(Kelp::Unexpected) + end + end + + end +end + + describe Kelp::Field, "fields_should_contain" do before(:each) do visit('/form')