Sha256: b428c54820569a7bbcdcdac73d5a432aee48144f962cae43100550beeecddf68
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' describe "Stubbing existing methods on fakes" do before do extend Bogus::MockingDSL Bogus.clear end it "should be possible to stub to_s" do foo = fake(:foo) { Samples::Foo } stub(foo).to_s { "I'm a foo" } expect(foo.to_s).to eq("I'm a foo") end it "should be possible to mock to_s" do foo = fake(:foo) { Samples::Foo } mock(foo).to_s { "I'm a foo" } expect { Bogus.after_each_test }.to raise_exception(Bogus::NotAllExpectationsSatisfied) end it "should be possible to stub to_s on anonymous fake" do foo = fake(to_s: "I'm a foo") expect(foo.to_s).to eq("I'm a foo") end class Object def sample_method_for_stubbing_existing_methods end end class SampleForStubbingExistingMethods end it "should be possible to stub arbitrary methods that were defined on Object" do foo = fake(:foo) { SampleForStubbingExistingMethods } stub(foo).sample_method_for_stubbing_existing_methods { :bar } expect(foo.sample_method_for_stubbing_existing_methods).to eq(:bar) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bogus-0.1.7 | spec/bogus/stubbing/stubbing_existing_methods_on_fakes_spec.rb |
bogus-0.1.6 | spec/bogus/stubbing/stubbing_existing_methods_on_fakes_spec.rb |