I am testing with ruby on rails (using rspec) - testing my events controller (specifically a variable assignment) like so:
Controller Code:
class EventsController < ApplicationController
def index
start_at = Time.zone.at(params[:start].to_f)
puts start_at
end
The puts start_at command above gives the output:
2015-05-01 19:56:25 -0700
RSPEC Test Code:
describe "INDEX action" do
it "assings correct start time" do
get('index', {:format=>:json, :start=> @event.starts_at,:end=>@event.ends_at})
expect(assigns(:start_at)).to eq(@event.starts_at)
end
end
Error Message:
Failure/Error: expect(assigns(:start_at)).to eq(@event.starts_at)
expected: Fri, 01 May 2015 19:56:25 PDT -07:00
got: nil
(compared using ==)
I am confused, why is it getting nil - when i output start_at it gives me a value. Therefore when i am testing, should it not return the same value as the output ?
Aucun commentaire:
Enregistrer un commentaire