Displaying 20 results from an estimated 800 matches similar to: "Mocking protected/private methods"
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
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!
2008 Feb 01
3
auth default : passwd-file Can't open file: Permission denied
Hello,
I'm attempting to migrate from an existing dovecot .99 install to dovecot
1.0.rc15 on a fresh up to date CentOs 5.1. I'm not sure what's causing this
permissions error on startup - I've tried 777,644, and 600 chmods but it's
always this same error:
Feb 1 12:43:05 ns2 dovecot: Dovecot v1.0.rc15 starting up
Feb 1 12:43:06 ns2 dovecot: Auth process died too early -
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 Sep 11
3
Expectations on portions of arguments called.
I''d like to create expectations on just portions of the arguments a
function takes.
For example, I want to verify that the a certain ActiveRecord
association extension adds an order clause to the find options hash.
Currently I simply check the entire argument structure, something like this
def test_referring_journals_should_order_by_citation_count
article =
2007 Aug 22
1
mock framework ethics question
Hi James, Jim, and everyone else who''s listening.
I''ve been investigating an interesting bug related to mocks and rails
AssociationProxies. See
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=12547&group_id=797
for details.
The crux is that if you do this (rspec mock syntax):
obj.should_receive(:msg).with(mock_of_a_model)
and the implementation does
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
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
2007 Sep 06
5
Removing/overriding/unstubbing a stub?
We''re using Mocha stubs to stub out a slow-performing network request in
a Test::Unit class. But naturally, we don''t want to stub it out in the
few tests that actually verify the functionality of that network request.
Is there a way to do the stub in "setup", but override it for the few
tests that need the original functionality?
(I realize that in this case, the
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
2008 Jun 12
2
Anyone using trunk?
Has anybody been using Mocha trunk over the last month or two?
I''ve done quite a bit of internal refactoring and wondered whether
anyone had any problems.
There are also a bunch of new features e.g. states, sequences, extra
parameter matchers & configurable warnings, but these are not
documented in the on-line rdoc.
I wondered if anyone has been looking at the rdoc in trunk and
2007 Oct 25
4
Insure a method is called with no arguments.
We''ve been working with the ParameterMatchers (so cool!) but I don''t
see a way to insure a method is called with no arguments.
I imagined something like:
user = mock(''User'')
user.expects(:friends).with(nothing)
Anyone run into this?
2003 Sep 03
0
Printers not visible in "Add Printer Wizard"
Hello,
I have a problem with samba-3xx (All beta and rc versions) concerning
the visibility in the "Add Printer Wizard" on windows clients.
Printing works fine but that's not the problem, the problem is the
visibilty of the printers defined in smb.conf in the "Add Printer Wizard".
Steps:
Start -> Settings -> Printers ->
"Double Click Add Printer"
Screen
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 Jan 30
2
Testing a call to super
Did any further discussion ever come of this? I take it is officially
not supported currently? I just get an odd error when I try it (it
throws a "0 expected 1 received", no matter what stubbing/expectation
combo I use), so came looking around on google, and finally the
mailinglist.
Here''s my stripped down example: http://pastie.caboo.se/145603 (it
fails with expects too)
2007 May 27
2
Mocking Requests
Hi Guys!
I just joined this list after James helped me out in ruby-talk to
mock a http get request for a project I have running :)
Now comes the second question...
I was fiddling around, making the mocking with the get request work
(which turned out to me pretty easy), but then I ran into another
problem. I was faced with mocking the post request, so I thought I
could do it the same way
2007 Dec 21
5
Mocha and rails 2.0.2?
Folks-
With Rails 2.0.2, I''m seeing mocha failures where they did not fail
with Rails 2.0.1
test_set_to_process_fail_in_transaction(FileRecordTest):
NoMethodError: undefined method `ord'' for 63:Fixnum
/home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/class_method.rb:45:in
`hidden_method''
2007 Aug 21
7
mocking singletons
How can I safely mock a singleton without the mocked method living on
outside the scope of the test method?
I''ve run into this problem with mocking methods on globals (gasp!) in
the past by doing something like
def mock_my_global
original = $my_global
$my_global.expects(:foo).returns(''bar'')
yield
$my_global = original
end
Is there something similar I
2007 Mar 18
5
Automatically mocking ActiveRecord methods
Seems like I do a fair amount of mocking ActiveRecord''s automatically
generated routines when I''m testing controllers. Things like:
@portalspace = PortalSpace.new :public_readable => true,
:public_writable => true, :name => ''public''
@portalspace.stubs(:id).returns(203)
PortalSpace.stubs(:find).with(203).returns(@portalspace)
2008 Jan 02
2
Proxies
I really like the idea of Mock Proxies as explained in Brian Takita''s post here:
http://pivots.pivotallabs.com/users/brian/blog/articles/352-introducing-rr
I posted to this list eariler with an incomplete implementation of
.stops_mocking in the thread "Mocking Time, delegating to original
object." The Mock Proxy pattern would make this simpler.