Sha256: 6cc49747197e47aa134dfc4d7e250fab278e3968ee19e2cda693508964b9d5d7

Contents?: true

Size: 785 Bytes

Versions: 9

Compression:

Stored size: 785 Bytes

Contents

require 'spec_helper'

describe Bogus::MultiStubber do
  let(:double) { FakeDouble.new }
  let(:create_double) { proc{ double } }
  let(:any_args) { Bogus::AnyArgs }

  let(:multi_stubber) { isolate(Bogus::MultiStubber) }

  it "stubs all the given methods with any args returning the given value" do
    multi_stubber.stub_all(Object.new, foo: 1, bar: 2)

    double.stubbed.should == [[:foo, [any_args], 1], [:bar, [any_args], 2]]
  end

  it "uses passed procs as the return value block" do
    multi_stubber.stub_all(Object.new, foo: proc{ 1 })

    double.stubbed.should == [[:foo, [any_args], 1]]
  end

  class FakeDouble
    def stubbed
      @stubbed ||= []
    end

    def stubs(name, *args, &return_value)
      stubbed << [name, args, return_value.call]
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bogus-0.1.4 spec/bogus/stubbing/multi_stubber_spec.rb
bogus-0.1.3 spec/bogus/multi_stubber_spec.rb
bogus-0.1.2 spec/bogus/multi_stubber_spec.rb
bogus-0.1.1 spec/bogus/multi_stubber_spec.rb
bogus-0.1.0 spec/bogus/multi_stubber_spec.rb
bogus-0.0.4 spec/bogus/multi_stubber_spec.rb
bogus-0.0.3 spec/bogus/multi_stubber_spec.rb
bogus-0.0.3.rc.2 spec/bogus/multi_stubber_spec.rb
bogus-0.0.3.rc.1 spec/bogus/multi_stubber_spec.rb