similar to: Mocking Requests

Displaying 20 results from an estimated 1000 matches similar to: "Mocking Requests"

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 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 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 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 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 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
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 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
2006 Oct 17
4
Mocking the rendering of a Rails template
Hello all, I''m having difficulty setting up mocks such that I can verify that Rails was going to render the right template file (for example new.rhtml) and stop Rails from performing the actual rendering. After peeking at Rails'' internals, I tried two techniques as illustrated here: http://pastie.caboo.se/18197 Neither worked. I think the first one failed because Rails
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
2008 Jun 01
0
Mixing mocking frameworks?
First, it was great meeting a bunch of you at RailsConf. Recently I''ve run into a problem using RSpec, namely its support for multiple mocking frameworks. Wait you say, isn''t that a good thing? Yes, it is until you end up mixing frameworks. I was writing my latest app, and I choose to get the app working and then add in the authentication system. So I went and wrote all
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
2007 Feb 05
2
Mock objects for stubbing out Paypal - anyone have any???
Hi, Just wondering if anyone has already developed a mocking approach to stub out the Paypal interface so that one can test on an internal PC which doesn''t provide a means for PayPal to callback to your webserver? (i.e. once the app is deployed to the hosting provider it would then work as PayPal could then hit the application with the specified URL). Anyone already solved this? What
2007 Feb 05
1
Mock objects for stubbing out Paypal - anyone have any???
Hi, Just wondering if anyone has already developed a mocking approach to stub out the Paypal interface so that one can test on an internal PC which doesn''t provide a means for PayPal to callback to your webserver? (i.e. once the app is deployed to the hosting provider it would then work as PayPal could then hit the application with the specified URL). Anyone already solved this? Would
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 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
2007 Apr 06
3
Mocking Authentication
Is anyone using Restful Authentication? If so, how are you mocking the login for your controllers? I''m having trouble with it and would love an example of someone''s login. I''m sure I''m missing something simple. Michael railsconsulting.com
2007 Jul 24
2
Mocking Resolv::DNS?
Hello Rspecers, I have a rails project where I am calling Resolv::DNS.open and then using the block to check a domain name. The code snippet in question is: domain = "mytest.com" Resolv::DNS.open do |dns| @mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) end I obviously want to stub this out, especially for speed but can''t quite work out how. I