-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panda, tiger, eagle levels #15
base: master
Are you sure you want to change the base?
Conversation
end | ||
|
||
def winner | ||
return tie if @fighter_a_move.type == :block and @fighter_b_move.type == :block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to use &&
in most cases of and
. Same with ||
and or
(reasons: http://devblog.avdi.org/2010/08/02/using-and-and-or-in-ruby/)
Truly excellent work. Most people get stuck on the Building the match vs replaying the match. yay! |
I got stuck on getting the turn_specs to work. I've read other places that using 'instance_variable_set' is probably testing internal state and not the result. Is this true? What would the alternative approach be? I feel like the ruby stuff is going well but I spend most of my time trying to write tests. I definitely need more test writing practice. Thanks again for reviewing! |
Yes, that's true. If you feel the need to do that, you should extract logic to "Collaborators". That is, have the class that has internal variables you want to touch, and move the logic to something where you can send in the conditions you need in order to make changes. In this case, the trickiest part is deciding upon Random -- making decisions based upon a random result. So, you can extract Random out into a class you own, and fix the results based on what outcome you want to test. If you give an example, I can help in more concrete terms :) |
[fighter_a, fighter_b].should include subject.winner | ||
end | ||
|
||
it "should determine winner by rank on strike vs strike" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully this is what you meant be specific example:
In turn.rb I create a turn with 2 Fighters. These fighters already have moves assigned on creation.
- I need to assign a specific move and ranking for testing
Next, Turn randomly chooses a move for each fighter. - I need to assign a specific move to each fighter so I can test that the right move won
Are you saying I should have created a method #random on Turn that took 2 Moves so that when testing I could send in the Moves I want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so maybe instead of
[move_a, move_b].sample
You could have a method
choose_random [move_a, move_b]
And then you have full control over choose_random
muhahahaha 🎉
No description provided.