similar to: Returning different values with stubs

Displaying 20 results from an estimated 1000 matches similar to: "Returning different values with stubs"

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
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 Nov 28
2
follow_redirect!() doesn't exist?
Hi all I want to do some functional testing. I stumbled over the method follow_redirect!() somewhere, but evidently this doesn''t seem to exist in my Rails version (1.2.5 or so)?! Then I tried follow_redirect() (without the exclamation mark), and I get the following error: TypeError: can''t convert Symbol into String What am I doing wrong? Thanks for help :-) Josh -- Posted via
2006 Apr 04
1
integration tests - 1.1
I?m using the new 1.1 integration test facility? I?m trying to write a test that sees if a controller redirects to the correct place and preserves the query string. Here?s the code: class LoginRedirectTest < ActionController::IntegrationTest def test_non_admin_auth request_uri = "/datafeed/event/report?blah=blah" get(request_uri) follow_redirect!
2007 Jul 25
3
autotest + integration testing (follow_redirect!) error
I''ve got an interesting (possibly) problem right now between autotest and rails integration tests. There are a few things to preface this with. Works fine: rake test rake test:integration Blows up: autotest Autotest is correctly determining rails and runs tests just fine. One part of the behavior is that if I save a change in just the integration test (even hitting cmd+s to trigger a
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 11
12
Mocking system/`
This drives me insane on a regular basis. How does one mock system(''blah'') or `blah` ? Adding expectations on Kernel doesn''t do it. Adding expectations on Object just makes me sad: Object.any_instance.expects(:system).with(''ls'') # => #<Mock:0x12b584e>.system(''ls'') - expected calls: 0, actual calls: 1 And this really
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
2005 Dec 23
6
Agile book - test error
Hi all, I get an error when testing the "store_controller_test.rb" The troublesome line is in the test below: def test_add_to_cart get :add_to_cart, :id => @version_control_book.id <<< cart = session[:cart] assert_equal @version_control_book.price, cart.total_price assert_redirected_to :action => ''display_cart'' follow_redirect
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 12
1
did something in revision 68 break stubs?
Hi, I''ve been a happy user of Mocha for a while now. My current project is by far the most complicated I''ve ever worked on and Mocha has made testing it much easier than it would otherwise be. So, I was highly disturbed to come in this morning, run svn up and find that something in today''s update broke lots of my tests. I use Mocha as a Rails plugin under
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:
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 21
4
stubs! method
Hello James et al. I try to set only one expectation per test, but I also dislike having extra stub declarations that are no longer used, thus I often find myself wanting Object.expects(:foo).at_least_once. That works, but I don''t actually "expect" foo to be called, in fact, I don''t care, I only want to know when it isn''t called so I can remember to
2008 Jun 02
2
Cannot log in/authenticate within RSpec Story
I''ve been slamming my head against a wall for a while now, and would like some help. I believe this is session related. I have a story that looks like: -------------------------------------------------- Given that a post exists And I am logged in When I visit the post details page Then there should be a link to add a new comment
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 Apr 03
0
follow_redirect! aborts rake during integration tests
I''m running integration tests on Rails 1.1/Ruby 1.8.4/Windows XP and have found that any call to follow_redirect! (directly or through [get|post]_via_redirect) causes rake to abort (see command line output below). Has anyone else seen this error, or know what might be the trouble? Thanks! Tom C:\dev\h2h>rake test:integration --trace (in C:/dev/h2h) ** Invoke test:integration
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 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 Feb 08
1
flex mock?
Hi guys, Would you mind if I ask how Flex Mock and Mocha sit together? They compete directly? I read that Flex Mock was built into Rails 1.2. Is there a reason to use Mocha instead of Flex Mock? Tks Greg