Sha256: b3c9809700203b991948d489900c0aeaf7356bba43a9ff1fc6a5b66fb6719473

Contents?: true

Size: 565 Bytes

Versions: 1

Compression:

Stored size: 565 Bytes

Contents

require 'spec_helper'

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

  include Bogus::MockingDSL

  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

1 entries across 1 versions & 1 rubygems

Version Path
bogus-0.1.5 spec/bogus/fakes/stubbing_new_method_on_fake_class_spec.rb