Displaying 20 results from an estimated 2000 matches similar to: "Fwd: Dealing with exec?"
2007 Jan 17
8
Mocha Mock''s hanging on after test run?
Hi guys,
I''m running mocha (0.3.2) against Rails core and just found an issue
where the mock doesn''t go away after the test is run.
For example:
def test_reset_bang_doesn_reinstall_named_routes
ActionController::Routing::Routes.named_routes.expects(:install).never
@session.reset!
end
def test_zzz
puts ActionController::Routing::Routes.named_routes.inspect
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
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
2006 Sep 03
1
Slimmed down version for inclusion in Rails?
I''m pushing a major overhaul in testing the Rails codebase. Mocha and
stubba make my life easy so that''s what I''m using. The first major
patch using them is in RailTies
(http://dev.rubyonrails.org/ticket/5970) now. I spoke to DHH today
about using it in the other libraries and I think it''ll be ok, but
they really want to include as little code as needed. I
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
2007 Jun 19
4
Changing the value of $?
Hi :)
Does anyone know of a way to set the value of $? ?
I have a test which stubs ` ; the call works fine, but then the library
I am testing checks the value of $? to see if the process terminated
correctly.
It seems not to be possible to assign $? directly...
For now I do this before my test :
`ls > /dev/null`
Which ensure that $? is zero ; but this is not a very nice way of doing
it !
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)
2006 Oct 25
5
Mocha, Stubba and RSpec
Hi,
I''ve been reading with interest the threads trying to integrate Mocha
and Stubba with RSpec. So far, I''ve made the two changes in
spec_helper.rb suggested, but discovered another one that neither of
the archives mentions:
If you use traditional mocking: object = mock or the stub shortcut
: object = stub(:method => :result), you run into namespace conflicts
with
2006 Sep 13
2
Problem with RSpec and Mocha/Stubba
I''ve recently upgraded to the latest versions of Mocha and RSpec
(0.3.2 and 0.6.3 respectively) and I''m no longer able to use Mocha/
Stubba with RSpec. Its actually only Stubba I''m interested in as I
use RSpec''s built-in mocking library.
I require stubba in my spec file but whenever I try and run my spec
it fails with the error:
Unintialized constant
2006 Nov 21
5
stubbing in development environment
Hi guys.
Quite happy with mocha for testing. It''s been a bit of an eye opener
for me, and I expect to begin using it heavily.
One other thing I''d like to do is stub out particular class methods in
development. Is there a way I can do this with mocha?
Jason
2006 Sep 03
1
Returning different values with stubs
Right now I''m working on adding tests to a method that looks like this:
def get_via_redirect(path, args={})
get path, args
follow_redirect! while redirect?
status
end
So, I want to confirm that get is called and that status is returned
but I also want to see that when the value of redirect? effects how
many times follow_redirect is called. Is there
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
2006 Aug 14
14
A mock which extends rather than replaces a class?
While running tests, we would like to instrument some of the classes
under test. We still want the classes to do exactly what they currently
do, but we would like them to do more when running in the test
environment.
Clearly we can (and currently do) just extend the objects "on the fly"
where necessary, but this is a bit messy - we''d like some centralised
way to always
2008 Jun 12
2
Google Group?
A number of people have had difficulties subscribing and/or sending
messages to the existing mailing list.
Also I have to spend quite a bit of time moderating spam and the
mailman interface is pretty clunky.
So I was contemplating setting a Google Group up instead. Does anyone
have any objections?
--
James.
http://blog.floehopper.org
http://tumble.floehopper.org
2007 Sep 21
5
Stubbing yielding methods
I''ve just been tying my brain in knots looking at bug #8687 (
http://rubyforge.org/tracker/index.php?func=detail&aid=8687&group_id=1917&atid=7477
).
I''ve been (1) trying to work out whether there is anything logically wrong
with Mocha''s existing behaviour and (2) whether Mocha should support the
requested functionality.
It all centres around the use of the
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 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
2008 Jan 28
9
Nested matchers
We''re encountering a failure with Mocha 0.5.6.
We had this expectation:
game_version.expects(:attributes=).with(:game_file =>
kind_of(GameFile), :game_id => @game.id)
This expectation was passing with 0.5.5, but fails with 0.5.6.
I added this test to parameter_matcher_acceptance_test.rb, which
passes in 0.5.5 and fails in 0.5.6
def test_should_match_nested_parameters
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