Sha256: c0c8856f485c7ae18ff1b1f5ad8485b1cd32ba6a78a597d5b018ad4ac6a0a2d9

Contents?: true

Size: 839 Bytes

Versions: 2

Compression:

Stored size: 839 Bytes

Contents

require 'spec_helper'

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

  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)

    expect(fake_double.stubbed).to eq([[:foo, [bogus_any_args], 1], [:bar, [bogus_any_args], 2]])
  end

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

    expect(fake_double.stubbed).to eq([[:foo, [bogus_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

2 entries across 2 versions & 1 rubygems

Version Path
bogus-0.1.7 spec/bogus/stubbing/multi_stubber_spec.rb
bogus-0.1.6 spec/bogus/stubbing/multi_stubber_spec.rb