Sha256: 4205960a8b3f3d7bf1d8f97c553d2d12f6ef91a4885322d2d8ef4951f8b85149

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

describe "Matcher::HaveGeneric" do
  it "have_key passes if the hash includes the given key" do
    expect({a: 1, b: 2, c: 3}).to have_key(:c)
  end

  it "have_key fails if the hash doesn't include the given key" do
    expect_failure{ expect({a: 1, b: 2, c: 3}).to have_key(:h) }
  end

  it "have_color passes when the value responds to has_color? and returns true" do
    class TestClass; def has_color?(color); color == :red; end; end
    expect(TestClass.new).to have_color(:red)
  end

  it "have_color fails when the value responds to has_color? and returns false" do
    class TestClass; def has_color?(color); color == :red; end; end
    expect_failure{ expect(TestClass.new).to have_color(:blue) }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bacon-expect-1.0.2 spec_app/spec/matchers/have_generic_spec.rb
bacon-expect-1.0.1 spec_app/spec/matchers/have_generic_spec.rb
bacon-expect-0.1 spec_app/spec/matchers/have_generic_spec.rb