|
| 1 | +require "rails_helper" |
| 2 | + |
| 3 | +RSpec.describe "GameExhibit" do |
| 4 | + let(:game) { Game.new } |
| 5 | + let(:player) { Player.new } |
| 6 | + subject(:game_exhibit) { GameExhibit.new(game, player) } |
| 7 | + |
| 8 | + describe "#to_partial_path" do |
| 9 | + subject { game_exhibit.to_partial_path } |
| 10 | + |
| 11 | + context "when the current player is actually playing the game" do |
| 12 | + before { player.game = game } |
| 13 | + |
| 14 | + context "if the game is waiting for an opponent" do |
| 15 | + before { allow(game).to receive(:state).and_return("awaiting_opponent") } |
| 16 | + it { is_expected.to eql("games/game") } |
| 17 | + end |
| 18 | + |
| 19 | + context "if the game is running" do |
| 20 | + before { allow(game).to receive(:state).and_return("running") } |
| 21 | + it { is_expected.to eql("games/game") } |
| 22 | + end |
| 23 | + |
| 24 | + context "if the game is over" do |
| 25 | + before { allow(game).to receive(:state).and_return("finished") } |
| 26 | + it { is_expected.to eql("games/finished_game") } |
| 27 | + end |
| 28 | + end |
| 29 | + |
| 30 | + context "when the current player is not part of the game" do |
| 31 | + before { player.game = Game.new } |
| 32 | + |
| 33 | + context "if the game is waiting for an opponent" do |
| 34 | + before { allow(game).to receive(:state).and_return("awaiting_opponent") } |
| 35 | + it { is_expected.to eql("games/awaiting_opponent_game") } |
| 36 | + end |
| 37 | + |
| 38 | + context "if the game is running" do |
| 39 | + before { allow(game).to receive(:state).and_return("running") } |
| 40 | + it { is_expected.to eql("games/full_game") } |
| 41 | + end |
| 42 | + |
| 43 | + context "if the game is over" do |
| 44 | + before { allow(game).to receive(:state).and_return("finished") } |
| 45 | + it { is_expected.to eql("games/finished_game") } |
| 46 | + end |
| 47 | + end |
| 48 | + end |
| 49 | +end |
0 commit comments