Sha256: b47c2d27f7af455676d4dd46baf47fb6816128ab8d3cdf7c196f1227c6cbd520

Contents?: true

Size: 991 Bytes

Versions: 2

Compression:

Stored size: 991 Bytes

Contents

require 'spec_helper'

describe Bogus::RegistersCreatedFakes do
  let(:fake_registry) { double }
  let(:creates_fakes) { double }
  let(:double_tracker) { double }

  let(:registers_created_fakes) { isolate(Bogus::RegistersCreatedFakes) }

  before do
    allow(fake_registry).to receive(:store)
    allow(creates_fakes).to receive(:create) { :the_fake }
    allow(double_tracker).to receive(:track).with(:the_fake)
  end

  it "registers the fakes created by creates_fakes" do
    registers_created_fakes.create(:foo, as: :instance) { Object }

    expect(fake_registry).to have_received(:store).with(:foo, :the_fake)
  end

  it "tracks the created fakes for purposes of mock expectations" do
    registers_created_fakes.create(:foo, as: :instance) { Object }

    expect(double_tracker).to have_received(:track).with(:the_fake)
  end

  it "returns the created fake" do
    fake = registers_created_fakes.create(:foo, as: :instance) { Object }

    expect(fake).to eq :the_fake
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bogus-0.1.7 spec/bogus/fakes/registers_created_fakes_spec.rb
bogus-0.1.6 spec/bogus/fakes/registers_created_fakes_spec.rb