[rspec-users] RSpec mock question

2012-01-09 Thread Christopher Voltz
How can I mock the XMLRPC::Client.new3 class method using rspec's mock? I expected this spec: describe Foo do it 'should call new3' do options = {} XMLRPC::Client.any_instance.should_receive(:new3).with(options) Foo.new(options) end

Re: [rspec-users] RSpec mock question

2012-01-09 Thread Patrick J. Collins
> 1) Foo should call new 3 > Failure/Error: Unable to find matching line from backtrace >Exactly one instance should have received the following > message(s) but didn't: new3 > > How can I change the spec to make this pass (while verifying that new3 > was cal

Re: [rspec-users] RSpec mock question

2012-01-09 Thread Christopher Voltz
I knew it was a class method but wasn't sure how to put an expectation on a class method. I tried your suggestion but, unfortunately, it still fails, although with a different error message: 1) Foo should call new 3 Failure/Error: XMLRPC::Client.should_receive(:new3).with(optio

Re: [rspec-users] RSpec mock question

2012-01-09 Thread Christopher Voltz
I got it working. I had defined new on Foo rather than initialize so it was my dumb mistake that prevented your solution from working. Thanks a lot for your help Patrick. Christopher On 01/09/2012 01:15 PM, Christopher Voltz wrote: > I knew it was a class method but wasn't sure how to put an ex

Re: [rspec-users] view_context in specs

2012-01-09 Thread Benito S.
If you put this on your spec_helper.rb //If you have your spec in the directory "spec/presenters" config.include ActionView::TestCase::Behavior, example_group: {file_path: %r{spec/presenters}} Then you can use a method, :view, that you can use as the view context like this let(:profile) { Profil