Sha256: 6517d920fe616c0052bfcf3e49d02408031107b53c0816b31dac03248d452db2

Contents?: true

Size: 584 Bytes

Versions: 2

Compression:

Stored size: 584 Bytes

Contents

require 'spec_helper'

describe "Stubbing .new on fake class" do
  class ExampleForStubbingNew
  end

  before do
    extend Bogus::MockingDSL
  end

  it "allows stubbing new on a class" do
    fake_class = fake(ExampleForStubbingNew, as: :class)
    stub(fake_class).new { :stubbed_value }

    instance = fake_class.new

    expect(instance).to eq(:stubbed_value)
  end

  it "returns fake instances when nothing is stubbed" do
    fake_class = fake(ExampleForStubbingNew, as: :class)

    instance = fake_class.new

    expect(instance).to be_an_instance_of(fake_class)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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