search for: as_null_object

Displaying 5 results from an estimated 5 matches for "as_null_object".

2010 May 27
3
as_null_object
...t RSpec has the following methods to create test doubles ... double(:my_test_double) mock(:my_mock_object) stub(:my_stub) Is there a way to/ plans to introduce a similar syntax for null objects? null_object(:my_null_object) Instead of mock(:bar, :is_null_object => true) or mock(:foo).as_null_object I think this would be cleaner, what do you think?
2011 May 14
1
RSpec stub question
Hi I am using Mongoid. In Mongoid while saving a record we typically give like in the controller @post.safely.save For a model class Post I am writing rspecs for my controller and want to mock the model. So what I am doing is let(:post) { mock_model(Post).as_null_object } before(:each) do Post.stub(:new).and_return(post) end it "creates new post" Post.should_receive(:new).and_return(post) end #how do I stub safely.save also here and test whether it receives save call? Thanks Arun
2008 Sep 24
19
How to define request.domain in when testing
Hi, My application relies on request.domain for doing its job. The problem I am encountering, is that when running tests, request.domain returns "test.host", how can I change that so that it returns "mysite.com"? Thanks in advance. -- Posted via http://www.ruby-forum.com/.
2008 Nov 03
1
stub! and null_object
I have some code I want to stub out as it''s not part of what I''m testing. It''s got a bit of DSL going on, so there are method calls chained together. The call I want to stub out looks like this: user.record_action(:uploaded_a_photo => concert).with_result(photo) So ideally, I''d just do @user.stub!(:record_action) and that would return a null
2011 Jul 06
0
undefined method `assigns' and undefined method `post'
...hod `post'' for #<Spec::Example::ExampleGroup::Subclass_1:0xb7754114> undefined method `assigns'' for #<Spec::Example::ExampleGroup::Subclass_1:0xb785d1b4> Test file describe "GET Index" do def mock_product(stubs={}) @mock_user ||= mock_model(User, stubs).as_null_object end def setup @user = User.new end please give me some help .. thanks Yennie it "assigns all users as @users" do @user.stub(:all){[mock_user]} assigns(:users).should eq([mock_user]) end end -- You received this message because you are subscribed to the Go...