[rspec-users] View spec for 'new' keeps failing despite generated html has expected attribute

Gordon anexiole at gmail.com
Wed Oct 19 03:36:11 EDT 2011


Fixed the issue as soon as I walked off my desk.
Thought it was because of the resource object, @brand in spec/views/
parts/new.html.erb_spec.rb not being stubbed properly.

Checked and I was right :)

So,
  before(:each) do
    @brand = assign( :brand,
                        stub_model( Brand,
                          :name        => 'Apple',
                          :description => 'OS X and Ipods'
                        )
   )
  end

should have also had the ".as_new_record" method there. Reading below,
my view specs pass :)


    before(:each) do
        @brand = assign( :brand,
            stub_model( Brand,
                          :name        => 'Apple',
                          :description => 'OS X and Ipods'
            ).as_new_record
        )
    end


Case closed :)


More information about the rspec-users mailing list