Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Scott Taylor
On Nov 4, 2008, at 3:46 PM, Fernando Perez wrote: Are the docs on mock outdated? I sometimes see mock_model, and sometimes mock. Which one should be used? mock_model is for ActiveRecord objects. it's just a mock() call with a random id stub set, and a :new_record? => false Scott _

Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Fernando Perez
Ok I get it. I was wondering why mock_model was not showing up in rspec's rdoc. Thanks for the clarification. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-us

Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Fernando Perez
Crap! I was stubbing Product, instead of Site! It all works now. Matt's typo put me on the track! But I will definitely use the trick Spec::Runner.configure do |config|... to avoid having to type this stub in all my files. Thanks. -- Posted via http://www.ruby-forum.com/.

Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Matt Wynne
On 4 Nov 2008, at 20:46, Fernando Perez wrote: Are the docs on mock outdated? I sometimes see mock_model, and sometimes mock. Which one should be used? For mock_model, you need to look at the rspec-rails gem, which is a separate library. You actually have three choices when mocking an Ac

Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Fernando Perez
Are the docs on mock outdated? I sometimes see mock_model, and sometimes mock. Which one should be used? -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Fernando Perez
> That work? It could. But in such case, how will I test my before_filter independently? My real problem is to stub the find_by_domain_name instance method. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.

Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Matt Wynne
On 4 Nov 2008, at 19:38, Fernando Perez wrote: Here is my spec: -- describe Admin::ProductsController, "A visitor wants to access admin/products" do before(:each) do @product = mock_model(Product, :traffic_available => 0) Product.stub!(:find_by_domain_name).and_return(@product) Should t

Re: [rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread David Chelimsky
On Tue, Nov 4, 2008 at 1:38 PM, Fernando Perez <[EMAIL PROTECTED]> wrote: > Here is my spec: > -- > describe Admin::ProductsController, "A visitor wants to access > admin/products" do > > before(:each) do >@product = mock_model(Product, :traffic_available => 0) >Product.stub!(:find_by_doma

[rspec-users] Unable to stub a class method in a before_filter

2008-11-04 Thread Fernando Perez
Here is my spec: -- describe Admin::ProductsController, "A visitor wants to access admin/products" do before(:each) do @product = mock_model(Product, :traffic_available => 0) Product.stub!(:find_by_domain_name).and_return(@product) end it "should redirect to login path" do get :