Skip to content

Commit

Permalink
Added field_should_not_contain spec/cucumber tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wapcaplet committed May 12, 2011
1 parent 1ffe674 commit 17ed5ca
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
5 changes: 5 additions & 0 deletions examples/sinatra_app/features/field_fail.feature
Expand Up @@ -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"

Expand Down
8 changes: 6 additions & 2 deletions features/kelp_step_definitions.feature
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions spec/field_spec.rb
Expand Up @@ -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')
Expand Down

0 comments on commit 17ed5ca

Please sign in to comment.