search for: jmock

Displaying 20 results from an estimated 34 matches for "jmock".

Did you mean: mock
2008 Jan 20
2
Bug #17118 - expectations should take precedence over stubs
...ly. 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). > > The idea of this change was to bring Mocha into line with jMock v1 [1] so > that it stops matching expectations when the maximum number of expected > invocations is reached. You are suffering from "gotcha" number 2 in that > jMock reference: "if you create a stub and then an expectation for the same > method, the expectation will matc...
2007 Feb 05
10
how does Mocha compare in terms of classical vs mock-based testing, and stubbing???
Hi guys, I''ve just been reading Martin Fowler''s article re mock versus stubbing<http://martinfowler.com/articles/mocksArentStubs.html>where he compares traditional TDD testing techniques with mock based testing. I''d be interested in comments from a ruby on rails perspective in terms of this and Mocha? For example: a) Do you see Mocha as a robust way to test Ruby
2007 Feb 28
12
Specifying that code is called in a block
Not sure if this is possible currently. I have a section of code like this: ActiveRecord::Base.transaction do cow.save! duck.save! dog.save! end (Names changed to protect the innocent.) I''d like to specify that the saves run in a transaction. I can do ActiveRecord::Base.should_receive(:transaction).and_yield But is there any way to specify that the code is
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
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
2007 Jul 09
2
Problem with Mocks: "random" tests failing
Hi all! I am pretty new to Mocha and I am writing tests that use Mocks quite a bit. I am having a weird behavior with some of the tests for a specific class: I wrote a first couple of tests that were passing and then when adding a 3rd one, the first tests begun to fail. Now what''s bugging me even more is that if I run them in debugger mode with breakpoints on the functions where the
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
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
2008 Jan 02
2
Proxies
...know that since revision 193 (which is included in gem 0.5.6), the > initializer block syntax has been available. Unfortunately the rdoc > didn''t get updated until revision 221 (which hasn''t yet been > released). > > Since your email, I''ve added support for JMock2 style sequences [1] > and states [2] which allow you to constrain the order of invocation. I > haven''t yet sorted out the error reporting and there may be some > teething problems, but feel free to give it a try. All the rdoc has > been updated in trunk. See AutoVerify#sequenc...
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 02
0
Mocha
...ow would surely not work with expects(). Many thanks for the patch. It''s been something on the todo list for quite a while. But you''ll be pleased to hear I''ve just applied it (revision 75). I''m happy with your supplied solution - it achieves the same effect as JMock''s LIFOInvocationDispatcher. -- James. http://blog.floehopper.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20070102/617dd19d/attachment-0001.html
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
2008 Jan 11
2
guide to good mocking?
Hi all - does anyone know of a good blog post or wiki or something with a good guide to mocking? I''ve got some degree of responsibility for people who are creating mocks. I''m supposed to actually be telling them the best way to do it. In some cases we have code with like a bazillion mock(:x) statements and it''s kind of out of control. I have an idea how the specs should
2007 Apr 17
8
problem with rspec_on_rails and @controller.should_receive(:render) in trunk
Hey guys! I am using rspec trunk, and I am having a little problem with the latest version. (I am quite sure this worked with an older version about a week ago) heres the spec: it "should render the new user form without layout for a xhr request" do @controller.should_receive(:render).with(:layout=>false) xhr :get,:new end and the controller: def new render
2007 Sep 05
2
how to test timeouts? that #returns deprecation again...
I''m writing quite a few specs lately that use Ruby''s Timeout::timeout functionality, making sure that timeout errors are properly handled and everything flows right when some command line tools timeout. I like being able to use Mocha''s #returns right now to force a method to raise a TimeoutError, but I know that usage is going away at some point. I''d like to
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
2007 Mar 06
15
mocking missing methods
...the type responds to the method (or if it implements method_missing). If neither of these is the case, it blows up like a regular sheep with a NoMethodError, rather than doing the expectation stuff. The reason for deferring the failure until the method is invoked rather than failing fast like JMock does when the expectation is defined, is in case the method gets defined, or the Sheep class gets extended, between the mock being defined and the method being invoked. Again, you would only get this behaviour if you created a typed mock, using sheep = mock(Sheep) rather than sheep = mock(). W...
2007 Feb 22
7
We can''t 100% remove our unit tests from the database, can we?
I hope this isn''t too rambly. This is sort of a brain dump of a subject I''ve been thinking about for months as I''ve used RSpec. Let''s say we''ve got a simple query method, that will find all the users in the DB older than 18. Our model could look like class User < ActiveRecord::Base def self.find_older_than(age) find :all, :conditions =>
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
2008 May 10
4
Newbie: lambda do...end.should change(Model, :count).by(1). Doesn''t work
Hi to everyone, I''m an RSpec, and BDD in general, newbie so in order to learn I have chosen to use my personal website as a tesbed. I''m having difficulties juggling with mocks, and in particula with the following code. Here''s the controller action: def create @album = Album.new(params[:album]) if @album.save flash[:notice] = "album saved"