Sha256: 5291171e7b9cfebf1d4166acc41a29eaa860337210ebcddd7ae6be74c3948183
Contents?: true
Size: 1.62 KB
Versions: 36
Compression:
Stored size: 1.62 KB
Contents
require 'spec_helper' module RSpec module Matchers describe "eq" do it_behaves_like "an RSpec matcher", :valid_value => 1, :invalid_value => 2 do let(:matcher) { eq(1) } end it "is diffable" do expect(eq(1)).to be_diffable end it "matches when actual == expected" do expect(1).to eq(1) end it "does not match when actual != expected" do expect(1).not_to eq(2) end it "compares by sending == to actual (not expected)" do called = false actual = Class.new do define_method :== do |other| called = true end end.new expect(actual).to eq :anything # to trigger the matches? method expect(called).to be_true end it "describes itself" do matcher = eq(1) matcher.matches?(1) expect(matcher.description).to eq "eq 1" end it "provides message, expected and actual on #failure_message" do matcher = eq("1") matcher.matches?(1) expect(matcher.failure_message_for_should).to eq "\nexpected: \"1\"\n got: 1\n\n(compared using ==)\n" end it "provides message, expected and actual on #negative_failure_message" do matcher = eq(1) matcher.matches?(1) expect(matcher.failure_message_for_should_not).to eq "\nexpected: value != 1\n got: 1\n\n(compared using ==)\n" end it 'fails properly when the actual is an array of multiline strings' do expect { expect(["a\nb", "c\nd"]).to eq([]) }.to fail_matching("expected: []") end end end end
Version data entries
36 entries across 36 versions & 12 rubygems