barker 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 984796895fe9bc71b1d2ce82ea679d7fe75f78ae
4
- data.tar.gz: c987d3c1af4e2662bfd0b416610bfcb24426bc0f
3
+ metadata.gz: 4bf2da58c1e96e4df0a94d949c7ff4c707c6b5e0
4
+ data.tar.gz: cc809a8256703900766ce90aa96639c91fe05ba7
5
5
  SHA512:
6
- metadata.gz: 3c0da2c756ae07411f8a08151a6e733f88aedddd82d4015746cff8c08276a784da35769191fcf54b63ce69bb247384c9301fcb080d3798db22db6872d2206f9e
7
- data.tar.gz: 64de935ceff6389621d30888bc389e4520f0212f800f42975cd395f35dad9d8726a638ed943b51d72f6aaf3a27ffca256d6912eaa3b3e5d66485ce0a2e5194ab
6
+ metadata.gz: 52f937800cdcb5bbda1f66ad9909a3c8871ab6dfbbe8ac80b2b871af1552c1880bd6397e0168a2e320a3fc11002b54531a23753b0e29b4388055a63e808f520a
7
+ data.tar.gz: 6fd93f9fd4d3821084f1da8ef2bd40272cce9fafb1c5b0d64fa800b5e60b8be7bc2304ad4b56f69d1d57553582a76e36c6d968a217b15bcda0cc4438e470a330
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- barker (0.2.2)
4
+ barker (0.2.3)
5
5
  activemodel
6
6
  activesupport
7
7
  thread_safe
@@ -14,12 +14,16 @@ module Barker
14
14
  game_show.rounds.map {|round| Response::Round.new(:round => round)}
15
15
  end
16
16
 
17
+ def jokers
18
+ game_show.jokers.map {|joker| Response::Joker.new(:joker => joker)}
19
+ end
20
+
17
21
  def to_hash
18
22
  {
19
23
  'id' => id,
20
24
  'game_show_id' => game_show_id,
21
- 'joker_ids' => joker_ids,
22
25
  'jokers' => jokers.map(&:to_hash),
26
+ 'joker_ids' => joker_ids,
23
27
  'started_at' => to_i(started_at),
24
28
  'finished_at' => to_i(finished_at),
25
29
  'aborted_at' => to_i(aborted_at),
@@ -0,0 +1,19 @@
1
+ module Barker
2
+ module Api
3
+ module Response
4
+ class Joker < Base
5
+
6
+ extend Forwardable
7
+ def_delegators :joker, :id, :joker_id
8
+
9
+ def to_hash
10
+ {
11
+ 'id' => id,
12
+ 'joker_id' => joker_id
13
+ }
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -2,6 +2,7 @@ require 'barker/api/response/base'
2
2
  require 'barker/api/response/error'
3
3
  require 'barker/api/response/game_show'
4
4
  require 'barker/api/response/round'
5
+ require 'barker/api/response/joker'
5
6
  require 'barker/api/response/candidate'
6
7
  require 'barker/api/response/candidate_question'
7
8
  require 'barker/api/response/candidate_answer'
data/lib/barker/joker.rb CHANGED
@@ -6,6 +6,10 @@ module Barker
6
6
  @id = id
7
7
  end
8
8
 
9
+ def joker_id
10
+ @id
11
+ end
12
+
9
13
  def call(candidate_question)
10
14
  "Barker::Jokers::#{id.to_s.classify}".constantize.call(candidate_question)
11
15
  end
@@ -1,3 +1,3 @@
1
1
  module Barker
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -34,7 +34,6 @@ module Barker
34
34
  assert result.has_key? 'id'
35
35
  assert result.has_key? 'game_show_id'
36
36
  assert result.has_key? 'joker_ids'
37
- assert result.has_key? 'jokers'
38
37
  assert result.has_key? 'started_at'
39
38
  assert result.has_key? 'finished_at'
40
39
  assert result.has_key? 'aborted_at'
@@ -55,6 +54,8 @@ module Barker
55
54
 
56
55
  assert_kind_of Array, result['rounds']
57
56
  assert_kind_of Hash, result['rounds'][0]
57
+
58
+ assert_kind_of Array, result['jokers']
58
59
  end
59
60
 
60
61
  test "delegate" do
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ module Barker
4
+ module Api
5
+ module Response
6
+ class JokerTest < Spec
7
+
8
+ test "instance" do
9
+ assert_kind_of Barker::Api::Response::Joker, klass.new
10
+ end
11
+
12
+ test "inherit from base" do
13
+ assert klass < Barker::Api::Response::Base
14
+ end
15
+
16
+ test "joker" do
17
+ assert_equal joker, subject.joker
18
+ end
19
+
20
+ test "delegate" do
21
+ assert_delegate :id
22
+ assert_delegate :joker_id
23
+ end
24
+
25
+ test "to_hash" do
26
+ result = subject.to_hash
27
+ assert_kind_of Hash, result
28
+
29
+ assert result.has_key? 'id'
30
+ assert result.has_key? 'joker_id'
31
+ end
32
+
33
+ private
34
+
35
+ def assert_delegate(method)
36
+ assert joker.respond_to?(method), "Joker should respond to #{method}"
37
+ assert subject.respond_to?(method), "Response::Joker should respond to #{method}"
38
+ assert_equal joker.send(method), subject.send(method), "Joker##{method} != Response::Joker##{method}"
39
+ end
40
+
41
+ def klass
42
+ Barker::Api::Response::Joker
43
+ end
44
+
45
+ def subject
46
+ klass.new(:joker => joker)
47
+ end
48
+
49
+ def joker
50
+ @joker ||= FactoryGirl.build :joker
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Owiesniak
@@ -152,6 +152,7 @@ files:
152
152
  - lib/barker/api/response/candidate_question.rb
153
153
  - lib/barker/api/response/error.rb
154
154
  - lib/barker/api/response/game_show.rb
155
+ - lib/barker/api/response/joker.rb
155
156
  - lib/barker/api/response/round.rb
156
157
  - lib/barker/candidate.rb
157
158
  - lib/barker/candidate_answer.rb
@@ -202,6 +203,7 @@ files:
202
203
  - test/unit/api/response/candidate_question_test.rb
203
204
  - test/unit/api/response/candidate_test.rb
204
205
  - test/unit/api/response/game_show_test.rb
206
+ - test/unit/api/response/joker_test.rb
205
207
  - test/unit/api/response/round_test.rb
206
208
  - test/unit/candidate_answer_test.rb
207
209
  - test/unit/candidate_question_test.rb
@@ -265,6 +267,7 @@ test_files:
265
267
  - test/unit/api/response/candidate_question_test.rb
266
268
  - test/unit/api/response/candidate_test.rb
267
269
  - test/unit/api/response/game_show_test.rb
270
+ - test/unit/api/response/joker_test.rb
268
271
  - test/unit/api/response/round_test.rb
269
272
  - test/unit/candidate_answer_test.rb
270
273
  - test/unit/candidate_question_test.rb