Sha256: c72d616052006cc978575ab2190e9d79216cbf97a77403914629892de75e285e

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 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)

    expect(double.stubbed).to eq([[: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 })

    expect(double.stubbed).to eq([[: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

1 entries across 1 versions & 1 rubygems

Version Path
bogus-0.1.5 spec/bogus/stubbing/multi_stubber_spec.rb