barker 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.simplecov +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +50 -0
- data/LICENSE +22 -0
- data/README.md +204 -0
- data/Rakefile +12 -0
- data/barker.gemspec +29 -0
- data/ci/run +20 -0
- data/lib/barker/answer.rb +11 -0
- data/lib/barker/api/base.rb +145 -0
- data/lib/barker/api/response/base.rb +25 -0
- data/lib/barker/api/response/candidate.rb +38 -0
- data/lib/barker/api/response/candidate_answer.rb +23 -0
- data/lib/barker/api/response/candidate_joker.rb +21 -0
- data/lib/barker/api/response/candidate_question.rb +51 -0
- data/lib/barker/api/response/error.rb +17 -0
- data/lib/barker/api/response/game_show.rb +43 -0
- data/lib/barker/api/response/round.rb +21 -0
- data/lib/barker/api/response.rb +15 -0
- data/lib/barker/api.rb +7 -0
- data/lib/barker/candidate.rb +52 -0
- data/lib/barker/candidate_answer.rb +42 -0
- data/lib/barker/candidate_joker.rb +30 -0
- data/lib/barker/candidate_question.rb +116 -0
- data/lib/barker/candidate_round.rb +32 -0
- data/lib/barker/entity.rb +15 -0
- data/lib/barker/game_show.rb +176 -0
- data/lib/barker/guideline/base.rb +33 -0
- data/lib/barker/guideline/llmcquiz/questions.yaml +300 -0
- data/lib/barker/guideline/llmcquiz.rb +28 -0
- data/lib/barker/guideline/mock.rb +17 -0
- data/lib/barker/guideline.rb +8 -0
- data/lib/barker/import/yaml.rb +22 -0
- data/lib/barker/import.rb +6 -0
- data/lib/barker/joker.rb +28 -0
- data/lib/barker/question.rb +12 -0
- data/lib/barker/quiz.rb +19 -0
- data/lib/barker/repo/memory/game_show.rb +38 -0
- data/lib/barker/repo/memory.rb +8 -0
- data/lib/barker/repo.rb +6 -0
- data/lib/barker/round.rb +68 -0
- data/lib/barker/stage.rb +38 -0
- data/lib/barker/store/memory.rb +158 -0
- data/lib/barker/store.rb +6 -0
- data/lib/barker/validations.rb +14 -0
- data/lib/barker/version.rb +3 -0
- data/lib/barker.rb +45 -0
- data/test/factories/answer.rb +21 -0
- data/test/factories/candidate.rb +23 -0
- data/test/factories/candidate_answer.rb +12 -0
- data/test/factories/candidate_joker.rb +8 -0
- data/test/factories/candidate_question.rb +16 -0
- data/test/factories/candidate_round.rb +8 -0
- data/test/factories/game_show.rb +12 -0
- data/test/factories/joker.rb +5 -0
- data/test/factories/question.rb +13 -0
- data/test/factories/quiz.rb +11 -0
- data/test/factories/round.rb +12 -0
- data/test/factories/stage.rb +12 -0
- data/test/fixtures/questions.yaml +20 -0
- data/test/test_helper.rb +72 -0
- data/test/test_mocks.rb +21 -0
- data/test/unit/answer_test.rb +49 -0
- data/test/unit/api/base_test.rb +207 -0
- data/test/unit/api/response/base_test.rb +35 -0
- data/test/unit/api/response/candidate_answer_test.rb +64 -0
- data/test/unit/api/response/candidate_joker_test.rb +60 -0
- data/test/unit/api/response/candidate_question_test.rb +99 -0
- data/test/unit/api/response/candidate_test.rb +82 -0
- data/test/unit/api/response/game_show_test.rb +105 -0
- data/test/unit/api/response/round_test.rb +49 -0
- data/test/unit/candidate_answer_test.rb +66 -0
- data/test/unit/candidate_question_test.rb +277 -0
- data/test/unit/candidate_round_test.rb +64 -0
- data/test/unit/candidate_test.rb +76 -0
- data/test/unit/game_show_test.rb +372 -0
- data/test/unit/guideline/base_test.rb +34 -0
- data/test/unit/guideline/llmcquiz_test.rb +35 -0
- data/test/unit/guideline/mock_test.rb +33 -0
- data/test/unit/import/yaml_test.rb +41 -0
- data/test/unit/joker_test.rb +32 -0
- data/test/unit/question_test.rb +55 -0
- data/test/unit/quiz_test.rb +37 -0
- data/test/unit/repo/memory/game_show_test.rb +54 -0
- data/test/unit/round_test.rb +167 -0
- data/test/unit/stage_test.rb +53 -0
- metadata +283 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Barker
|
4
|
+
class CandidateAnswerTest < Spec
|
5
|
+
|
6
|
+
test "interface" do
|
7
|
+
Barker::CandidateAnswer.new(candidate, answer)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "valid factory" do
|
11
|
+
assert FactoryGirl.build(:candidate_answer).valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
test "invalid factory" do
|
15
|
+
refute FactoryGirl.build(:candidate_answer, :invalid).valid?
|
16
|
+
end
|
17
|
+
|
18
|
+
test "invalid if answer is invalid" do
|
19
|
+
refute FactoryGirl.build(:candidate_answer, :answer => FactoryGirl.build(:answer, :invalid)).valid?
|
20
|
+
end
|
21
|
+
|
22
|
+
test "candidate" do
|
23
|
+
assert_equal candidate, FactoryGirl.build(:candidate_answer, :candidate => candidate).candidate
|
24
|
+
end
|
25
|
+
|
26
|
+
test "answer" do
|
27
|
+
assert_equal answer, FactoryGirl.build(:candidate_answer, :answer => answer).answer
|
28
|
+
end
|
29
|
+
|
30
|
+
test "reveal" do
|
31
|
+
answer = FactoryGirl.build(:candidate_answer)
|
32
|
+
|
33
|
+
refute answer.revealed?
|
34
|
+
answer.reveal
|
35
|
+
assert answer.revealed?
|
36
|
+
end
|
37
|
+
|
38
|
+
test "answer_id" do
|
39
|
+
answer = FactoryGirl.build(:answer)
|
40
|
+
assert_equal answer.id, FactoryGirl.build(:candidate_answer, :answer => answer).answer_id
|
41
|
+
end
|
42
|
+
|
43
|
+
test "candidate_id" do
|
44
|
+
candidate = FactoryGirl.build(:candidate)
|
45
|
+
assert_equal candidate.id, FactoryGirl.build(:candidate_answer, :candidate => candidate).candidate_id
|
46
|
+
end
|
47
|
+
|
48
|
+
test "label fallback to en if candidate locale is missing" do
|
49
|
+
candidate = FactoryGirl.build(:candidate, :locale => 'wookie')
|
50
|
+
answer = FactoryGirl.build(:candidate_answer, :candidate => candidate, :answer => FactoryGirl.build(:answer, :label => {'en' => 'answer in en'}))
|
51
|
+
assert_equal 'answer in en', answer.label
|
52
|
+
end
|
53
|
+
|
54
|
+
test "translate label in candidate locale" do
|
55
|
+
candidate = FactoryGirl.build(:candidate, :locale => 'wookie')
|
56
|
+
answer = FactoryGirl.build(:candidate_answer, :candidate => candidate, :answer => FactoryGirl.build(:answer, :label => {'en' => 'answer in en', 'wookie' => 'woo arrr uuur'}))
|
57
|
+
assert_equal 'woo arrr uuur', answer.label
|
58
|
+
end
|
59
|
+
|
60
|
+
test "delegate correct? to answer" do
|
61
|
+
answer = FactoryGirl.build(:candidate_answer, :answer => FactoryGirl.build(:answer, :correct))
|
62
|
+
assert answer.correct?
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,277 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Barker
|
4
|
+
class CandidateQuestionTest < Spec
|
5
|
+
|
6
|
+
test "interface" do
|
7
|
+
Barker::CandidateQuestion.new(candidate, question)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "valid factory" do
|
11
|
+
FactoryGirl.build(:candidate_question, :valid).valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
test "invalid factory" do
|
15
|
+
refute FactoryGirl.build(:candidate_question).valid?
|
16
|
+
refute FactoryGirl.build(:candidate_question, :invalid).valid?
|
17
|
+
end
|
18
|
+
|
19
|
+
test "valid?" do
|
20
|
+
refute FactoryGirl.build(:candidate_question, :asked_at => Time.now, :answered_at => Time.now + 1, :question => FactoryGirl.build(:question, :invalid)).valid?
|
21
|
+
refute FactoryGirl.build(:candidate_question, :asked_at => Time.now + 1, :answered_at => Time.now).valid?
|
22
|
+
end
|
23
|
+
|
24
|
+
test "id alias question_id" do
|
25
|
+
assert_equal question.id, FactoryGirl.build(:candidate_question, :question => question).id
|
26
|
+
end
|
27
|
+
|
28
|
+
test "question" do
|
29
|
+
assert_equal question, FactoryGirl.build(:candidate_question, :question => question).question
|
30
|
+
end
|
31
|
+
|
32
|
+
test "question_id" do
|
33
|
+
assert_equal question.id, FactoryGirl.build(:candidate_question, :question => question).question_id
|
34
|
+
end
|
35
|
+
|
36
|
+
test "candidate" do
|
37
|
+
assert_equal candidate, FactoryGirl.build(:candidate_question, :candidate => candidate).candidate
|
38
|
+
end
|
39
|
+
|
40
|
+
test "candidate_id" do
|
41
|
+
assert_equal candidate.id, FactoryGirl.build(:candidate_question, :candidate => candidate).candidate_id
|
42
|
+
end
|
43
|
+
|
44
|
+
test "ask return self" do
|
45
|
+
question = FactoryGirl.build(:candidate_question)
|
46
|
+
assert_equal question, question.ask
|
47
|
+
end
|
48
|
+
|
49
|
+
test "ask set asked_at to now" do
|
50
|
+
asked_at = Time.now
|
51
|
+
Time.stubs(:now).returns(asked_at)
|
52
|
+
|
53
|
+
question = FactoryGirl.build(:candidate_question)
|
54
|
+
|
55
|
+
assert_nil question.asked_at
|
56
|
+
question.ask
|
57
|
+
assert_equal asked_at, question.asked_at
|
58
|
+
end
|
59
|
+
|
60
|
+
test "ask set asked_at only once" do
|
61
|
+
asked_at = Time.now
|
62
|
+
asked_again_at = Time.now + 100
|
63
|
+
Time.stubs(:now).returns(asked_at)
|
64
|
+
|
65
|
+
question = FactoryGirl.build(:candidate_question)
|
66
|
+
|
67
|
+
assert_nil question.asked_at
|
68
|
+
question.ask
|
69
|
+
assert_equal asked_at, question.asked_at
|
70
|
+
|
71
|
+
Time.stubs(:now).returns(asked_again_at)
|
72
|
+
question.ask
|
73
|
+
assert_equal asked_at, question.asked_at
|
74
|
+
end
|
75
|
+
|
76
|
+
test "ask set state from open to asked" do
|
77
|
+
question = FactoryGirl.build(:candidate_question)
|
78
|
+
|
79
|
+
assert_equal :open, question.state
|
80
|
+
question.ask
|
81
|
+
assert_equal :asked, question.state
|
82
|
+
end
|
83
|
+
|
84
|
+
test "answer return given answer" do
|
85
|
+
question = FactoryGirl.build(:candidate_question)
|
86
|
+
answer_id = question.answers[0].id
|
87
|
+
question.ask
|
88
|
+
assert_equal question.answers[0], question.answer(answer_id)
|
89
|
+
end
|
90
|
+
|
91
|
+
test "given answer" do
|
92
|
+
question = FactoryGirl.build(:candidate_question)
|
93
|
+
answer_id = question.answers[0].id
|
94
|
+
|
95
|
+
question.ask
|
96
|
+
question.answer(answer_id)
|
97
|
+
|
98
|
+
assert_equal question.answers[0], question.given_answer
|
99
|
+
end
|
100
|
+
|
101
|
+
test "answer set answered_at to now" do
|
102
|
+
answered_at = Time.now
|
103
|
+
Time.stubs(:now).returns(answered_at)
|
104
|
+
|
105
|
+
question = FactoryGirl.build(:candidate_question)
|
106
|
+
answer_id = question.answers[0].id
|
107
|
+
|
108
|
+
assert_nil question.answered_at
|
109
|
+
question.ask
|
110
|
+
question.answer(answer_id)
|
111
|
+
assert_equal answered_at, question.answered_at
|
112
|
+
end
|
113
|
+
|
114
|
+
test "answer set given answer" do
|
115
|
+
question = FactoryGirl.build(:candidate_question)
|
116
|
+
answer_id = question.answers[0].id
|
117
|
+
|
118
|
+
question.ask
|
119
|
+
question.answer(answer_id)
|
120
|
+
assert_equal question.answers[0], question.given_answer
|
121
|
+
end
|
122
|
+
|
123
|
+
test "answer set state from asked to wrong" do
|
124
|
+
answers = [
|
125
|
+
FactoryGirl.build(:answer, :correct => false),
|
126
|
+
FactoryGirl.build(:answer, :correct => true)
|
127
|
+
]
|
128
|
+
|
129
|
+
question = FactoryGirl.build(:candidate_question, :question => FactoryGirl.build(:question, :answers => answers))
|
130
|
+
answer_id = question.answers[0].id
|
131
|
+
|
132
|
+
assert_equal :open, question.state
|
133
|
+
question.ask
|
134
|
+
question.answer(answer_id)
|
135
|
+
assert_equal :wrong, question.state
|
136
|
+
end
|
137
|
+
|
138
|
+
test "answer set state from asked to correct" do
|
139
|
+
answers = [
|
140
|
+
FactoryGirl.build(:answer, :correct => false),
|
141
|
+
FactoryGirl.build(:answer, :correct => true)
|
142
|
+
]
|
143
|
+
|
144
|
+
question = FactoryGirl.build(:candidate_question, :question => FactoryGirl.build(:question, :answers => answers))
|
145
|
+
answer_id = question.answers[1].id
|
146
|
+
|
147
|
+
assert_equal :open, question.state
|
148
|
+
question.ask
|
149
|
+
question.answer(answer_id)
|
150
|
+
assert_equal :correct, question.state
|
151
|
+
end
|
152
|
+
|
153
|
+
test "answer raise error if question already answered" do
|
154
|
+
question = FactoryGirl.build(:candidate_question)
|
155
|
+
answer_id = question.answers[0].id
|
156
|
+
|
157
|
+
question.ask
|
158
|
+
question.answer(answer_id)
|
159
|
+
|
160
|
+
assert_raises Barker::Errors::AlreadyAnsweredError do
|
161
|
+
question.answer(answer_id)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
test "answer raise error if answer could not be found" do
|
166
|
+
question = FactoryGirl.build(:candidate_question)
|
167
|
+
|
168
|
+
question.ask
|
169
|
+
|
170
|
+
assert_raises Barker::Errors::AnswerNotFoundError do
|
171
|
+
question.answer(Time.now.to_i)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
test "open?" do
|
176
|
+
assert FactoryGirl.build(:candidate_question).open?
|
177
|
+
end
|
178
|
+
|
179
|
+
test "asked?" do
|
180
|
+
assert FactoryGirl.build(:candidate_question, :asked_at => Time.now).asked?
|
181
|
+
end
|
182
|
+
|
183
|
+
test "answered?" do
|
184
|
+
assert FactoryGirl.build(:candidate_question, :answered_at => Time.now).answered?
|
185
|
+
end
|
186
|
+
|
187
|
+
test "correct?" do
|
188
|
+
answers = [
|
189
|
+
FactoryGirl.build(:answer, :correct => false),
|
190
|
+
FactoryGirl.build(:answer, :correct => true)
|
191
|
+
]
|
192
|
+
|
193
|
+
question = FactoryGirl.build(:candidate_question, :question => FactoryGirl.build(:question, :answers => answers))
|
194
|
+
answer_id = question.answers[1].id
|
195
|
+
|
196
|
+
question.ask
|
197
|
+
question.answer(answer_id)
|
198
|
+
|
199
|
+
assert question.correct?
|
200
|
+
refute question.wrong?
|
201
|
+
end
|
202
|
+
|
203
|
+
test "wrong?" do
|
204
|
+
answers = [
|
205
|
+
FactoryGirl.build(:answer, :correct => false),
|
206
|
+
FactoryGirl.build(:answer, :correct => true)
|
207
|
+
]
|
208
|
+
|
209
|
+
question = FactoryGirl.build(:candidate_question, :question => FactoryGirl.build(:question, :answers => answers))
|
210
|
+
answer_id = question.answers[0].id
|
211
|
+
|
212
|
+
question.ask
|
213
|
+
question.answer(answer_id)
|
214
|
+
|
215
|
+
refute question.correct?
|
216
|
+
assert question.wrong?
|
217
|
+
end
|
218
|
+
|
219
|
+
test "label fallback to en if candidate locale is missing" do
|
220
|
+
candidate = FactoryGirl.build(:candidate, :locale => 'wookie')
|
221
|
+
question = FactoryGirl.build(:candidate_question, :candidate => candidate, :question => FactoryGirl.build(:question, :label => {'en' => 'question in en'}))
|
222
|
+
assert_equal 'question in en', question.label
|
223
|
+
end
|
224
|
+
|
225
|
+
test "translate label in candidate locale" do
|
226
|
+
candidate = FactoryGirl.build(:candidate, :locale => 'wookie')
|
227
|
+
question = FactoryGirl.build(:candidate_question, :candidate => candidate, :question => FactoryGirl.build(:question, :label => {'en' => 'question in en', 'wookie' => 'woo arrr uuur'}))
|
228
|
+
assert_equal 'woo arrr uuur', question.label
|
229
|
+
end
|
230
|
+
|
231
|
+
test "timer nil by default" do
|
232
|
+
question = FactoryGirl.build(:candidate_question)
|
233
|
+
assert_equal nil, question.timer
|
234
|
+
refute question.timeout?
|
235
|
+
end
|
236
|
+
|
237
|
+
test "optional timer" do
|
238
|
+
question = FactoryGirl.build(:candidate_question, :timer => 20)
|
239
|
+
assert_equal 20, question.timer
|
240
|
+
refute question.timeout?
|
241
|
+
end
|
242
|
+
|
243
|
+
test "timeout?" do
|
244
|
+
answers = [
|
245
|
+
FactoryGirl.build(:answer, :correct => false),
|
246
|
+
FactoryGirl.build(:answer, :correct => true)
|
247
|
+
]
|
248
|
+
|
249
|
+
question = FactoryGirl.build(:candidate_question, :question => FactoryGirl.build(:question, :answers => answers), :timer => 20)
|
250
|
+
answer_id = question.answers[0].id
|
251
|
+
|
252
|
+
asked_at = Time.now
|
253
|
+
Time.stubs(:now).returns(asked_at)
|
254
|
+
|
255
|
+
assert_equal 20, question.time_left
|
256
|
+
refute question.timeout?
|
257
|
+
|
258
|
+
question.ask
|
259
|
+
|
260
|
+
assert_equal 20, question.time_left
|
261
|
+
refute question.timeout?
|
262
|
+
|
263
|
+
answered_at = asked_at + 22
|
264
|
+
Time.stubs(:now).returns(answered_at)
|
265
|
+
question.answer(answer_id)
|
266
|
+
|
267
|
+
assert_equal 0, question.time_left
|
268
|
+
assert question.timeout?
|
269
|
+
end
|
270
|
+
|
271
|
+
private
|
272
|
+
|
273
|
+
let(:candidate) { FactoryGirl.build(:candidate) }
|
274
|
+
let(:question) { FactoryGirl.build(:question) }
|
275
|
+
|
276
|
+
end
|
277
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Barker
|
4
|
+
class CandidateRoundRest < Spec
|
5
|
+
|
6
|
+
test "interface" do
|
7
|
+
Barker::CandidateRound.new(candidate, round)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "candidate_question" do
|
11
|
+
candidate_round = Barker::CandidateRound.new(round.candidates.first, round)
|
12
|
+
candidate_question = candidate_round.question
|
13
|
+
|
14
|
+
assert_kind_of CandidateQuestion, candidate_question
|
15
|
+
assert_equal round.question, candidate_question.question
|
16
|
+
assert_equal round.candidates.first, candidate_question.candidate
|
17
|
+
end
|
18
|
+
|
19
|
+
test "ask delegation" do
|
20
|
+
candidate_round = CandidateRound.new(nil, nil)
|
21
|
+
question = Minitest::Mock.new
|
22
|
+
|
23
|
+
question.expect(:ask, :candidate_question, [{}])
|
24
|
+
|
25
|
+
candidate_round.stub :question, question do
|
26
|
+
assert_equal :candidate_question, candidate_round.ask
|
27
|
+
end
|
28
|
+
|
29
|
+
assert question.verify
|
30
|
+
end
|
31
|
+
|
32
|
+
test "answer delegation" do
|
33
|
+
candidate_round = CandidateRound.new(nil, nil)
|
34
|
+
question = Minitest::Mock.new
|
35
|
+
|
36
|
+
question.expect(:answer, :candidate_answer, [12])
|
37
|
+
|
38
|
+
candidate_round.stub :question, question do
|
39
|
+
assert_equal :candidate_answer, candidate_round.answer(12)
|
40
|
+
end
|
41
|
+
|
42
|
+
assert question.verify
|
43
|
+
end
|
44
|
+
|
45
|
+
test "given answer delegation" do
|
46
|
+
candidate_round = CandidateRound.new(nil, nil)
|
47
|
+
question = Minitest::Mock.new
|
48
|
+
|
49
|
+
question.expect(:given_answer, :candidate_answer)
|
50
|
+
|
51
|
+
candidate_round.stub :question, question do
|
52
|
+
assert_equal :candidate_answer, candidate_round.given_answer
|
53
|
+
end
|
54
|
+
|
55
|
+
assert question.verify
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
let(:round) { FactoryGirl.build :round }
|
61
|
+
let(:candidate) { round.candidates[0] }
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
class CandidateTest < Spec
|
5
|
+
test "has id" do
|
6
|
+
assert_kind_of Numeric, candidate.id
|
7
|
+
end
|
8
|
+
|
9
|
+
test "has locale" do
|
10
|
+
assert_equal "en", candidate.locale
|
11
|
+
end
|
12
|
+
|
13
|
+
test "joined_at" do
|
14
|
+
joined_at = Time.now
|
15
|
+
Time.stubs(:now).returns(joined_at)
|
16
|
+
|
17
|
+
refute candidate.joined_at
|
18
|
+
candidate.join
|
19
|
+
assert_equal joined_at, candidate.joined_at
|
20
|
+
end
|
21
|
+
|
22
|
+
test "leaved_at" do
|
23
|
+
leaved_at = Time.now
|
24
|
+
Time.stubs(:now).returns(leaved_at)
|
25
|
+
|
26
|
+
refute candidate.leaved_at
|
27
|
+
candidate.leave
|
28
|
+
assert_equal leaved_at, candidate.leaved_at
|
29
|
+
end
|
30
|
+
|
31
|
+
test "aborted_at" do
|
32
|
+
aborted_at = Time.now
|
33
|
+
Time.stubs(:now).returns(aborted_at)
|
34
|
+
|
35
|
+
refute candidate.aborted_at
|
36
|
+
candidate.abort
|
37
|
+
assert_equal aborted_at, candidate.aborted_at
|
38
|
+
end
|
39
|
+
|
40
|
+
test "joined?" do
|
41
|
+
refute candidate.joined?
|
42
|
+
candidate.join
|
43
|
+
assert candidate.joined?
|
44
|
+
end
|
45
|
+
|
46
|
+
test "leaved?" do
|
47
|
+
refute candidate.leaved?
|
48
|
+
candidate.leave
|
49
|
+
assert candidate.leaved?
|
50
|
+
end
|
51
|
+
|
52
|
+
test "aborted?" do
|
53
|
+
refute candidate.aborted?
|
54
|
+
candidate.abort
|
55
|
+
assert candidate.aborted?
|
56
|
+
end
|
57
|
+
|
58
|
+
test "candidate_id" do
|
59
|
+
assert_equal candidate.id, candidate.candidate_id
|
60
|
+
end
|
61
|
+
|
62
|
+
context "error" do
|
63
|
+
test "object has to respond to id" do
|
64
|
+
assert_raises Barker::Errors::HasToRespondToIdError do
|
65
|
+
candidate_without_id.id
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
test "object has to respond to locale" do
|
70
|
+
assert_raises Barker::Errors::HasToRespondToLocaleError do
|
71
|
+
candidate_without_locale.locale
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|