psyho / bogus

Fake library for Ruby
Other
359 stars 14 forks source link

Argument requirements on .new #65

Closed tpendragon closed 9 years ago

tpendragon commented 9 years ago

Given

class TestClass
  def initialize(foo, bar)
  end
end

I would expect

stub(TestClass).new(1) { fake(:test_class) }

to throw an error, because TestClass can't instantiate with only one argument. It doesn't. Is this because it's sidestepping #initialize, where the arguments are actually defined?

tpendragon commented 9 years ago

@psyho https://github.com/terrellt/bogus/commit/2cd401328e39f3b7372faee5220c81ca26c7000c I think this covers it.

psyho commented 9 years ago

Thanks for catching this issue.

BTW. You don't need to call object.allocate.method(), you can also use object.instance_method().

tpendragon commented 9 years ago

Ah, thanks. Would you like me to change that bit and send a PR, or would you like to do the commit?

psyho commented 9 years ago

I cherry-picked your commit and made some cosmetic changes. Thank you for your help.

tpendragon commented 9 years ago

Very nice, thank you for getting it in.