Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Shoegaze doesn't support mock a class with argumented initializer #3

Open
zozowell opened this issue Jul 23, 2019 · 1 comment
Open

Comments

@zozowell
Copy link

What is problem I'd like to solve?

For class with argumented initializer, shoegaze doesn't mock class initialize function, then instantiation like FakeClass.proxy.new(args) fails with following error:

  1) FakeTest works with customized initializer in shoegaze
     Failure/Error: subject { FakeTest.proxy.new("dummy") }

     ArgumentError:
       wrong number of arguments (given 1, expected 0)

How to reproduce

class TestClass
  def initialize(dummy)
  end
end

class FakeTest < Shoegaze::Mock
  mock "TestClass"

  implement_instance_method :initialize do
    default do
      datasource do |*arg|
        "instance method implementation doesn't help, \
        because `missing_method` wasn't hit at all."
      end
    end
  end
end

describe FakeTest do
  subject { FakeTest.proxy.new("dummy") }
  
  it "works with customized initializer in shoegaze" do
    expect(subject).to be_kind_of Shoegaze::Proxy::Template
  end
end
@zozowell
Copy link
Author

#4 is the fix

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant