Displaying 20 results from an estimated 5000 matches similar to: "Howto find out, a function was called"
2007 Jun 12
4
advice on new failures with 0.5.0
Hi all,
We just updated to the latest version of Mocha and now we''re seeing a
lot of odd test failures. If this isn''t the appropriate place for a
question like this, please let me know.
Say I have code like this in a controller:
DataMonitor.toggle_notification!
And I mock it like this:
DataMonitor.any_instance.stubs(:toggle_notification!)
This would work fine with Mocha
2006 Oct 13
6
If I stub do I have to mock as well?
Hi, I''m new to mocha and stubba but eager to learn. I have a rails
functional test in which I would like to stub an instance method of
particular class to always return true. I tried the following:
def test_post_checkout
Order.any_instance.stubs(:successful?).returns(true)
post :checkout
assert_response :redirect
assert_equal "Checkout was successful.",
2006 Oct 06
8
Expecting calls with two different parameters
Hello,
I''ve just started using Mocha in the tests for my Rails app, and I''ve
run across an issue with mocking a method that should be called with
different parameters.
How would I setup a mock that expects that a method will be called
once with no paramaters, and a second time with a parameter? I''d be
tempted to shortcut and just do something like
2007 Nov 13
5
how to ensure signature compliance while mocking in ruby
On 13/11/2007, Pradeep Gatram <pradeep.gatram at gmail.com> wrote:
>
> Let me put my dilemma as an example. Take a look at a snippet from
> FooTest.
>
> #using mocha
> def test_method1
> Bar.expects(:method2).with(''param1'', ''param2'').once
> Foo.method1
> end
>
> And now the implementation
>
> class Foo
> def
2007 Aug 21
7
mocking singletons
How can I safely mock a singleton without the mocked method living on
outside the scope of the test method?
I''ve run into this problem with mocking methods on globals (gasp!) in
the past by doing something like
def mock_my_global
original = $my_global
$my_global.expects(:foo).returns(''bar'')
yield
$my_global = original
end
Is there something similar I
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 Sep 06
1
any reason we can''t use the concise stubs on Object
I like the concise version of stubs available on true mocks:
=> #<Mock:0x32f76d4>
>> foo.stubs(:one => ''hi'', :two => ''again'')
=> {:one=>"hi", :two=>"again"}
Why can''t we do it on ''real'' objects?
>> foo = Object.new
>> foo.stubs(:method1 => ''a'',
2007 Sep 11
1
Fwd: [ mocha-Feature Requests-13763 ] add with_any_arguments method
---------- Forwarded message ----------
From: noreply at rubyforge.org <noreply at rubyforge.org>
Date: 7 Sep 2007 22:43
Subject: [ mocha-Feature Requests-13763 ] add with_any_arguments method
To: noreply at rubyforge.org
Feature Requests item #13763, was opened at 2007-09-07 17:43
You can respond by visiting:
2008 Jan 02
2
Proxies
I really like the idea of Mock Proxies as explained in Brian Takita''s post here:
http://pivots.pivotallabs.com/users/brian/blog/articles/352-introducing-rr
I posted to this list eariler with an incomplete implementation of
.stops_mocking in the thread "Mocking Time, delegating to original
object." The Mock Proxy pattern would make this simpler.
2007 Dec 21
5
Mocha and rails 2.0.2?
Folks-
With Rails 2.0.2, I''m seeing mocha failures where they did not fail
with Rails 2.0.1
test_set_to_process_fail_in_transaction(FileRecordTest):
NoMethodError: undefined method `ord'' for 63:Fixnum
/home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/class_method.rb:45:in
`hidden_method''
2007 Mar 23
2
Mocha 0.4.0 Hates My App
Hi all -
I''ve recently made the leap from FlexMock to Mocha for mocks within
my app. Today I decided to upgrade from Mocha 0.3.2 to Mocha 0.4.0.
So I updated the gem, started rake and went to get some coffee. I
came back 5 mins later and my units (which were clean) are now
reporting 97 failures (!!!). Every failure reports a callstack like
this:
18) Error:
2006 Sep 03
2
Fwd: Dealing with exec?
---------- Forwarded message ----------
From: Kevin Clark <kevin.clark at gmail.com>
Date: 01-Sep-2006 20:31
Subject: Dealing with exec?
To: James Mead <jamesmead44 at gmail.com>
Hey James,
Sorry to bug you. I was curious how you''d handle a call to exec in a
method you were testing. Kernel.stubs(:exec)... doesn''t seem to work
but I''m not sure where else an
2007 Aug 29
5
Undefined method stub
When I try to execute the following example, I get an error message:
/usr/local/lib/ruby/gems/1.8/gems/mocha-0.5.4/lib/mocha/object.rb:40:
in `expects'': undefined method `stub'' for nil:NilClass (NoMethodError)
from test8.rb:5
What could be the reason? I tried with the latest Mocha Ruby gem, and I
also tried it with the Rails plugin.
The example:
require
2006 Sep 11
4
Using rspec and mocha
I prefer to use rspec than test::unit for developing my apps. However
I''ve found its mocking library to be pretty inflexible compared to
Mocha. This isn''t really a surprise since rspec isn''t intended as a
mocking framework, whereas Mocha is. So I''d like to play to both of
their strengths and use rspec as my testing/specification framework
and Mocha do to
2006 Dec 15
0
Fwd: Re: Re: [HOWTO] Edgemocha
---------- Forwarded message ----------
From: James Mead <jamesmead44 at gmail.com>
Date: 15-Dec-2006 17:37
Subject: Re: Re: [HOWTO] Edgemocha
To: John Pywtorak <jpywtora at calpoly.edu>
On 15/12/06, John Pywtorak <jpywtora at calpoly.edu> wrote:
> Compare
> ~$ sudo gem install mocha
> Attempting local installation of ''mocha''
> Successfully
2008 Jun 12
2
Anyone using trunk?
Has anybody been using Mocha trunk over the last month or two?
I''ve done quite a bit of internal refactoring and wondered whether
anyone had any problems.
There are also a bunch of new features e.g. states, sequences, extra
parameter matchers & configurable warnings, but these are not
documented in the on-line rdoc.
I wondered if anyone has been looking at the rdoc in trunk and
2007 Jul 30
6
Object.stubs doesn''t seem to work.
Hi
I''m using Mocha 0.5.3 and I want to stub out a call to Time.now, just
like the example in the post
http://blog.floehopper.org/articles/2007/06/08/mocha-0-5-released
However, trying it in irb gets me the following error:
>> require ''mocha''
=> true
>> Time.stubs(:now).returns(Time.parse(''Thu Feb 01 00:00:00 UTC 2007''))
NoMethodError:
2007 Mar 05
4
When to stub/when to mock (was Rails functional testing and Mocha)
Hi James,
> From: James Mead <jamesmead44 at gmail.com>
> Date: Mar 5, 2007 5:15 AM
> Subject: Re: [mocha-developer] Rails functional testing and Mocha
> To: mocha-developer at rubyforge.org
> "I''d probably stub the call to find not expect it, because its a query not a command"
I have a different perspective on when to use stubs and when to use
mocks and
2006 Dec 21
4
Stubbing Kernel#open
Anyone know how to stub Kernel#open? I''m trying to mock/stub an
open-uri call, but it doesn''t seem to like it.
Here''s the test code, and the failures:
body = File.open(File.dirname(__FILE__) +
''/../fixtures/google_search_california.html'').read
2007 Apr 12
15
Preview of Latest Mocha Changes
I''ve finally managed to find some time to do some serious work on
Mocha. There are some code snippets on my blog
(http://blog.floehopper.org/articles/2007/04/12/preview-of-latest-mocha-changes)
showing the new functionality available in trunk (revision 128). I
don''t don''t know how many people out there are using trunk, but it
would be great to get some feedback on these