thirteen-tien-len/spec/models/table_spec.rb
2021-07-08 01:33:16 -07:00

39 lines
1014 B
Ruby

RSpec.describe Table, type: :model do
before :all do
@table = FactoryGirl.create(:table)
end
subject { @table }
it { should respond_to :title }
it { should respond_to :seats }
it { should respond_to :users }
it { should respond_to :games }
it { should respond_to :current_game }
it '#title returns a string' do
expect(@table.title).to match 'Test Table'
end
it '#seats returns Seats collection' do
expect(@table.seats.class.to_s).to match "Seat::ActiveRecord_Associations_CollectionProxy"
end
it '#users returns Users collection' do
expect(@table.users.class.to_s).to match "User::ActiveRecord_Associations_CollectionProxy"
end
it '#games returns Games collection' do
expect(@table.games.class.to_s).to match "Game::ActiveRecord_Associations_CollectionProxy"
end
it '#current_game returns a Game' do
expect(@table.current_game.class).to match Game
end
it "#seats returns 4 seats by default" do
expect(@table.seats.count).to eq 4
end
end