dkubb / adamantium

Create immutable objects
MIT License
373 stars 13 forks source link

Don't works with rspec-mock #8

Closed shingara closed 10 years ago

shingara commented 11 years ago

If you mock an object and this object is memoize by Adamantium, you mock don't work anymore

Adamantium do a #dup on object to memoize it. But a mock object from rspec-mock forget all this stub do before the dup.

By example

class Foo
  include Adamantium

  def bar
     Baz.new
  end
  memoize :bar
end

Baz.stub(:new).and_return(mock('bar', :hello => 'ok')
Foo.new.bar.hello # method not found

If we use the :freezer => noop it's works.

I try mock system with mocha and it's work.

mbj commented 11 years ago

@dkubb This is an integration rather than an internal problem of adamantium. rspec-mocks are not prepared to be #dup ed. We need a general policy on how we act with this kind of problems.

mbj commented 11 years ago

IMHO we should fix rspec-mock.

shingara commented 11 years ago

I report an issue on rspec-mock : https://github.com/rspec/rspec-mocks/issues/199

dkubb commented 10 years ago

I'm going to mark this as closed since there has been no recent activity.