Displaying 6 results from an estimated 6 matches for "responds_like".
2007 Mar 06
15
mocking missing methods
Hi folks.
So I''m using mocha on a ruby project, and I really like it. One thing
I''ve noticed is that it can be a bit "surprising" when I''m mocking
methods that don''t exist on an object, and I think there''s an easyish fix.
At the moment, you use sheep = mock() to create a mock sheep. What I''d
like to do is something like sheep =
2007 Jun 15
0
Fwd: [ mocha-Patches-11583 ] Mocha 0.5.0 throwing unexpected warnings, one line patch included
...t; 151: warning: instance variable @responder not initialized
> /usr/local/lib/ruby/gems/1.8/gems/mocha-0.5.0/lib/mocha/mock.rb:
> 151: warning: instance variable @responder not initialized
>
> This seems to be related to the fact that I am not calling a new
> method in 0.5.0 Mock#responds_like in mock.rb in my tests. Since I
> never call this in my tests the @responder instance variable is
> never set and the method_missing call throws a warning since you
> are doing a test on an unset variable.
>
> Not sure if this is the perfect fix or not, but when I defined
&g...
2007 Nov 13
5
how to ensure signature compliance while mocking in ruby
...l the objects are wired
together correctly, but...
Mocha [1] used to only allow you to mock *existing* methods on *concrete*
classes. This functionality accidentally got removed a while ago, but I''d
like to reintroduce it asap.
You can already restrict expecations on *mocks* by using the responds_like
modifier [2], something like this...
class Foo
def bar
end
end
def test_me
foo = mock(''foo'')
foo.responds_like(Foo.new)
foo.expects(:not_bar)
foo.not_bar
end
# => NoMethodError: undefined method `not_bar'' for #<Mock:foo> which
responds like #<Fo...
2007 Oct 04
5
Specs and Libs
How would I go about writing specs for a lib, particularly one with
all protected and private methods. I''m trying to spec the
AuthenticatedSystem library from the rails restful_authentication
plugin:
http://pastie.caboo.se/103625
Also, when you''re mocking objects, a side-effect is helping you
define the api of the object. Is there a way to get all the
behaviors that
2007 Jul 16
4
RSpec - concerns about mocking
I''m getting into RSpec more after getting the awesome Peepcode
screencast about it. So far I love it, but coming form Test::Unit with
Rails, I have some concerns about the recommendation to mock models and
database calls in controller and view specs.
Lets say you have a method on your User model called
User.find_activated, and you have models specs for it. Then in your
controller specs
2007 May 02
4
Terse Mocks
Hello,
I recently made a feature request with a patch for terser mocks.
http://rubyforge.org/tracker/index.php?func=detail&aid=10412&group_id=1917&atid=7480
Here are some examples with their current equivalents:
the_mock.expects.foo(1,2) {|a, b| :bar}
the_mock.expects.foo(1,2).returns(:bar)
the_mock.expects(:foo).with(1,2) {|a, b| :bar}
the_mock.expects(:foo).with(1,2).returns(:bar)