Sha256: a426a6b1126015c5cb559f99b6380103715ef44b7e31264c31971f9eb75ba3a8

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

require "spec_helper"

describe ElabsMatchers::Matchers::HaveFields, :type => :feature do
  describe "#have_fields" do
    let(:html) do
      Capybara.string(%Q{
        <form>
          <label for="author">Author</label>
          <input type="text" name="author" id="author" value="Adam" />
          <label for="year">Year</label>
          <input type="text" name="year" id="year" value="2011" />
        </form>
      })
    end
    subject { html }

    it "returns true with several fields if both labels and values are correct" do
      should have_fields("Author" => "Adam", "Year" => "2011")

      expect { should have_fields("Author" => "Adam", "Year" => "2012") }.to fail_assertion
      expect { should have_fields("Author" => "Adam", "Week" => "2011") }.to fail_assertion
    end

    it "returns true with one field if both labels and values are correct" do
      should have_fields("Year" => "2011")
      expect { should have_fields("Week" => "2011") }.to fail_assertion
    end

    it "returns false if the label is correct but the value is not" do
      should_not have_fields("Author" => "David")
      expect { should_not have_fields("Author" => "Adam") }.to fail_assertion
    end

    it "returns false if the label is correct but the value is not" do
      should_not have_fields("Wrong" => "Adam")
    end

    it "returns false if the one of the pairs is incorrect" do
      should_not have_fields("Author" => "Goliath", "Year" => "2012")

      expect { should_not have_fields("Author" => "Adam", "Year" => "2012") }.to fail_assertion
      expect { should_not have_fields("Author" => "Adam", "Year" => "2011") }.to fail_assertion
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
elabs_matchers-2.0.1 spec/elabs_matchers/matchers/have_fields_spec.rb
elabs_matchers-2.0.0 spec/elabs_matchers/matchers/have_fields_spec.rb
elabs_matchers-1.0.1 spec/elabs_matchers/matchers/have_fields_spec.rb
elabs_matchers-1.0.0 spec/elabs_matchers/matchers/have_fields_spec.rb
elabs_matchers-0.0.7 spec/elabs_matchers/matchers/have_fields_spec.rb
elabs_matchers-0.0.6 spec/elabs_matchers/matchers/have_fields_spec.rb
elabs_matchers-0.0.5 spec/elabs_matchers/matchers/have_fields_spec.rb
elabs_matchers-0.0.4 spec/elabs_matchers/matchers/have_fields_spec.rb