Sha256: c142f4ce26660dd98183c30ced9f180f5d3550d59215c66eb20fa60df020a826

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

describe "Frozen Fakes" do
  include Bogus::MockingDSL

  class ExampleForFreezing
    def foo(x)
    end
  end

  shared_examples_for "frozen fakes" do
    before { object.freeze }

    describe "stubbing" do
      it "allows stubbing" do
        stub(object).foo(1) { 123 }

        object.foo(1).should == 123
      end
    end

    describe "mocking" do
      it "allows mocking" do
        mock(object).foo(1) { 123 }

        object.foo(1).should == 123
      end

      it "allows verifying expectations" do
        mock(object).foo(1) { 123 }

        expect {
          Bogus.after_each_test
        }.to raise_error(Bogus::NotAllExpectationsSatisfied)
      end
    end

    describe "spying" do
      it "allows spying" do
        object.foo(1)

        object.should have_received.foo(1)
        object.should_not have_received.foo(2)
      end
    end
  end

  context "anonymous fakes" do
    let(:object) { fake }

    include_examples "frozen fakes"
  end

  context "named fakes" do
    let(:object) { fake(:example_for_freezing) }

    include_examples "frozen fakes"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bogus-0.1.4 spec/bogus/fakes/frozen_fakes_spec.rb
bogus-0.1.3 spec/bogus/frozen_fakes_spec.rb
bogus-0.1.2 spec/bogus/frozen_fakes_spec.rb
bogus-0.1.1 spec/bogus/frozen_fakes_spec.rb
bogus-0.1.0 spec/bogus/frozen_fakes_spec.rb