similar to: [Rspec] Difference between stub and message expectation with any_number_of_times

Displaying 20 results from an estimated 110 matches similar to: "[Rspec] Difference between stub and message expectation with any_number_of_times"

2006 Nov 10
2
mock syntax order
I have the following statement mock_requester.should_receive(:request_with).with ("x").any_number_of_times.and_return(@object) which works fine, but when i do it backwards, which makes the same amount of sense syntactically, it fails mock_requester.should_receive(:request_with).with("x").and_return (@object).any_number_of_times are all of the mock options
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 30
4
Mocking with Calculated Results
I am setting up an AR mock object and wanted to sanity check it. My intent is to mix this into all my examples and then override/add methods where necessary. Note that I''ve anticipated three cases for find: find with one numeric argument => object find with :all => Array find with anything else => nil This roughly approximates how ActiveRecord::find works in this case
2007 May 23
2
rspec mocha and controller specs without integrated_views
The ability to choose a mocking framework is great as I prefer mocha, but I am have problems. On my controller specs, I am forced to ''integrate_views'' as the following code below shows you, the mocking of views is rspec specific. See stub! versus mocha''s stub unless block_given? unless integrate_views?
2007 Aug 11
2
Rspec and acl_system2 plugin
Hello, I''m trying to spec a Rails application using the couple restful_authentication/acl_system2 plugins. In my admin layout, I put the following code : <% restrict_to "admin" do -%> <ul id="admin-tabs"> <li> /users Users management </li> </ul> <% end -%> Then in my spec file
2006 Dec 12
3
Stubs breaking other things
Hi All I''m working on converting some existing controller specs to use mocks and stubs rather than real ActiveRecord objects in a Rails project. In one of my controller actions, I use a database transaction. So, the obvious thing to do is have this in my setup block: Project.stub!(:transaction) Firstly, is there an easy way to have that stub yield to the block passed to any
2006 Oct 04
3
do we need stubbing?
Hey all - The trunk currently supports three types of mocking/stubbing: Mock Objects (created dynamically at runtime) Partial Mocking of methods on existing classes Stubbing of methods on existing objects or classes The main difference between Partial Mocking and Stubbing is that Stubs don''t verify. I''m wondering if we really need the stubbing facility at all, given that we
2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model? I''m assuming i need to say @mock_thing = mock_model(Thing) @mock_thing_errors = mock("errors") @mock_thing_errors.should_receive(:full_messages).and_return("An error") @mock_thing.should_receive(:errors).and_return(@mock_thing_errors) Just wanted to check the best practice on this kind of thing and how
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
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 26
5
Coding standards and whitespace
Recently as a result of using Git I''ve noticed a number of inconsistencies in the RSpec codebase with respect to whitespace (mixed line endings, mixed use of spaces and tabs for indentation, and trailing whitespace at the end of lines). I never would have noticed, but Git produces nice colorized diff output which highlights these kinds of inconsistencies. I wanted to ask if the
2007 Aug 23
6
controller spec with model that validates_uniqueness
I want to use mocks and stubs to test the controller, but am having trouble getting my validation not to trigger. Here''s the code: # spec: Image.stub!(:find).and_return(@image) @image.should_receive(:save!).once.with(:any_args) put :update, :id => @image.id, :category_id => @category.id, :image => {:name => ''test'', :image_number =>
2007 Jun 02
7
I''m really bad at controllers, help please.
Hey, Sorry for so many questions - I''m really bad at this right now. I''m trying to cover the following code w/ rspec def index if params[:user_id] @user = User.find(params[:user_id]) @messages = @user.messages end end So basically what I''m doing is listing all the messages for a user, provided there is an id parameter. describe
2007 Feb 18
1
get() method in custom expectation matcher?
I''m trying to write a custom expectation: controller.should_require_login_for(:action_name). I''m using the example in the docs for ''Custom Expectation Matchers'' but I''m unsure how to make the get() method available to my ShouldRequireLogin class. I''ve tried requiring spec_helper but no joy. can anyone help? thanks -- View this message in
2007 Feb 20
1
having should_receive expectation for things that happen in setup
Hi! The following example doesn''t work for me: http://pastie.caboo.se/41732 However, if the call to msg() happens in the specify block after the expecation and not in the setup, it will pass. Why is this? I thought the setup method was there to actually ''construct'' the context and the specifications are some kind of "postconditions" that only need to be
2007 Jan 27
1
should expectation syntax has changed
This is just a note in case anyone else is using the (I believe experimental) custom expectations. The custom expectation I had written used the custom ''met_by?'' function, which now appears to have been replaced by the ''matches?'' function to determine whether the expectation is met. Steve
2006 Oct 10
0
Is anybody using a block to verify arguments passed to an expectation?
For example... def test_should_receive_at_least_three_arguments object = mock object.expects(:foo).with { |*args| args.size >= 3 } #=> Rather pointless expectation to ensure that we get at least three arguments end If possible, I''d like to remove/rename this functionality. Instead, I''d like to be able to set an expectation that checks for specified arguments _and_ a
2006 Sep 23
1
Fwd: [PATCH] Remove warning in expectation.rb
Begin forwarded message: > From: Xavier Shay <xshay at rhnh.net> > Date: 23 September 2006 05:53:57 BDT > To: james.mead at mail.com > Subject: [PATCH] Remove warning in expectation.rb > > Hi James, > Please find below a one line addition to lib/mocha/expectation.rb > to remove the following warning: > > mocha-0.3.2/lib/mocha/expectation.rb:32: warning:
2016 Feb 17
0
[Bug 1047] Creating expectation entry using conntrack tool results in ESHUTDOWN
https://bugzilla.netfilter.org/show_bug.cgi?id=1047 --- Comment #5 from Asbj?rn Sloth T?nnesen <asbjorn at asbjorn.it> --- Ping -- You are receiving this mail because: You are watching all bug changes. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.netfilter.org/pipermail/netfilter-buglog/attachments/20160217/e911c053/attachment.html>
2013 Dec 06
0
Re: [PATCH] builder: adapt test-virt-builder-list.sh output expectation
On Fri, Dec 06, 2013 at 03:00:41PM +0100, Pino Toscano wrote: > ee0e56f43e55307fefa1d04505ed6477d604d220 slightly changes the output of > --list but test-virt-builder-list.sh has not been updated accordingly. > > Adapting the expected output makes test-virt-builder-list.sh pass again. > -os-version: phony-debian > +OS version: phony-debian Now I look