Displaying 20 results from an estimated 1000 matches similar to: "Mixing mocking frameworks?"
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 Jan 31
1
RESTful Resources/ Caching Issue?
Hi,
I just ran into a bizarre problem when I put my site into production.
I have a resource (call it xxx), then I created with the generate
script.
I then set up page caching on the show action. But now in the
production environment, trying to call the edit action results in the
show page being retreived from the cache.
I''m assuming this has to do with the similarity of the URL
2007 May 07
6
mock frameworks
Just curious - now that rspec (as of 0.9) let''s you choose your mock
framework, how many of you are actually using (or planning to use)
mocha or flexmock?
Anybody planning to use any other mock framework besides rspec, mocha
or flexmock?
Thanks,
David
2008 May 22
14
Specifying certain tables NOT to be cleared each example?
Is it possible to specify that certain tables not be cleared on each
example.
I''ve inherited a project where a good amount of enumerated data is
stored in the database (US States, statuses, about 15-20 tables worth.
Over all, it''s a reasonable decision that leads to solid production
code (acts_as_enumerated is good). This data is read-only and
relatively static; any
2007 Aug 08
1
Mocking Time, delegating to original object
In my Unit tests, I run into the all-too-common problem of
Time.expects(:now) being called by Benchmark before the method is
unmocked.
Instead of messing around with the teardown order, I decided to modify
the Expectation with a new method, .stops_mocking.
Here are the changes I use, including a few monkey patches to push
relevant objects down to where I want them, all wrapped up in a big
ugly
2008 May 28
3
Mocking objects to test Rails Controllers
Hi all,
I''m currently considering the use of Mocha to aid in writing my Rails
unit/functional tests.
I currently have a Rails model which mixes in a series of methods to
allow it to talk to an external service. The code is roughly of this form:
class Person < ActiveRecord::Base
include SMSNotifier
def send_notification(message)
send_sms(number,message)
#
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 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 Oct 18
4
Mocking models provided in Rails plugins
Hey folks,
How do I mock a model that is given to me by a Rails plugin? I''m
trying to mock Session from the restful_authentication plugin but I
get a number of errors telling me RSpec doesn''t recognize Session.
NameError in ''SessionsController handling GET /sessions/new should be
successful''
uninitialized constant Session
An example of my usage:
2006 Oct 11
0
stubbing/mocking
All,
Inspired by a conversation on the mocha list, I added the ability to
mix stubs w/ mocks on the same methods.
Here''s what it allows:
context "a mock" do
specify "can stub! and mock the same message" do
mock = mock("stubbing mock")
mock.stub!(:msg).and_return(:stub_value)
mock.should_receive(:msg).with(:arg).and_return(:mock_value)
2008 May 10
1
Mocking protected/private methods
Hello all,
I have a question concerning mocha''s handling
of protected and private methods. When expecting
such a method, the method is public in the test.
I expected the method to keep its original visibilty.
Is this intended behaviour, or a bug?
Thanks for your help,
Tammo Freese
2007 Dec 07
0
weird behavior of mocking ruby class methods
Hello everyone:
After I played with Rspec for three months, I realized a weird behavior of
mocking ruby classes (e.g. File).
Please let me post a sample code before I point out the problems:
#file_reader.rb (to be tested)
class FileReader
def do_read
File.read(''asd.txt'')
end
end
#file_reader_spec.rb
describe FileReader, "do_read" do
it
2006 Oct 04
0
stubbing/partial mocking
All,
Brian Takita has been contributing to a stubs branch to support
stubbing and partial mocking on Modules (and therefore classes). I
tweaked the syntax a bit and merged it into the trunk, so you can
update from the trunk and check out the new stubbing/mocking love. If
you prefer to wait for a release, there should be one coming soon-ish
(I''m aiming for later this week).
As Brian
2007 Jan 08
0
mocking/stubbing ferret
Does anyone have an experience with mocking/stubbing ferret, in order
to increase speed? I''ve taken a look at what it might entail and from
what I''ve seen it would have to be a pretty elaborate system. But I
am not very experienced with mocking/stubbing.
Any tips much appreciated.
John
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
2010 Aug 29
0
Troll - A Rails plugin for making webservice mocking easier
Hi Folks,
Troll trumps your existing ActiveResource mocking libraries like
inbuilt HttpMock,Fakeweb or Webmock out of water. With Troll,
ActiveResource mocking just works, some of its features:
1. Don''t need to mock calls at Net::HTTP level (which webmock,fakeweb
do). Really, we don''t care what HTTP library ActiveResource uses,
fakeweb and webmock bring additional complexity
2007 Oct 25
1
Mocking/Stubbing help with subdomain as account key
My app uses account_location to set up subdomains as account keys. In
my controllers, all my model operations are scoped through the
@current_person object.
The question is: How do I test this with RSpec''s mocking and
stubbing? Basically, I need to test that @current_person.things is
getting the find message and returning @thing. I''ve tried stubbing
and mocking
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 Jan 24
0
Mocha 0.4 released
So I finally got round to releasing a new
version<http://rubyforge.org/frs/?group_id=1917&release_id=9184>of
Mocha <http://mocha.rubyforge.org/>. Much of the functionality has been
available for some time if you''ve been using the Rails plugin based on
subversion HEAD, but now you can get it in all in a gem (or other package).
The most recent changes centre around allowing
2007 Mar 27
2
mocking/stubbing newbie questions
I''m new to mocking and stubbing. Can someone help me out with the
following? I don''t exactly know why this spec is failing:
describe "GET /users/1/terms" do
controller_name :terms
setup do
@user = mock_model(User)
User.stub!(:find).and_return(@user)
end
def do_get
get :index, :user_id => 1
end
it "should find all terms