search for: expected_method

Displaying 5 results from an estimated 5 matches for "expected_method".

2006 Sep 22
2
foo.expects(:blah).returns(10).then(11) syntax
...========================================= --- test/mocha/expectation_test.rb (revision 854) +++ test/mocha/expectation_test.rb (working copy) @@ -95,6 +95,12 @@ assert_equal 99, expectation.invoke end + def test_should_return_values_in_order + expectation = Expectation.new(:expected_method).returns(9).then(10) + assert_equal 9, expectation.invoke + assert_equal 10, expectation.invoke + end + def test_should_return_nil_if_no_value_specified expectation = Expectation.new(:expected_method) assert_nil expectation.invoke Index: lib/mocha/expectation.rb =============...
2007 Sep 24
7
Parameter Matchers with optional params
Hi, Are there any docs for combining parameter matchers, or some way to define optional parameters? I''m trying to match something like: .find( 42 ) || .find( 42, {:conditions=>nil,:includes=>nil} ) Or for that matter, 42 followed by nothing or anything... Halp? I''ve tried different nested combos with any_of/all_of/anything, but getting lost trying. --Andrew
2006 Oct 08
9
Organizing tests and mocha expectations
I''m simultaneously getting into using Mocha and RSpec-style tests (courtesy of the simply_bdd plugin) and I''m struggling with some issues while trying to organize my specs/test. Here''s a code example illustrating the problem: context "update cliient invalid data" do include ClientsControllerSpecHelper specify "should render edit form" do
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 Mar 12
10
using mocha with rspec
Hi folks. I''ve just started using rspec and I have to say it''s very nice. The thing is, I prefer mocha''s mocking dialect. So I thought a simple require ''mocha'' would set me up. Unfortunately, rspec does all its goodness using do/end blocks in anonymous classes, so it wasn''t quite that obvious. Anyway, here is the incantation I ended up