Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-31 Thread Ken Egervari
> On 2011-05-31 1:57 PM, Chris Habgood wrote: > >> The program works when I run it on the server. >> >> describe FoodsController do >> render_views >> >> before(:each) do >> Food.delete_all >> login_as_admin >> Food.stubs(:find).with("1").returns(@food = mock_model(Food, >> :save=>fa

Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-31 Thread Ken Egervari
Can you give me the whole test code, with no comments? Just the stuff you are running. Thanks Ken On Tue, May 31, 2011 at 4:59 PM, Chris Habgood wrote: > yes > > > On Tue, May 31, 2011 at 15:33, Ken Egervari wrote: > >> Dumb question, do you have required "spec_help

Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-31 Thread Ken Egervari
n Tue, May 31, 2011 at 14:35, Ken Egervari wrote: > >> Oh, don't forget the :id in the call to edit >> >> >> before(:each) do >> @food = Food.new >> @food.id = 1 >> end >> >> describe "GET 'edit'" do >&g

Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-31 Thread Ken Egervari
Oh, don't forget the :id in the call to edit before(:each) do @food = Food.new @food.id = 1 end describe "GET 'edit'" do it "should be successful" do Food.stub(:find).with("1").and_return(@food) get :edit, :id => "1" assigns(:food).should == @food end e

Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-31 Thread Ken Egervari
(@food) get :edit assigns(:food).should == @food end end ^ This should work. > > describe "GET edit" do > it "should assign the requested food to @food" do >#Food.should_receive(:find).with("1").and_return(

Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-31 Thread Ken Egervari
On Tue, May 31, 2011 at 2:38 PM, Chris Habgood wrote: > Still getting the same error. ugggh. Truly, you have to give us some more code to help you. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-use

[rspec-users] How do you test a module that extends ActiveSupport::Concern?

2011-05-31 Thread Ken Egervari
I have a module that extends ActiveSupport::Concern. Here is the `included` block: included do after_save :save_tags has_many :taggings, :as => :taggable has_many :tags, :through => :taggings end How can I stub out these calls? I have tried a few ways, but Ruby complains that the

Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-28 Thread Ken Egervari
I just found it bothersome to use stubs when testing rails controllers. A far easier way to do this is to define what @food is in a before(:each) block and then use it in your tests: describe "GET edit" do it "should assign the requested food to @food" do Food.should_receive(:find).wi

Re: [rspec-users] [rails] undefined method `model_name' for NilClass:Class

2011-05-28 Thread Ken Egervari
espace for example, you are introducing a potential problem where the new or edit form doesn't work anymore. I have found it less trouble to actually test it to make sure Rails doesn't throw some error about trying to find a 'show' action when it's not supposed to. Ken On

Re: [rspec-users] RSpec and Rake

2011-05-28 Thread Ken Egervari
On Sat, May 28, 2011 at 8:12 AM, Jason Nah wrote: > Guys, > > Just upgraded to rspec / rspec-rails 2.6 today and noticed that it pulled > in rake 0.9.0 which was causing the rails 3.0.7 tasks to blowup. > > I've downgraded rake to 0.8.7. Are there any 'side-effects' that may impact > the operatio

Re: [rspec-users] For those using Rails with RSpec... what do you guys use for creating Factories?

2011-05-25 Thread Ken Egervari
On Thu, May 26, 2011 at 12:10 AM, Justin Ko wrote: > > > On Wed, May 25, 2011 at 6:11 PM, Ken Egervari wrote: > >> On Wed, May 25, 2011 at 5:34 PM, David Chelimsky wrote: >> >>> On May 25, 2011, at 2:00 PM, Ken Egervari wrote: >>> >>> I am u

Re: [rspec-users] For those using Rails with RSpec... what do you guys use for creating Factories?

2011-05-25 Thread Ken Egervari
On Wed, May 25, 2011 at 5:34 PM, David Chelimsky wrote: > On May 25, 2011, at 2:00 PM, Ken Egervari wrote: > > I am using factory_girl, and I have discovered that it is chiefly > responsible for making my tests run slow. > > I have posted a question about this on Stack Ov

Re: [rspec-users] How do you factor out common "before(:each)" calls so that multiple specs can use them?

2011-05-25 Thread Ken Egervari
es it > easier to have scenarios for both authenticated and unauthenticated > access in the same spec. YMMV. > > Best, > Sidu. > http://c42.in > http://about.me/ponnappa > > On 26 May 2011 02:20, Ken Egervari wrote: > > I'd like to factor this bunch of code

Re: [rspec-users] For those using Rails with RSpec... what do you guys use for creating Factories?

2011-05-25 Thread Ken Egervari
emory db. You could > also parallelize your specs to use all cores on your machine. > > Best, > Sidu. > http://c42.in > http://about.me/ponnappa > > On 26 May 2011 00:30, Ken Egervari wrote: > > I am using factory_girl, and I have discovered that it is chiefly > > res

Re: [rspec-users] For those using Rails with RSpec... what do you guys use for creating Factories?

2011-05-25 Thread Ken Egervari
Sure, I have to add a pieces of data to make render_views comply, but it's not much. It is a *very small* price to pay for this much performance gain. Ken On Wed, May 25, 2011 at 5:45 PM, Justin Ko wrote: > > > On Wed, May 25, 2011 at 1:00 PM, Ken Egervari wrote: > >&g

[rspec-users] How do you factor out common "before(:each)" calls so that multiple specs can use them?

2011-05-25 Thread Ken Egervari
I'd like to factor this bunch of code so that all of my controller tests (well, almost all of them) use this before(:each) block: before(:each) do @user = User.new controller.stub(:authenticate_user!) controller.stub(:current_user).and_return(@user) controller.stub(:add_secure_mo

[rspec-users] For those using Rails with RSpec... what do you guys use for creating Factories?

2011-05-25 Thread Ken Egervari
I am using factory_girl, and I have discovered that it is chiefly responsible for making my tests run slow. I have posted a question about this on Stack Overflow: http://stackoverflow.com/questions/6128476/how-can-i-get-factory-girl-to-never-hit-the-database-if-i-am-calling-factory-buil Anyway,

Re: [rspec-users] Reusing Spec's

2011-05-18 Thread Ken Egervari
h! I think it's because Ubuntu has installed 1.9.1 as a package and Idea detected this one over the the other one. Ken On Wed, May 18, 2011 at 9:36 PM, Justin Ko wrote: > > > On Wed, May 18, 2011 at 8:33 PM, Ken Egervari wrote: > >> Hi Justin >> >> I tried tha

Re: [rspec-users] Reusing Spec's

2011-05-18 Thread Ken Egervari
Oh, never mind. I tried this in spec_helper.rb and it works ;) Ken On Wed, May 18, 2011 at 9:33 PM, Ken Egervari wrote: > Hi Justin > > I tried that config.include call in my test.rb file, but Rails complains:: > > /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/li

Re: [rspec-users] Reusing Spec's

2011-05-18 Thread Ken Egervari
Wed, May 18, 2011 at 10:23 AM, Ken Egervari wrote: > >> Hello, >> >> Is there any way to reuse spec definitions, perhaps through some kind of >> inheritance? >> >> For example, in rails, every time it generates a Spec I must tell it to >> >> 1

[rspec-users] Reusing Spec's

2011-05-18 Thread Ken Egervari
Hello, Is there any way to reuse spec definitions, perhaps through some kind of inheritance? For example, in rails, every time it generates a Spec I must tell it to 1) Include Devise::TestHelpers 2) Log the user in, so there is a default user setup before each test is run. This is common for 95%