similar to: Anyone help with using Mocks inside plugins?

Displaying 20 results from an estimated 100000 matches similar to: "Anyone help with using Mocks inside plugins?"

2008 Sep 30
0
Help me with this test/mocks issue please!
I have a class called X that writes to disk. For this reason, the class is hard to test. If it wrote to a hash instead, I could test it. So I made a new class called X in test/mocks. In that class, I overrode the methods that wrote to disk. But I didn''t want to copy ALL the methods from the real X into the mock X - only the ones that were being over-ridden. My idea was to subclass
2007 Oct 08
0
Using mocks in classes
I am mocking a rails model that hasn''t been implemented and belongs_to a model that I am developing with rspec. The model in development, Audit, has_many AuditItems which is being mocked. When created, Audit creates the first instance of AuditItem. To enable me to mock AuditItem I have created a factory method in Audit to create the AuditItem, rather than creating it in the initialize
2007 Jun 01
0
rspec_on_rails, could someone provide an example of using mocks/stubs?
hi all I''m still a little uncertain on how to use mocks/stubs with rspec when dealing with associations. I know the point is to isolate the code being tested and remove external dependencies, but I''m not sure how to implement it. Can someone suggest how they would spec the code below: I have a Book model and Review model class Book < ActiveRecord::Base has_many :reviews
2007 Jan 30
0
nil object in mocks
RSpecrs, I''ve been running into some trouble lately when passing mock objects into rich views. Either I have to obscure my specs by stubbing every method the view would call on my object, or I have to resort to trickery like stubbing ActionController#render, which is also less than ideal. The solution I''ve some up with is a variant on the :null_object option that can be passed
2007 May 30
4
Using mocks
I''ve just started doing TDD/BDD and like the idea of mocks. So I set out to use them. The doc pages seem great, I setup the mock and then it just works. Here is what I am trying to do: Myuser is a non-rails model of user attributes. We are going to be mocking the connection to the ldap server. The user class has a login method that connects to the ldap server and if successful,
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:
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)
2007 Dec 09
2
Mocks and Manual Tests
Is it possible for me to use Mock objects in manual testing? They work great for functional testing, but now I need to load the pages and play around with some stuff, but of course I cant load them because there are a number of classes without implementations, which I want to just mock out. Any ideas? ----------------------------------------------------------------- Find the home of your dreams
2006 Jun 14
9
Controller testing and mocks...
So far I''ve been doing my controller testing against "real" (testing) objects; however, I''ve been beginning to wonder if I should "default" to using mocks in most cases -- both for performence and to enforce a looser coupling. In part this is driven by my viewpoint that rail''s "functional" tests are still "unit" tests, so they
2007 Feb 17
1
"warning: object#id will be deprecated" with mocks
hi all I have the following code in a spec: @user = mock("user") User.stub!(:authenticate).and_return(@user) @user.should_receive(:id).once.and_return(99) post :login, {:username => ''username'', :password => ''password''} session[:user_id].should == 99 it works as expected but I get the following warning when I run the spec: warning:
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec. I can''t seem to tell rSpec to expect the call @item.user. The following error message plagues me not matter how I try to fuss with the mock: Spec::Mocks::MockExpectationError in ''ItemsController handling POST / items should redirect to the new course on successful save'' Mock
2006 Sep 01
3
Anyone seeing mock breakage after updating to 4.4?
Morning, somehow the upgrade to 4.4 broke mock on my system: | [angenenr at shutdown SPECS]$mock -r c3-i386 /home/angenenr/redhat/SRPMS/apache-ssl-2.8.28-2el4.src.rpm | init | clean | prep | This may take a while | Could not find useradd in chroot, maybe the install failed? Nope, it's not the config_opts['chroot_setup_cmd'] = 'groupinstall build' issue, as I'm still
2006 Jan 21
2
Documentation for mocks?
Is there any documentation about how mock objects work in RoR, specifically exactly how one should use the test/mocks directory. Is it just me being incompetent searching for it, or hasn''t this been documented yet? Thanks in advance for your help! paul.butcher->msgCount++ Snetterton, Castle Combe, Cadwell Park... Who says I have a one track mind? -- Posted via
2005 Dec 27
4
Using mocks
Hi, What's the purpose of test/mocks? I couldn't quite complete the Wiki entry on this because all the information I _could_ find was in the readme. - Rowan -- Morality is usually taught by the immoral. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
2008 Jun 02
1
Cherry-picking mocks?!
A colleague just came in and asked me about a problem he was having with stub_render, which reminded me of another issue he had a week or so ago, which seems related. Let me start with the earlier issue. He was trying to write specs for a method which sends the same message possibly multiple times, but with different arguments under different calling conditions. He wanted to write
2007 Aug 28
3
How do you keep mocks updated without pain?
Hi! I know you must be answering a lot of basic questions, sorry about that :-) However I have not get it, how do you keep mocks updated without pain? I reached to the point where mocking things for view. I spec model-controller-view using "correct doc" way mocking-stubbing (plus I should run integration test to be sure that everything really works together). Now, when I want to
2007 Jan 08
2
thoughts on mocks and specs
I spent the last couple of days getting my sea legs with Rails and RSpec. I''d been waiting til things seemed calmer before jumping in, and I''m overall very happy with my experience so far. My only real annoyance so far has been forgetting to call "do_post" or "do_create" from my specify blocks. My mocks don''t get the calls they want, and it usually
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 Jun 12
1
Does anyone know how to mock the Rails Logger then set expectations with should_receive?
Hey Guys, I''m trying to mock the Rails Logger for the following code: ... rescue TimeoutError => error $logger.error("#{self.name} Timeout for #{path}: #{error}") and return rescue SocketError => error $logger.error("#{self.name} SocketError for #{path}: #{error}") and return rescue StandardError => error
2007 Mar 13
1
Opening the singleton class of mocked objects
I wrote a plugin [1] a while ago that lets me do validations on a single AR instance. Instead of defining validations in an AR class, I can define them on a AR instance''s singleton class: class << @video validates_presence_of :title end One of my specs mocks Video.find, and the above code is run on the mock object. When I run the spec, I get the expected undefined method