I want to test if my sessions logic works.
Session:
id
user_id
When I create a new session, if there was a previous session row in the db
with user_id = xxx, it should delete it first, then create a new row.
How could I test this scenerio?
So far I have:
require 'spec_helper'
describe Session do
let(:session) { FactoryGirl.create(:session) }
subject { session }
it { should be_valid }
describe "a new session" do
s1 = FactoryGirl.build(:session)
s2 = FactoryGirl.build(:session)
user = FactoryGirl.create(:user)
s1.user_id = user.id
s1.save!
#should change(Session, :count).by(1)
end
end
I can't seem to figure out how to use the "should change Session count by
1".
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users