Sha256: e918192ac218c4bf3d881d4766cde5b29ca98a829b22b3b7b5cc934d0607708b

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require_relative 'spec_helper'

describe TriviaCrack::Game do
  let(:game_id) { 1111 }
  let(:game) { TriviaCrack::Game.new id: game_id, my_turn: my_turn, game_status: game_status }

  describe '#playable?' do
    subject { game.playable? }

    context 'when the game status is active' do
      let(:game_status) { :active }

      context 'and it is the users turn' do
        let(:my_turn) { true }

        it { is_expected.to be true }
      end

      context 'and it is not the users turn' do
        let(:my_turn) { false }

        it { is_expected.to be false }
      end
    end

    context 'when the game status is pending_approval' do
      let(:game_status) { :pending_approval }

      context 'and it is the users turn' do
        let(:my_turn) { true }

        it { is_expected.to be true }
      end

      context 'and it is not the users turn' do
        let(:my_turn) { false }

        it { is_expected.to be false }
      end
    end

    context 'when the game status is ended' do
      let(:game_status) { :ended }

      context 'and it is the users turn' do
        let(:my_turn) { true }

        it { is_expected.to be false }
      end

      context 'and it is not the users turn' do
        let(:my_turn) { false }

        it { is_expected.to be false }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
triviacrack-0.8.0 spec/game_spec.rb
triviacrack-0.7.0 spec/game_spec.rb