-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz_rspec.rb
72 lines (57 loc) · 1.67 KB
/
quiz_rspec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'rspec'
require './quiz'
describe Quiz do
before do
@quiz = Quiz.new(["q1", "q2", "q3"])
end
it "gives me a question about cats as the first question" do
expect(@quiz.next_question).to eq "q1"
end
it "gives me a question about dogs as the second question" do
@quiz.next_question
expect(@quiz.next_question).to eq "q2"
end
it "stores answer" do
answer = "yes"
@quiz.store_answer(answer)
expect(@quiz.last_answer).to eq answer
end
it "only accepts yes or no as answers" do
expect{@quiz.store_answer("huhuhu") }.to raise_error(InvalidAnswerError)
end
it "should count starts in zero" do
expect(@quiz.count).to eq 0
end
it "should count when next question is called" do
@quiz.next_question
expect(@quiz.count).to eq 1
end
it "should count when next question is called for the second time" do
2.times do
@quiz.next_question
end
expect(@quiz.count).to eq 2
end
it "says there are more questions available when we havent asked any questions" do
expect(@quiz.has_more_questions?).to be true
end
it "says there are more questions available when we have asked only some of the questions" do
2.times do
@quiz.next_question
end
expect(@quiz.has_more_questions?).to be true
end
it "says there are no more questions available when we have asked all the questions" do
3.times do
@quiz.next_question
end
expect(@quiz.has_more_questions?).to be false
end
# it "evaluates the answers" do
# # @questions = %w(1 2 3 4 5)
# # 5.times do
# # @quiz.next_question
# # end
# expect(@quiz.result).to eq "Result"
# end
end