Sha256: bc1eee0a6534ce055a5a0b11a5263b49de3c803968beca179401a6b7999417a5
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require 'spec_helper' describe Object, "#should" do before(:each) do @target = "target" @matcher = double("matcher") allow(@matcher).to receive(:matches?).and_return(true) allow(@matcher).to receive(:failure_message) end it "accepts and interacts with a matcher" do expect(@matcher).to receive(:matches?).with(@target).and_return(true) expect(@target).to @matcher end it "asks for a failure_message when matches? returns false" do expect(@matcher).to receive(:matches?).with(@target).and_return(false) expect(@matcher).to receive(:failure_message).and_return("the failure message") expect { expect(@target).to @matcher }.to fail_with("the failure message") end context "on interpretters that have BasicObject", :if => defined?(BasicObject) do let(:proxy_class) do Class.new(BasicObject) do def initialize(target) @target = target end def proxied? true end def method_missing(name, *args) @target.send(name, *args) end end end it 'works properly on BasicObject-subclassed proxy objects' do expect(proxy_class.new(Object.new)).to be_proxied end end end describe Object, "#should_not" do before(:each) do @target = "target" @matcher = double("matcher") end it "accepts and interacts with a matcher" do expect(@matcher).to receive(:matches?).with(@target).and_return(false) allow(@matcher).to receive(:failure_message_when_negated) expect(@target).not_to @matcher end it "asks for a failure_message_when_negated when matches? returns true" do expect(@matcher).to receive(:matches?).with(@target).and_return(true) expect(@matcher).to receive(:failure_message_when_negated).and_return("the failure message for should not") expect { expect(@target).not_to @matcher }.to fail_with("the failure message for should not") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-expectations-3.0.0.beta2 | spec/rspec/expectations/extensions/kernel_spec.rb |