Skip to content

Commit

Permalink
Complete assignment method TheOdinProject#2
Browse files Browse the repository at this point in the history
  • Loading branch information
lohikaarme committed Dec 5, 2023
1 parent 66e9d41 commit 71a85d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/14_find_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ def initialize(min, max, answer = RandomNumber.new(min, max), guess = nil)
def make_guess(min = @min, max = @max)
((min + max)/2).floor
end

def game_over?
return true if @guess == @answer
end
end
10 changes: 8 additions & 2 deletions spec/14_find_number_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
# ASSIGNMENT: METHOD #2
describe '#game_over?' do
context 'when guess and random_number are equal' do
let(:end_solution) { double('random_number', value: 3)}
subject(:game_over) { described_class.new(0, 9, end_solution, 3)}
# Create another subject and random_number double with meaningful names.
# The subject will need to specify the number value of @guess.

Expand All @@ -178,7 +180,8 @@
# the random_number double's value above. Remember that this test will not
# be able to pass yet because you haven't written the method!

xit 'is game over' do
it 'is game over' do
expect(game_over).to be_game_over
end
end

Expand All @@ -189,7 +192,10 @@
# NOT equal the random_number double's value above.

context 'when guess and random_number are not equal' do
xit 'is not game over' do
let(:incorrect_guess) { double('random_number', value: 6) }
subject(:wrong_solution) { described_class.new(0, 9, incorrect_guess, 5) }
it 'is not game over' do
expect(wrong_solution).to_not be_game_over
end
end
end
Expand Down

0 comments on commit 71a85d3

Please sign in to comment.