Sha256: 6bd9fa37ae1f57a5d177e9114d69c6b974185458e96d17ffbc85dcf82dbeb0d5
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
require 'spec_helper' module Bogus describe Double do shared_examples_for "double behavior" do it "tracks existence of test doubles" do mock(double_tracker).track(object) double.stub.foo("a", "b") { "the result" } end it "verifies stub definition" do mock(verifies_stub_definition).verify!(object, :foo, ["a", "b"]) double.stub.foo("a", "b") { "the result" } end it "stubs shadow methods" do object.extend RecordInteractions mock(object.__shadow__).stubs(:foo, "a", "b") double.stub.foo("a", "b") { "the result" } end it "mocks shadow methods" do object.extend RecordInteractions mock(object.__shadow__).mocks(:foo, "a", "b") double.mock.foo("a", "b") { "the result" } end it "adds method overwriting" do double.stub.foo("a", "b") { "the result" } overwrites_methods.overwrites.should == [[object, :foo]] end it "records double interactions" do mock(records_double_interactions).record(object, :foo, ["a", "b"]) double.stub.foo("a", "b") { "the result" } end end let(:double_tracker) { stub(track: nil) } let(:verifies_stub_definition) { stub(verify!: nil) } let(:records_double_interactions) { stub(record: nil) } let(:overwrites_methods) { FakeMethodOverwriter.new } let(:double) { isolate(Double) } context "with regular objects" do let(:object) { Samples::Foo.new } include_examples "double behavior" end context "with fakes" do let(:object) { Samples::FooFake.new } include_examples "double behavior" end class FakeMethodOverwriter def overwrite(object, method) overwrites << [object, method] object.extend RecordInteractions end def overwrites @overwrites ||= [] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bogus-0.0.3.rc.1 | spec/bogus/double_spec.rb |