The goal for this warmup is to practice refactoring using Sandi Metz Rules. Use these rules to refactor this class to the best of your ability. Use the specs to ensure functionality is still working, you may need to rewrite them in accordance with your code changes. This is a full working Rails app written by @craftninja, so the app should still be working after the refactor.
There is a model, and there is a corresponding spec.
- Your class can be no longer than 100 lines of code.
- Your methods can be no longer than five lines of code.
- You can pass no more than four parameters and you can't just make it one big hash.
- When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done.
Break one thing at a time. Make a small change and run the specs. Commit often.
- There are two bugs pending in the game spec. Un-pend and fix the bugs.
- fork, clone, bundle
- rake db:create db:migrate
- rails s
- register and play!
- Dice are rejected if cannot be scored, flash message is shown? and dice can be used again in next roll
- User can play game with remote players
- User can have multiple games going on, are listed on welcome page
it 'finds a certain roll' do
players = {"player_1" => "Albert", "player_2" => "Eddie"}
actual_roll = ""
i = 0
while actual_roll != [[2, '⚁'],[3, '⚂'],[4, '⚃'],[4, '⚃'],[6, '⚅'],[6, '⚅']]
srand(i)
game_turn = Game.new(players)
game_turn.roll_again([])
actual_roll = game_turn.last_roll
p "srand #{i} - #{actual_roll}"
i+=1
end
end