similar to: Is anybody using a block to verify arguments passed to an expectation?

Displaying 20 results from an estimated 4000 matches similar to: "Is anybody using a block to verify arguments passed to an expectation?"

2007 Jan 11
4
counter-intuitive behaveour when passing a proc to Mocha::Expectation#returns
Let''s say that I have a procedure that: * gets the number of bytes to write into some file * and returns the number of successfully written bytes def save( text, len ) This procedure is being used all over the place especially inside the method "process" which I want to test. Thus in order not to polute my filesystem I stub the "save" procedure. But of course in
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:
2006 Sep 25
3
Problem stubbing instances referred to by constants
Hi James, An instance retains its mocha between tests if that instance is pointed to by a constant. The simplest failing test is something like (add as a new file in mocha/test).. #--code-- require File.join(File.dirname(__FILE__), "test_helper") require ''stubba'' class WemStubbaTest < Test::Unit::TestCase Arr = [1, 2, 3] def test_a
2007 Apr 03
5
small suggestion - once method on Expectation
I find that a lot of times I want to ensure a method gets called exactly once, for example when testing caching or eager loading. What does the list think of adding this little humane method to Mocha::Expectation? def once times(1) self end which means this: def test_should_only_grab_post_once_from_the_cache Post.expects(:get_cache).with(google_vs_yahoo.id).times(1)
2007 Aug 08
1
Mocking Time, delegating to original object
In my Unit tests, I run into the all-too-common problem of Time.expects(:now) being called by Benchmark before the method is unmocked. Instead of messing around with the teardown order, I decided to modify the Expectation with a new method, .stops_mocking. Here are the changes I use, including a few monkey patches to push relevant objects down to where I want them, all wrapped up in a big ugly
2007 Sep 11
3
Expectations on portions of arguments called.
I''d like to create expectations on just portions of the arguments a function takes. For example, I want to verify that the a certain ActiveRecord association extension adds an order clause to the find options hash. Currently I simply check the entire argument structure, something like this def test_referring_journals_should_order_by_citation_count article =
2007 Nov 04
3
Returning the mock associated with an expectation.
I was reading through the FlexMock docs and noticed the expectation method .mock, which returns the original mock associated with an expectation. It looks really handy for writing nice all-in-one mocks like: mock_user = mock(''User'').expects(:first_name).returns(''Jonah'').mock So I started playing around with mocha and found I could actually already do this!
2007 Jan 23
2
SslRequirements plugin and mocha
Hi. I''m loving mocha but have ran into a problem with using the mocha plugin with a project that has the SslRequirement plugin. It seems there is some conflict between the two? Any ideas? $ ruby test/functional/calendar_controller_test.rb /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:478:in `const_missing'': uninitialized constant
2006 Sep 12
4
ActiveRecord Validations - validates_uniqueness_of
Hello, I''m wanting to use Mocha and Stubba for my tests in place of the default Rails testing with fixtures. I have the following class: class Person < ActiveRecord::Base validates_uniqueness_of :email end and am wondering how I can test to ensure that the validates_uniqueness_of validation is running. Any ideas? -Jonathan
2007 Jun 21
2
expects with returns that returns the return value of the actual method
I''m trying to test some code that''s using active_merchant using the following test. What I''d like to be able to do is verify that purchase is called, however, rather than specifying the return value for purchase with returns, I''d like it to return the actual return value provided if you called the non mocked purchase method. Is this possible? def test_charge
2007 Mar 12
1
expectations in order
Hi folks. Does mocha support expectations in a sequence, like JMock''s after(...) method? Or something like that to support ordered expectations? Thanks, Dan
2006 Nov 15
3
using expects with (for Hash and Array)
First off, thanks for the great library. Is there a way setup expects with this: runtime_options[:property] = properties_option_string or do i have to use: runtime_options.store(:property, properties_option_string) which results in this: runtime_options.expects(:store).with(:property, ''prop1=1'') Thanks for your help. jeremy
2006 Nov 28
2
Partial matches in expectations
Hi ! I would like to ascertain the following in a test case: @template.expects(:content_tag).with(:fieldset, :__any_arguments__i_dont_care) Is it possible to do so ? If so how ? If not, is it something the community wants ? Is it useful ? Thanks ! -- Fran?ois Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/
2007 Oct 25
4
Insure a method is called with no arguments.
We''ve been working with the ParameterMatchers (so cool!) but I don''t see a way to insure a method is called with no arguments. I imagined something like: user = mock(''User'') user.expects(:friends).with(nothing) Anyone run into this?
2006 Aug 17
1
expectations on stubs (stubba) or mock methods on existing classes?
Hello, First, thanks for releasing Mocha. As someone who''s been practicing TDD much longer than I''ve been using Rails, one of my biggest complaints has always been the fact that the "Unit" tests are more like intefration tests because of how tightly coupled the domain model is when using ActiveRecord. Stubba looks like it could really help aleviate this problem. The
2008 Jan 20
2
Bug #17118 - expectations should take precedence over stubs
I wanted to draw attention to this bug report [A] which highlights a change that was made between Mocha 0.4 and 0.5. It may have lead to tests which pass unexpectedly. Does my explanation (below) make sense to people? It feels like we should at least add some warnings to the documentation. You are correct that this behaviour did change between Mocha v0.4.0 and > v0.5.0 (in revision 115).
2007 Feb 01
3
with-arguments block is executed regardless of method?
I have a test case where I''m stubbing one method (''jobs''), and mocking another (''new_worker'') MiddleMan.stubs(:jobs) MiddleMan.expects(:new_worker).with{|args| args[:class] ==:download_worker} MiddleMan.jobs() The above code results in an error ("The error occurred while evaluating nil.[]") - calling ''jobs'' results in
2006 Oct 25
2
Isn''t it possible to stub / expect on :id ?
Hi all ! Running this: @payout = stub_everything(:id => 141) Payout.stubs(:find).with(@payout.id).returns(@payout) Generates this warning: ./test/functional/payouts_controller_test.rb:22: warning: Object#id will be deprecated; use Object#object_id What am I missing ? :id is a fairly frequent method to override in Rails-based applications. I''m using Mocha from
2007 Jun 08
4
Mocha 0.5 released
* Hamcrest-style parameter matchers * Values returned and exceptions raised on consecutive invocations * Yields on consecutive invocations * Multiple yields on single invocation * Invocation dispatch fixed * Deprecated returning result of a Proc -- James. http://blog.floehopper.org
2018 May 08
4
[Bug 13423] New: Checksum option does not work as expected when append-verify is used
https://bugzilla.samba.org/show_bug.cgi?id=13423 Bug ID: 13423 Summary: Checksum option does not work as expected when append-verify is used Product: rsync Version: 3.1.3 Hardware: All OS: All Status: NEW Severity: normal Priority: P5 Component: core