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

Commit

Permalink
Catching up with master
Browse files Browse the repository at this point in the history
  • Loading branch information
r3trofitted committed Nov 19, 2016
1 parent 884c496 commit d737c2b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(game:, word:, player:)
private

def game_running?
unless game.state == 'running'
unless game.running?
errors.add(:game, "not_running")
end
end
Expand Down
9 changes: 6 additions & 3 deletions spec/models/attack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

RSpec.describe "Attack", type: :model do
subject(:attack) { Attack.new(game: game, word: word, player: player) }
let(:game) { Game.create!(state: 'running') }
let(:game) { Game.create! }
let(:word) { 'attack' }
let(:player) { Player.new }

before { allow_words("attack") }
before do
allow_words("attack")
game.running!
end

describe '.reward_for' do
describe 'word between 0 and 1 letters' do
Expand Down Expand Up @@ -102,7 +105,7 @@
context 'when game is finished' do
before :each do
allow_words("finished")
game.update(state: 'finished')
game.finished!
end

it 'returns false' do
Expand Down
3 changes: 2 additions & 1 deletion spec/requests/attacks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require "rails_helper"

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

before :each do
game.running!
allow_any_instance_of(ApplicationController).to receive(:current_player).and_return(player)
end

Expand Down

0 comments on commit d737c2b

Please sign in to comment.