Displaying 20 results from an estimated 3000 matches similar to: "With Parameter Block"
2007 Jul 26
5
Test errors without verification
I''m not sure if this is by design, but I''ve stumbled across this a
few times trying to debug my own tests. If an assertion fails the
test, and a mock expectation was to blame, the test''s failure / error
messages don''t give enough info. I''ve had to resort to
def teardown
mocha_verify
end
which just gets tedious.
I''ve created a patch
2007 Oct 20
14
Problems with form_for and partials
i''m having problem with a form_for situation where i''m trying to DRY
out the repeated parts of my forms and put them in common/form and
render the form elements via another partial in controller_name/_form.
Here''s the first form
# app/views/common/form
<% form_for ... do |f| -%>
<%= render :partial => "params[:controller]/form", :object => f
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 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
2008 May 20
7
Expect with "real world" returns?
Is there a way to do something like this?
class Foo
def self.hello(name)
"Hello #{name}!"
end
end
Foo.expects(:bar).with("Carl").once
assert_equal "Hello Carl!", Foo.hello
Basically, my problem is that once you set an expectation, the
original code is never executed and is not tested. However, it''s
still very useful to set expectations to
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 Sep 05
4
Mocking to spec a sort_by method
Hello,
I have a question regarding the use of Mocha with rSpec to spec one of
my methods.
My spec contains the following
vehical1 = mock()
vehical2 = mock()
vehical1.stubs(:mph).returns(150)
vehical2.stubs(:mph).returns(250)
comparer.add_vehical([@vehical1, @vehical2])
comparer.sort_by(:mph)
The comparer is an object that has a basic "stack like" functionality,
add_vehical is the
2007 Jun 21
3
only checking certain parameters for a method
I''m writing a test where I only care about one of the parameters being sent
to the method, does anyone think having a way to say that any value for a
parameter which I don''t care about is valid? I''m thinking something like:
def test_charge_is_for_10_bucks
gateway = test_gateway
member = Member.new
member.credit_card_number = "1"
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan
is to deprecate the mocking framework." I hadn''t heard anything about
that, but then again I haven''t paid super close attention to the list.
Are we planning on dumping the mock framework in favor of using Mocha
(or any other framework one might want to plug in?).
Pat
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
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?
2009 Mar 15
7
How to use different mocking frameworks?
Hi,
I''m pretty new to Rspec, so hope someone can help me out with this.
I''m leveraging a couple pre-existing applications in my current
project, both have fairly robust test suites in Rspec already.
However, one is using Rspec''s builit in mocking, and the other is
using mocha.
If I set config.mock_with mocha in spec_helper.rb, then all of the
rspec mocks fail. If I
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
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
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 Apr 11
4
Feature request... I think...
Folks-
I just started using Mocha and I wanted to try something but I
couldn''t get it to work. I''m coming from the Java world, so my
approach may not be optimal for Ruby.
Say I''m testing a.do_something() which calls b.do_other_thing() twice,
but I really don''t want to change b.do_other_thing(), just ''expect'' it
to be called twice. I know I
2011 Jul 09
1
[LLVMdev] getting and setting array indices c interface
I really can't figure out how to get and set array indices from the c
interface.
so to get an element I'm calling
tindex = *fn\SymbolTable(*index\name)
index = LLVMBuildLoad(builder,tindex,"index")
arr = *fn\SymbolTable(*array\name)
arrptr = LLVMBuildLoad(Builder,arr,"arrayptr")
tmp = LLVMBuildGEP(Builder,arrptr,index,0,"ptr")
ptr =
2007 Aug 14
4
Stubbing all methods
Mocha''s mock/stub framework has the ability to stub all methods on a
mock given. Does RSpec''s mocking framework have this ability? And
if not, is there some reason it shouldn''t be implemeneted?
Regards,
Scott
2007 May 23
2
rspec mocha and controller specs without integrated_views
The ability to choose a mocking framework is great as I prefer mocha, but I
am have problems.
On my controller specs, I am forced to ''integrate_views'' as the following
code below shows you, the mocking of views is rspec specific. See stub!
versus mocha''s stub
unless block_given?
unless integrate_views?