Forum: RSpec Testing Custom methods

Posted by Tony Spore (Guest)
on 2011-11-14 21:49
(Received via mailing list)
I am attempting to test a custom method, and totally bombing out.
describe Record do
  describe '#save_cf_data' do
    before  :each do
      @record = mock_model(Record)
    end
    it "should have a birthday" do
      @record.save_cf_data({"final_outputs"=>["birth_day"=>["3"]]})
      @record.birth_day.should eql 3
    end
end

My Model looks like this:
class Record < ActiveRecord::Base
   def save_cf_data(params)
     result = params[:final_outputs].first
       ....
      self.birth_day = result['birth_day'].first
  end
end


I have this output - As if I'm not hitting the method correctly -

Mock "Record_1002" received unexpected message :save_cf_data with
({"final_outputs"=>[{"birth_day"=>["3"]}]})



The actual code mostly works, I think I'm just sending rspec the wrong
info.


Thanks!
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.