chiketto 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb292f89caf8ed73a2243fb2cdc35898fbde4dea
4
- data.tar.gz: 319b27db4b751daf9c1421a74dcddb251a65ef44
3
+ metadata.gz: 4fe182668f0ba773e90ca1d3e00e0891f7b29fd0
4
+ data.tar.gz: 5366c09c37057e93db34ca46208d02613c43886e
5
5
  SHA512:
6
- metadata.gz: 88550de3fb39bcadbc0c193eae7c2ca75c3ee4354a4b4999280dd28ee69b326e42ca30cfcd0634bd8feef3c87a5954bc852d5f969608067f7bc11dbf2c4685d1
7
- data.tar.gz: 073ba811c4a4f630e2e50c7cbc72c716917863fad46d5e8d5ae26a35db6f59ad8bfb066761811cf22299caed73f2aa00513e6df558c2d91655c1bde08a34b7d3
6
+ metadata.gz: f47071f3bb35e426d06630f58c1f468121300fbbc4b684f90f59b595128c47c2edbbceab47a2db62b44579d49802e0c90a50cc2d33e21d18c8835114c4fa1da3
7
+ data.tar.gz: 70842e569625439e1828b5f51eda7e95793766f1c7d558e981406c3b94b078286deecc885c895c09b26d27c5489bef5406443788692aa022eabfb3ec48761d63
data/lib/chiketto.rb CHANGED
@@ -13,6 +13,8 @@ module Chiketto
13
13
  require 'chiketto/attendee_profile'
14
14
  require 'chiketto/category'
15
15
  require 'chiketto/email'
16
+ require 'chiketto/choice'
17
+ require 'chiketto/question'
16
18
  require 'chiketto/event'
17
19
  require 'chiketto/organizer'
18
20
  require 'chiketto/ticket_class'
@@ -0,0 +1,5 @@
1
+ module Chiketto
2
+ class Choice < Resource
3
+ attr_attrib :answer
4
+ end
5
+ end
@@ -46,6 +46,11 @@ module Chiketto
46
46
  !!@listed
47
47
  end
48
48
 
49
+ def questions
50
+ questions = Event.find_questions id
51
+ questions.map { |question| Question.new question }
52
+ end
53
+
49
54
  def organizer
50
55
  Organizer.new @organizer.to_h
51
56
  end
@@ -75,7 +80,11 @@ module Chiketto
75
80
 
76
81
  private
77
82
 
78
- def self.find_attendees(id, params)
83
+ def self.find_questions(id, params = {})
84
+ get "events/#{id}/questions", params
85
+ end
86
+
87
+ def self.find_attendees(id, params = {})
79
88
  get "events/#{id}/attendees", params
80
89
  end
81
90
 
@@ -0,0 +1,11 @@
1
+ module Chiketto
2
+ class Question < Resource
3
+ attr_accessor :type, :required, :respondent
4
+
5
+ attr_attrib :question
6
+
7
+ def choices
8
+ @choices.map { |choice| Choice.new choice }
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Chiketto
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class ChoiceTest < MiniTest::Test
4
+ def setup
5
+ @choice = Chiketto::Choice.new 'answer' => {
6
+ 'text' => 'test choice',
7
+ 'html' => '<p>test choice</p>'
8
+ },
9
+ 'id' => '123456'
10
+ end
11
+
12
+ def test_responds_to_methods
13
+ assert_respond_to @choice, :answer
14
+ assert_respond_to @choice, :id
15
+ end
16
+
17
+ def test_answer_is_an_attribute
18
+ assert_respond_to @choice.answer, :html
19
+ assert_respond_to @choice.answer, :text
20
+ end
21
+ end
data/test/event_test.rb CHANGED
@@ -42,6 +42,7 @@ class EventTest < MiniTest::Test
42
42
  assert_respond_to @event, :listed?
43
43
  assert_respond_to @event, :logo
44
44
  assert_respond_to @event, :logo_url
45
+ assert_respond_to @event, :questions
45
46
  end
46
47
 
47
48
  def test_name_attribute_is_valid
@@ -63,6 +64,15 @@ class EventTest < MiniTest::Test
63
64
  assert_kind_of Chiketto::Category, @event.category
64
65
  assert_kind_of Chiketto::Category, @event.subcategory
65
66
  end
67
+
68
+ def test_questions_are_objects
69
+ find_event
70
+ VCR.use_cassette 'event-questions' do
71
+ assert_kind_of Array, @event.questions
72
+ assert_kind_of Chiketto::Question, @event.questions.first
73
+ end
74
+ end
75
+
66
76
  def test_organizer_is_object
67
77
  find_event
68
78
  assert_kind_of Chiketto::Organizer, @event.organizer
@@ -21,13 +21,6 @@ class OrganizerTest < MiniTest::Test
21
21
  assert_respond_to @organizer.description, :text
22
22
  end
23
23
 
24
- # def test_can_create_new_organizer
25
- # VCR.use_cassette 'organizer-create-new' do
26
- # organizer = Chiketto::Organizer.create name: 'New Organizer'
27
- # assert_kind_of Fixnum, organizer
28
- # end
29
- # end
30
-
31
24
  def test_cannot_create_an_existing_organizer
32
25
  VCR.use_cassette 'organizer-create' do
33
26
  assert_raises RuntimeError do
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ class QuestionTest < MiniTest::Test
4
+ def setup
5
+ @question = Chiketto::Question.new 'question' => {
6
+ 'text' => 'test question',
7
+ 'html' => '<p>test question</p>'
8
+ },
9
+ 'id' => '123456',
10
+ 'type' => 'checkbox',
11
+ 'required' => true,
12
+ 'respondent' => 'attendee'
13
+ end
14
+
15
+ def test_responds_to_methods
16
+ assert_respond_to @question, :question
17
+ assert_respond_to @question, :type
18
+ assert_respond_to @question, :required
19
+ assert_respond_to @question, :respondent
20
+ assert_respond_to @question, :id
21
+ end
22
+
23
+ def test_answer_is_an_attribute
24
+ assert_respond_to @question.answer, :html
25
+ assert_respond_to @question.answer, :text
26
+ end
27
+
28
+ def test_required_is_boolean
29
+ assert_kind_of TrueClass, @question.required
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chiketto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Radford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,9 +115,11 @@ files:
115
115
  - lib/chiketto/attr_attribute.rb
116
116
  - lib/chiketto/attribute.rb
117
117
  - lib/chiketto/category.rb
118
+ - lib/chiketto/choice.rb
118
119
  - lib/chiketto/email.rb
119
120
  - lib/chiketto/event.rb
120
121
  - lib/chiketto/organizer.rb
122
+ - lib/chiketto/question.rb
121
123
  - lib/chiketto/resource.rb
122
124
  - lib/chiketto/ticket_class.rb
123
125
  - lib/chiketto/user.rb
@@ -130,9 +132,11 @@ files:
130
132
  - test/attribute_test.rb
131
133
  - test/category_test.rb
132
134
  - test/chiketto_test.rb
135
+ - test/choice_test.rb
133
136
  - test/email_test.rb
134
137
  - test/event_test.rb
135
138
  - test/organizer_test.rb
139
+ - test/question.test.rb
136
140
  - test/test_helper.rb
137
141
  - test/ticket_class_test.rb
138
142
  - test/user_test.rb
@@ -168,10 +172,13 @@ test_files:
168
172
  - test/attribute_test.rb
169
173
  - test/category_test.rb
170
174
  - test/chiketto_test.rb
175
+ - test/choice_test.rb
171
176
  - test/email_test.rb
172
177
  - test/event_test.rb
173
178
  - test/organizer_test.rb
179
+ - test/question.test.rb
174
180
  - test/test_helper.rb
175
181
  - test/ticket_class_test.rb
176
182
  - test/user_test.rb
177
183
  - test/venue_test.rb
184
+ has_rdoc: