Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit d737c2b

Browse files
committed
Catching up with master
1 parent 884c496 commit d737c2b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

app/models/attack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def initialize(game:, word:, player:)
3131
private
3232

3333
def game_running?
34-
unless game.state == 'running'
34+
unless game.running?
3535
errors.add(:game, "not_running")
3636
end
3737
end

spec/models/attack_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
RSpec.describe "Attack", type: :model do
44
subject(:attack) { Attack.new(game: game, word: word, player: player) }
5-
let(:game) { Game.create!(state: 'running') }
5+
let(:game) { Game.create! }
66
let(:word) { 'attack' }
77
let(:player) { Player.new }
88

9-
before { allow_words("attack") }
9+
before do
10+
allow_words("attack")
11+
game.running!
12+
end
1013

1114
describe '.reward_for' do
1215
describe 'word between 0 and 1 letters' do
@@ -102,7 +105,7 @@
102105
context 'when game is finished' do
103106
before :each do
104107
allow_words("finished")
105-
game.update(state: 'finished')
108+
game.finished!
106109
end
107110

108111
it 'returns false' do

spec/requests/attacks_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
require "rails_helper"
22

33
RSpec.describe "Attacks", type: :request do
4-
let(:game) { Game.create!(name: 'Starship Battle', state: 'running') }
4+
let(:game) { Game.create!(name: 'Starship Battle') }
55
let(:player) { game.players.create!(nickname: "Rico") }
66

77
before :each do
8+
game.running!
89
allow_any_instance_of(ApplicationController).to receive(:current_player).and_return(player)
910
end
1011

0 commit comments

Comments
 (0)