I am writing a rails app with my colleague who wrote a lot of the tests.  
He had to take a leave of absence due to a death in his family, and I am 
needing helps with changing the model so that the tests will pass in our 
spec file.

Here is the model:

    class Worker < ActiveRecord::Base
      attr_accessible :first_name, :last_name
      
      has_many :writings
    end




Here is the spec:

    require 'spec_helper.rb'
    
    describe Worker do
      describe "merging two workers" do
        before(:each) do
          @writing1 = Writing.create!(:writing_text => "Winner's note")
          @writing2 = Writing.create!(:writing_text => "Loser's note")
          
          @winner = Worker.create!(:first_name => "Jim", :last_name => 
"Sullivan", :email => "win...@gmail.com")
          @winner.writings << @writing1
          
          @loser  = Worker.create!(:first_name => "Tom", :last_name => 
"Smithe"
          @loser.writings << @writing2
          
          @result = Worker.merge(@winner, @loser)
        end
        
        it "should return the winner" do
          @result.id.should eq @winner.id
        end
          
        it "should not edit the winner's name" do
          @result.first_name.should eq @winner.first_name
          @result.last_name.should eq @winner.last_name
        end
    end
    end


All of these tests are failing, and I'm not sure what to do.  I don't want 
to try something and accidentally break the model, as I am new to ruby on 
rails.  Thanks.

Fails:

Failures:

  

        1) Worker merging two worker should return the winner
         Failure/Error: @result = Worker.merge(@winner, @loser)
         NoMethodError:
           undefined method `merge' for #<Class:0x007fb612ee2ff8>
         # ./spec/models/worker_spec.rb:15:in `block (3 levels) in <top 
(required)>'
    
      2) Person merging two people should not edit the winner's name
         Failure/Error: @result = Worker.merge(@winner, @loser)
         NoMethodError:
           undefined method `merge' for #<Class:0x007fb612ee2ff8>
         # ./spec/models/worker_spec.rb:15:in `block (3 levels) in <top 
(required)>'
    
      3) Person merging two people should merge the winner's email only if 
he has no email
         Failure/Error: @result = Worker.merge(@winner, @loser)
         NoMethodError:
           undefined method `merge' for #<Class:0x007fb612ee2ff8>
         # ./spec/models/worker_spec.rb:15:in `block (3 levels) in <top 
(required)>'
    
      4) Person merging two people should not edit the winner's company name
         Failure/Error: @result = Worker.merge(@winner, @loser)
         NoMethodError:
           undefined method `merge' for #<Class:0x007fb612ee2ff8>
         # ./spec/models/worker_spec.rb:15:in `block (3 levels) in <top 
(required)>'
    
      5) Person merging two people should delete the loser
         Failure/Error: @result = Worker.merge(@winner, @loser)
         NoMethodError:
           undefined method `merge' for #<Class:0x007fb612ee2ff8>
         # ./spec/models/worker_spec.rb:15:in `block (3 levels) in <top 
(required)>'
    
      6) Person merging two people should merge the notes together
         Failure/Error: @result = Worker.merge(@winner, @loser)
         NoMethodError:
           undefined method `merge' for #<Class:0x007fb612ee2ff8>
         # ./spec/models/worker_spec.rb:15:in `block (3 levels) in <top 
(required)>'


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9db48dda-76b2-490f-bb4f-bcff90cb9a60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to