Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use unstub with any_instance #67

Closed
dolzenko opened this issue Jul 18, 2011 · 3 comments
Closed

Can't use unstub with any_instance #67

dolzenko opened this issue Jul 18, 2011 · 3 comments

Comments

@dolzenko
Copy link

test_model.rb

class TestModel
  def meth
    raise 'meth called'
  end
end

test_model_spec.rb

require 'spec_helper'

describe TestModel do
  before do
    TestModel.any_instance.stub(:meth)
  end

  it 'should be stubbed' do
    lambda { TestModel.new.meth }.should_not raise_error
  end

  it 'should be able to unstub' do
    TestModel.any_instance.unstub(:meth)
    lambda { TestModel.new.meth }.should raise_error
  end
end

rspec test_model_spec.rb -f d

TestModel
  should be stubbed
  should be able to unstub (FAILED - 1)

Failures:

  1) TestModel should be able to unstub
     Failure/Error: TestModel.any_instance.unstub(:meth)
       The method `meth` was not stubbed or was already unstubbed
     # test_model_spec.rb:13

PS. I think we're all robots here speaking code&specs :)

kaiwren added a commit to c42engineering/rspec-mocks that referenced this issue Jul 19, 2011
@kaiwren
Copy link
Contributor

kaiwren commented Jul 19, 2011

@dolzenko - I've sorted it out in #68. Please try this out and let me know if it works for you /cc @justinko

@dolzenko
Copy link
Author

Sorry whats the best way to test things like this? I mean whats the best way to get rspec-mocks with the fix included in my project?

@kaiwren
Copy link
Contributor

kaiwren commented Jul 19, 2011

Take a look at http://gembundler.com/git.html

justinko added a commit that referenced this issue Jul 20, 2011
Fixing #67 - unstub support for any_instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants