similar to: Pending should_receive shows as FIXED

Displaying 20 results from an estimated 30000 matches similar to: "Pending should_receive shows as FIXED"

2008 Jun 12
1
Does anyone know how to mock the Rails Logger then set expectations with should_receive?
Hey Guys, I''m trying to mock the Rails Logger for the following code: ... rescue TimeoutError => error $logger.error("#{self.name} Timeout for #{path}: #{error}") and return rescue SocketError => error $logger.error("#{self.name} SocketError for #{path}: #{error}") and return rescue StandardError => error
2008 Mar 14
2
Multiple should_receive(:render).with
I''m trying to specify that a particular view must render two different partials. My spec looks like: describe AClass do it do template.should_receive(:render).with(:partial => ''foo'', :locals => { ... }) ... end describe ''some conditional case'' do it do template.should_receive(:render).with(:partial =>
2007 Jun 03
3
should_receive.again
Hi, It appears that if I have 2 should_receives in a row, the latest one overrides the previous one(s). If there isn''t one, could we add a way to accumulate them, such as @thing.should_receive(:method).and_return(@value) @thing.should_receive(:method).again.and_return(@value) @thing.should_receive(:method).again.and_return(@value) would be equivalent to
2008 Jun 12
1
how do I mock the Rails Logger with should_receive?
Hey Guys, I''m trying to mock the Rails Logger for the following code: ... rescue TimeoutError => error $logger.error("#{self.name} Timeout for #{path}: #{error}") and return rescue SocketError => error $logger.error("#{self.name} SocketError for #{path}: #{error}") and return rescue StandardError => error
2006 Oct 23
6
overriding mock expectations
There is one annoyance I''m encountering with the Mock API in rSpec. Overall it works well, as far as dynamic mocks go ;)... but there''s this one thing... It doesn''t allow overriding of expectations. example: m = mock("blah") m.should_receive(:one).any_number_of_times().and_return(1) m.should_receive(:one).and_return(1) The second call to should_receive
2007 Apr 16
0
Fwd: ANN: FlexMock 0.6.0 Released
FYI - Jim Weirich just released an rspec-compatible version of FlexMock. For those of you using trunk, you can now use either FlexMock, Mocha, or RSpec''s built-in mocking framework by saying: Spec::Runner.configure do |config| config.mock_with :flexmock # or :mocha or :rspec (default) end The choice is yours. Mock in peace. Cheers, David ---------- Forwarded message ---------- From:
2008 Jan 13
2
should_receive twice and arguments
Hi all, I have a method calling Klass.create! two times with different arguments (this happens in a class reponsable for reading in a csv file) I want to test those like this: in one test: Klass.should_receive(:create!).with(:name => "foo").once in another: Klass.should_receive(:create!).with(:name => "foo2").once This doesn''t work because the
2008 Jun 02
1
Cherry-picking mocks?!
A colleague just came in and asked me about a problem he was having with stub_render, which reminded me of another issue he had a week or so ago, which seems related. Let me start with the earlier issue. He was trying to write specs for a method which sends the same message possibly multiple times, but with different arguments under different calling conditions. He wanted to write
2007 Jun 21
4
should_receive stubs methods?
Hey, I''m using rspec and rails and have a spec that tests if a before_filter is executed, I also have a spec that tests if a method called by the filter is executed. It appears however that when I should_receive something, it is no longer actually called when I fire the http request. I''m not sure how, or where exactly I should manually fire the filter, either before or after the
2010 Jul 13
2
[Rspec] Difference between stub and message expectation with any_number_of_times
I''m wondering what''s the difference between stub and message expectation with any_number_of_times, for example: myMock = mock("mymock") myMock.stub!(:is_a?).with(MyClass).and_return(false) and myMock = mock("mymock") myMock.should_receive(:is_a?).with(MyClass).any_number_of_times.and_return(false) because is_a? may not be called at all, it just like a
2007 Jun 11
2
Testing create in Rails controller
Hi All So I am a first-time caller ;-) ... and have been trying to apply RSpec to the depot example in Dave Thomas'' book as I build the application. I am having a problem testing the admin controller create method and cannot quite see where I am going wrong so was hoping for a pointer :-) My spec looks like: describe AdminController do before(:each) do @product =
2008 Mar 08
3
should_receive(:foo).with(any_object)
Hey, I just ran into a situation where I would like to expect a method call with an argument I know and another one, which is a random number. I think mocking up the rand method is somehow ugly so I thought maybe this is the first time where I can take something from Java to Ruby ;) Java''s EasyMock mocking library knows things like "anyObject()" and "anyInteger()" in
2007 Apr 17
8
problem with rspec_on_rails and @controller.should_receive(:render) in trunk
Hey guys! I am using rspec trunk, and I am having a little problem with the latest version. (I am quite sure this worked with an older version about a week ago) heres the spec: it "should render the new user form without layout for a xhr request" do @controller.should_receive(:render).with(:layout=>false) xhr :get,:new end and the controller: def new render
2007 Aug 17
4
should_receive, used in the wrong place?
What do you guys think of this: if someone calls should_receive outside of an "it" block, it warns you. before(:each) do @foo = Foo.new @foo.should_receive(:monkeys) end would warn you that you''re setting an expectation in the wrong place, and that "stub" is correct when setting up objects. Opinions? courtenay
2007 Dec 04
10
Unexpected message on :attr_accessor
This may be a dumb noob issue, but I haven''t found any answers while seaching the forum-- I have a controller method def edit @user = User.find params[:id] @user.password_confirmation = @user.password end The User class has an "attr_accessor :password_confirmation" definition (so "password_confirmation" doesn''t exist in the users table). My spec
2007 Nov 01
2
Writing controller specs
One thing that is bothering me about my controller specs is that sometimes I end up with a number of examples that are the same except for the example name. The reason that this happens is that I''ve expressed all the expected behavior with should_receive. While this does more or less work as intended it doesn''t feel right. As an example, let''s say I''m writing
2007 Oct 16
2
Does a mock model have to satisfy contraints
I am a little confused to the what happens with the following: before do @site = mock_model(Site, :to_param => "1") Site.stub!(:new).and_return(@site) end def post_with_successful_save @site.should_receive(:save).and_return(true) post :create, :site => {} end I understand that the "@site.should_receive(:save)..." places a check to whether the
2011 Jul 27
3
Rspec with ActionMailer and .deliver
I''m in the process of migrating from Rails 2 with rspec 1 to Rails 3 with rspec 2, the process has been going pretty well, however, today I came across an issue that I wanted to share. I have a controller that sends out an email through a mailer. Rails 2 code: CurriculumCommentMailer.deliver_comment_update(@curriculum_comment, "created") Rails 3 code:
2008 Mar 05
7
mocking successive return values
I''m having a problems mocking successive return values. I don''t know if I''m doing something wrong or if this is a limitation of rspec mocks. Any ideas of what I may be doing wrong? I''m trying to test the generate_quote_number method. It generates a quote number, looks to see if it is in the db already. If it is, it calls itself to try again. I want
2007 Jul 24
2
Mocking Resolv::DNS?
Hello Rspecers, I have a rails project where I am calling Resolv::DNS.open and then using the block to check a domain name. The code snippet in question is: domain = "mytest.com" Resolv::DNS.open do |dns| @mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) end I obviously want to stub this out, especially for speed but can''t quite work out how. I