Displaying 18 results from an estimated 18 matches for "null_objects".
Did you mean:
null_object
2007 Dec 05
9
Does mock_model''s :null_object option work?
Please understand in the following that I am making relatively minor changes to legacy (non-TDD/BDD) code in Substruct and don''t have the time to refactor nicely right now. I''m just trying to get past the untested/un-speced cruft quickly to write the spec for my new code, so I''m looking for expediency over prettiness.
I''m specifying
before( :each ) do
2010 May 27
3
as_null_object
Given that 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?
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
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
2006 Jul 24
6
Mocking causes empty specification blocks
I''ve found myself mocking out a published api in my set-up method.
This has led to some contexts having a large set-up and empty
specifications. As the mocks get auto-verified, the specification
blocks have nothing to do but serve as documentation. Does this sound
bad?
Chris
2008 Jun 04
2
Mock with an attributes that has state
I''m developing a rails application. I have an Order model that has_many
OrderItems.
I mocked the OrderItem model in my Order specs using mock_model. I thought
I should focus my specs on each model and always mock associated models.
In my Order model I need a way to merge OrderItems which have the same cost
and same product_id. That I can spec.
The other thing this merge helper
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
2008 May 26
7
Mocking Models in Controller Specs...
I find myself doing this kind of thing a lot in Controller Specs:
@vacancy = mock_model(Vacancy)
@vacancy.stub!(:reference)
@vacancy.stub!(:title)
@vacancy.stub!(:created_at)
@vacancy.stub!(:updated_at)
@vacancy.stub!(:body)
@vacancy.stub!(:contract)
@vacancy.stub!(:location)
@vacancy.stub!(:salary)
@vacancy.stub!(:benefits)
2008 Jul 25
21
Problems with mock assigned to a constant
Hi all,
Initially I thought this was a bug in the built-in mocking framework(and it
still may be), but I better hash it out on the mailing list before I
file/reopen the ticket:
http://rspec.lighthouseapp.com/projects/5645/tickets/478-mocks-on-constants#ticket-478-6
I thought my example illustrated my problem, but obviously I was passing the
wrong arguments to the mock. I revised my example to
2007 May 08
4
help with rspec''ing controller
Hi,
I''m a rspec newbie. I''m having trouble with rspec''ing a simple
controller to Create a record.
I''ve tried a couple of approaches and still get errors:
Mock ''remedy'' expected :save! with (any args) once, but received it 0
times
-or-
Mock ''Remedy'' received unexpected message :save with (no args).
Here are my two
2007 Nov 28
6
Newbie question
I installed Rspec and am getting the following failure:
$ sudo gem install rspec
Successfully installed rspec-1.0.8
Installing ri documentation for rspec-1.0.8...
Installing RDoc documentation for rspec-1.0.8...
$ spec -v
RSpec-1.0.8 (r2338) - BDD for Ruby
http://rspec.rubyforge.org/
$ cat acct.rb
describe Account, " when first created" do
it "should have a balance of $0"
2007 Feb 07
5
Mocking ActiveResource
I want to use ActiveResource in my app. Instead of hitting server
though, I want it to load from a file when I call find. Any clue how
I do that?
Pat
2007 Oct 31
16
Am I missing something with Heckle?
Hi
I can''t get heckle working. In fact, I''ve built an example so simple
that it either shows a bug, or I am being really, REALLY stupid.
Heckle does not appear to support RSpec directly, so I''m trying to use
spec --heckle (RSpec trunk as of 10 mins ago, Heckle 1.4.1). I''ve
constructed this pair of sample files:
18> ~/Desktop/heckle_test % cat
2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model?
I''m assuming i need to say
@mock_thing = mock_model(Thing)
@mock_thing_errors = mock("errors")
@mock_thing_errors.should_receive(:full_messages).and_return("An error")
@mock_thing.should_receive(:errors).and_return(@mock_thing_errors)
Just wanted to check the best practice on this kind of thing and how
2006 Jul 24
2
Creating a ''default'' mock
Am I correct in thinking that it''s not currently possible to have a
method that creates a ''standard'' mock (i.e. a mock that has defaults
useful in all contexts)?
I''ve tried with the mock method and also by manually creating new Mock
instances. I get failures when setting up expectations (undefined
method ''receive'' for proc).
Chris
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
I''m wondering whether I''m wasting my time trying to verify that an addition I''ve made to legacy code is in fact setting a new attribute on a model.
Substruct''s (http://dev.subimage.com/projects/substruct) OrderHelper contains this method:
1 def create_order_from_post
2 @use_separate_shipping_address = params[:use_separate_shipping_address]
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 Jun 28
19
Stopping example execution?
Hello, I''m wondering If I am missing something here when creating an example that sets an expecation at the top or beginning of an action but requires you to stub / mock everything that follows.
Example:
I want to test that a certain controller is running a before_filter...thats easy:
- controller.should_receive(:require_user)
- do_get
But now i''ve got to mock / stub