gather_content-api 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +7 -0
  3. data/README.md +161 -35
  4. data/gather_content-api.gemspec +1 -1
  5. data/lib/gather_content.rb +2 -0
  6. data/lib/gather_content/api.rb +16 -15
  7. data/lib/gather_content/config.rb +9 -0
  8. data/lib/gather_content/config/builder.rb +20 -0
  9. data/lib/gather_content/config/elements.rb +15 -0
  10. data/lib/gather_content/config/elements/base.rb +32 -0
  11. data/lib/gather_content/config/elements/choice_checkbox.rb +32 -0
  12. data/lib/gather_content/config/elements/choice_radio.rb +62 -0
  13. data/lib/gather_content/config/elements/files.rb +17 -0
  14. data/lib/gather_content/config/elements/option.rb +30 -0
  15. data/lib/gather_content/config/elements/other_option.rb +26 -0
  16. data/lib/gather_content/config/elements/section.rb +31 -0
  17. data/lib/gather_content/config/elements/text.rb +32 -0
  18. data/lib/gather_content/config/tab.rb +30 -0
  19. data/lib/gather_content/config/tabs.rb +13 -0
  20. data/lib/gather_content/dsl.rb +15 -0
  21. data/lib/gather_content/dsl/base.rb +28 -0
  22. data/lib/gather_content/dsl/choice_checkbox.rb +19 -0
  23. data/lib/gather_content/dsl/choice_radio.rb +25 -0
  24. data/lib/gather_content/dsl/config.rb +16 -0
  25. data/lib/gather_content/dsl/files.rb +12 -0
  26. data/lib/gather_content/dsl/option.rb +29 -0
  27. data/lib/gather_content/dsl/other_option.rb +18 -0
  28. data/lib/gather_content/dsl/section.rb +24 -0
  29. data/lib/gather_content/dsl/tab.rb +54 -0
  30. data/lib/gather_content/dsl/text.rb +29 -0
  31. data/lib/gather_content/error.rb +1 -1
  32. data/lib/gather_content/version.rb +1 -1
  33. data/spec/gather_content/config/builder_spec.rb +42 -0
  34. data/spec/gather_content/config/elements/choice_checkbox_spec.rb +78 -0
  35. data/spec/gather_content/config/elements/choice_radio_spec.rb +175 -0
  36. data/spec/gather_content/config/elements/files_spec.rb +23 -0
  37. data/spec/gather_content/config/elements/option_spec.rb +88 -0
  38. data/spec/gather_content/config/elements/other_option_spec.rb +124 -0
  39. data/spec/gather_content/config/elements/section_spec.rb +80 -0
  40. data/spec/gather_content/config/elements/text_spec.rb +163 -0
  41. data/spec/gather_content/config/tab_spec.rb +120 -0
  42. data/spec/gather_content/dsl/choice_checkbox_spec.rb +25 -0
  43. data/spec/gather_content/dsl/choice_radio_spec.rb +47 -0
  44. data/spec/gather_content/dsl/files_spec.rb +12 -0
  45. data/spec/gather_content/dsl/section_spec.rb +37 -0
  46. data/spec/gather_content/dsl/tab_spec.rb +107 -0
  47. data/spec/gather_content/dsl/text_spec.rb +48 -0
  48. data/spec/spec_helper.rb +1 -1
  49. data/spec/support/shared_examples/dsl.rb +63 -0
  50. data/spec/support/shared_examples/element.rb +77 -0
  51. metadata +63 -4
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'gather_content/config/tab'
3
+ require 'gather_content/dsl/choice_checkbox'
4
+
5
+ RSpec.describe GatherContent::DSL::ChoiceCheckbox do
6
+ let(:tab) { GatherContent::Config::Tab.new }
7
+ let(:dsl) { GatherContent::DSL::ChoiceCheckbox.new(tab) }
8
+
9
+ subject { tab.elements.first }
10
+
11
+ it_behaves_like "a Gather Content DSL"
12
+
13
+ context "setting the options" do
14
+ before(:each) do
15
+ dsl.option do
16
+ name "option_1"
17
+ label "Option 1"
18
+ end
19
+ end
20
+
21
+ it "stores the options in the tab element" do
22
+ expect(subject.options.first).to be_instance_of(GatherContent::Config::Element::Option)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'gather_content/config/tab'
3
+ require 'gather_content/dsl/choice_radio'
4
+
5
+ RSpec.describe GatherContent::DSL::ChoiceRadio do
6
+ let(:tab) { GatherContent::Config::Tab.new }
7
+ let(:dsl) { GatherContent::DSL::ChoiceRadio.new(tab) }
8
+
9
+ subject { tab.elements.first }
10
+
11
+ it_behaves_like "a Gather Content DSL"
12
+
13
+ context "setting the options" do
14
+ before(:each) do
15
+ dsl.option do
16
+ name "option_1"
17
+ label "Option 1"
18
+ end
19
+ end
20
+
21
+ it "stores the options in choice radio" do
22
+ expect(subject.options.first).to be_instance_of(GatherContent::Config::Element::Option)
23
+ end
24
+ end
25
+
26
+ context "setting the other_option" do
27
+ before(:each) do
28
+ dsl.other_option do
29
+ name "option_1"
30
+ label "Option 1"
31
+ value "value"
32
+ end
33
+ dsl.option do
34
+ name "option_1"
35
+ label "Option 1"
36
+ end
37
+ end
38
+
39
+ it "store the option as the last option" do
40
+ expect(subject.options.last).to be_instance_of(GatherContent::Config::Element::OtherOption)
41
+ end
42
+
43
+ it "sets other_option to true" do
44
+ expect(subject.other_option).to eq(true)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'gather_content/config/tab'
3
+ require 'gather_content/dsl/files'
4
+
5
+ RSpec.describe GatherContent::DSL::Files do
6
+ let(:tab) { GatherContent::Config::Tab.new }
7
+ let(:dsl) { GatherContent::DSL::Files.new(tab) }
8
+
9
+ subject { tab.elements.first }
10
+
11
+ it_behaves_like "a Gather Content DSL"
12
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'gather_content/config/tab'
3
+ require 'gather_content/dsl/section'
4
+
5
+ RSpec.describe GatherContent::DSL::Section do
6
+ let(:tab) { GatherContent::Config::Tab.new }
7
+ let(:dsl) { GatherContent::DSL::Section.new(tab) }
8
+
9
+ subject { tab.elements.first }
10
+
11
+ context "setting the name" do
12
+ let(:name) { "New Section" }
13
+ before(:each) { dsl.name(name) }
14
+
15
+ it "stores the name in the tab element" do
16
+ expect(subject.name).to eq(name)
17
+ end
18
+ end
19
+
20
+ context "setting the title" do
21
+ let(:title) { "Section Title" }
22
+ before(:each) { dsl.title(title) }
23
+
24
+ it "stores the title in the tab element" do
25
+ expect(subject.title).to eq(title)
26
+ end
27
+ end
28
+
29
+ context "setting the subtitle" do
30
+ let(:subtitle) { "Section Subtitle" }
31
+ before(:each) { dsl.subtitle(subtitle) }
32
+
33
+ it "stores the subtitle in the tab element" do
34
+ expect(subject.subtitle).to eq(subtitle)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+ require 'gather_content/config/builder'
3
+ require 'gather_content/dsl/tab'
4
+ require 'gather_content/config/elements/text'
5
+ require 'gather_content/config/elements/files'
6
+ require 'gather_content/config/elements/choice_checkbox'
7
+ require 'gather_content/config/elements/choice_radio'
8
+ require 'gather_content/config/elements/section'
9
+
10
+ RSpec.describe GatherContent::DSL::Text do
11
+ let(:builder) { GatherContent::Config::Builder.new }
12
+ let(:dsl) { GatherContent::DSL::Tab.new(builder) }
13
+
14
+ subject { builder.tabs.first }
15
+
16
+ context "setting the label" do
17
+ let(:label) { "Label" }
18
+ before(:each) { dsl.label(label) }
19
+
20
+ it "stores the label in the builder" do
21
+ expect(subject.label).to eq(label)
22
+ end
23
+ end
24
+
25
+ context "setting the name" do
26
+ let(:name) { "Name" }
27
+ before(:each) { dsl.name(name) }
28
+
29
+ it "stores the name in the builder" do
30
+ expect(subject.name).to eq(name)
31
+ end
32
+ end
33
+
34
+ context "setting the hidden flag" do
35
+ let(:hidden) { true }
36
+ before(:each) { dsl.hidden(hidden) }
37
+
38
+ it "stores the hidden flag in the builder" do
39
+ expect(subject.hidden).to eq(hidden)
40
+ end
41
+ end
42
+
43
+ context "adding a text element" do
44
+ before(:each) do
45
+ dsl.text do
46
+ label "text_label"
47
+ name "Text Label"
48
+ end
49
+ end
50
+
51
+ it "adds the text element to the tab" do
52
+ expect(subject.elements.first).to be_instance_of(GatherContent::Config::Element::Text)
53
+ end
54
+ end
55
+
56
+ context "adding a files element" do
57
+ before(:each) do
58
+ dsl.files do
59
+ label "files_label"
60
+ name "Files Label"
61
+ end
62
+ end
63
+
64
+ it "adds the files element to the tab" do
65
+ expect(subject.elements.first).to be_instance_of(GatherContent::Config::Element::Files)
66
+ end
67
+ end
68
+
69
+ context "adding a choice_radio element" do
70
+ before(:each) do
71
+ dsl.choice_radio do
72
+ label "choice_radio_label"
73
+ name "Choice Radio Label"
74
+ end
75
+ end
76
+
77
+ it "adds the choice_radio element to the tab" do
78
+ expect(subject.elements.first).to be_instance_of(GatherContent::Config::Element::ChoiceRadio)
79
+ end
80
+ end
81
+
82
+ context "adding a choice_checkbox element" do
83
+ before(:each) do
84
+ dsl.choice_checkbox do
85
+ label "choice_checkbox_label"
86
+ name "Choice Checkbox Label"
87
+ end
88
+ end
89
+
90
+ it "adds the choice_checkbox element to the tab" do
91
+ expect(subject.elements.first).to be_instance_of(GatherContent::Config::Element::ChoiceCheckbox)
92
+ end
93
+ end
94
+
95
+ context "adding a section element" do
96
+ before(:each) do
97
+ dsl.section do
98
+ name "section"
99
+ title "Title"
100
+ end
101
+ end
102
+
103
+ it "adds the section element to the tab" do
104
+ expect(subject.elements.first).to be_instance_of(GatherContent::Config::Element::Section)
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'gather_content/config/tab'
3
+ require 'gather_content/dsl/text'
4
+
5
+ RSpec.describe GatherContent::DSL::Text do
6
+ let(:tab) { GatherContent::Config::Tab.new }
7
+ let(:dsl) { GatherContent::DSL::Text.new(tab) }
8
+
9
+ subject { tab.elements.first }
10
+
11
+ it_behaves_like "a Gather Content DSL"
12
+
13
+ context "setting the value" do
14
+ let(:value) { "Value" }
15
+ before(:each) { dsl.value(value) }
16
+
17
+ it "stores the value in the tab element" do
18
+ expect(subject.value).to eq(value)
19
+ end
20
+ end
21
+
22
+ context "setting the limit_type" do
23
+ let(:limit_type) { :char }
24
+ before(:each) { dsl.limit_type(limit_type) }
25
+
26
+ it "stores the limit_type in the tab element" do
27
+ expect(subject.limit_type).to eq(limit_type)
28
+ end
29
+ end
30
+
31
+ context "setting the limit" do
32
+ let(:limit) { 2000 }
33
+ before(:each) { dsl.limit(limit) }
34
+
35
+ it "stores the limit in the tab element" do
36
+ expect(subject.limit).to eq(limit)
37
+ end
38
+ end
39
+
40
+ context "setting the plain_text flag" do
41
+ let(:plain_text) { true }
42
+ before(:each) { dsl.plain_text(plain_text) }
43
+
44
+ it "stores the plain_text in the tab element" do
45
+ expect(subject.plain_text).to eq(plain_text)
46
+ end
47
+ end
48
+ end
@@ -2,7 +2,7 @@ require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
4
  $: << "#{File.dirname(__FILE__)}/../lib"
5
- Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f}
5
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
6
6
 
7
7
  require 'pry'
8
8
  require 'vcr'
@@ -0,0 +1,63 @@
1
+ RSpec.shared_examples "a Gather Content DSL" do
2
+ context "setting the name" do
3
+ let(:name) { "New Section" }
4
+ before(:each) { dsl.name(name) }
5
+
6
+ it "stores the name in the tab element" do
7
+ expect(subject.name).to eq(name)
8
+ end
9
+ end
10
+
11
+ context "setting the label" do
12
+ let(:label) { "Label" }
13
+ before(:each) { dsl.label(label) }
14
+
15
+ it "stores the label in the tab element" do
16
+ expect(subject.label).to eq(label)
17
+ end
18
+ end
19
+
20
+ context "setting required" do
21
+ let(:required) { true }
22
+ before(:each) { dsl.required(required) }
23
+
24
+ it "stores the required flag in the tab element" do
25
+ expect(subject.required).to eq(required)
26
+ end
27
+ end
28
+
29
+ context "setting the microcopy" do
30
+ let(:microcopy) { "Microcopy" }
31
+ before(:each) { dsl.microcopy(microcopy) }
32
+
33
+ it "stores the microcopy in the tab element" do
34
+ expect(subject.microcopy).to eq(microcopy)
35
+ end
36
+ end
37
+ end
38
+
39
+ RSpec.shared_examples "Gather Content Defaults" do
40
+ context "name" do
41
+ it "is a blank string" do
42
+ expect(subject.name).to eq("")
43
+ end
44
+ end
45
+
46
+ context "label" do
47
+ it "is a blank string" do
48
+ expect(subject.label).to eq("")
49
+ end
50
+ end
51
+
52
+ context "required" do
53
+ it "is false" do
54
+ expect(subject.required).to eq(false)
55
+ end
56
+ end
57
+
58
+ context "microcopy" do
59
+ it "is a blank string" do
60
+ expect(subject.microcopy).to eq("")
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,77 @@
1
+ RSpec.shared_examples "a Gather Content Element" do |type|
2
+ it "has the correct type" do
3
+ expect(subject[:type]).to eq(type)
4
+ end
5
+
6
+ context "a valid section instance" do
7
+ it "has a name" do
8
+ expect(subject[:name]).to eq(name)
9
+ end
10
+
11
+ it "has a required flag" do
12
+ expect(subject[:required]).to eq(required)
13
+ end
14
+
15
+ it "has a label" do
16
+ expect(subject[:label]).to eq(label)
17
+ end
18
+
19
+ it "has microcopy" do
20
+ expect(subject[:microcopy]).to eq(microcopy)
21
+ end
22
+ end
23
+
24
+ context "with an empty name" do
25
+ let(:name) { "" }
26
+
27
+ it "raises a ArgumentError" do
28
+ expect {
29
+ subject
30
+ }.to raise_error(ArgumentError)
31
+ end
32
+ end
33
+
34
+ context "with an empty label" do
35
+ let(:label) { "" }
36
+
37
+ it "raises a ArgumentError" do
38
+ expect {
39
+ subject
40
+ }.to raise_error(ArgumentError)
41
+ end
42
+ end
43
+
44
+ context "required" do
45
+ context "is true" do
46
+ let(:required) { true }
47
+
48
+ it "compiles to true" do
49
+ expect(subject[:required]).to eq(true)
50
+ end
51
+ end
52
+
53
+ context "is false" do
54
+ let(:required) { false }
55
+
56
+ it "compiles to false" do
57
+ expect(subject[:required]).to eq(false)
58
+ end
59
+ end
60
+
61
+ context "is truthy" do
62
+ let(:required) { "I'm a string!" }
63
+
64
+ it "compiles to true" do
65
+ expect(subject[:required]).to eq(true)
66
+ end
67
+ end
68
+
69
+ context "is falsey" do
70
+ let(:required) { nil }
71
+
72
+ it "compiles to false" do
73
+ expect(subject[:required]).to eq(false)
74
+ end
75
+ end
76
+ end
77
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gather_content-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barnaby Alter
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-02 00:00:00.000000000 Z
12
+ date: 2018-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -18,7 +18,7 @@ dependencies:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '10'
21
- type: :runtime
21
+ type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
@@ -64,6 +64,7 @@ files:
64
64
  - ".gitignore"
65
65
  - ".travis.yml"
66
66
  - Gemfile
67
+ - MIT-LICENSE
67
68
  - README.md
68
69
  - Rakefile
69
70
  - gather_content-api.gemspec
@@ -84,6 +85,30 @@ files:
84
85
  - lib/gather_content/api/statuses.rb
85
86
  - lib/gather_content/api/template.rb
86
87
  - lib/gather_content/api/templates.rb
88
+ - lib/gather_content/config.rb
89
+ - lib/gather_content/config/builder.rb
90
+ - lib/gather_content/config/elements.rb
91
+ - lib/gather_content/config/elements/base.rb
92
+ - lib/gather_content/config/elements/choice_checkbox.rb
93
+ - lib/gather_content/config/elements/choice_radio.rb
94
+ - lib/gather_content/config/elements/files.rb
95
+ - lib/gather_content/config/elements/option.rb
96
+ - lib/gather_content/config/elements/other_option.rb
97
+ - lib/gather_content/config/elements/section.rb
98
+ - lib/gather_content/config/elements/text.rb
99
+ - lib/gather_content/config/tab.rb
100
+ - lib/gather_content/config/tabs.rb
101
+ - lib/gather_content/dsl.rb
102
+ - lib/gather_content/dsl/base.rb
103
+ - lib/gather_content/dsl/choice_checkbox.rb
104
+ - lib/gather_content/dsl/choice_radio.rb
105
+ - lib/gather_content/dsl/config.rb
106
+ - lib/gather_content/dsl/files.rb
107
+ - lib/gather_content/dsl/option.rb
108
+ - lib/gather_content/dsl/other_option.rb
109
+ - lib/gather_content/dsl/section.rb
110
+ - lib/gather_content/dsl/tab.rb
111
+ - lib/gather_content/dsl/text.rb
87
112
  - lib/gather_content/error.rb
88
113
  - lib/gather_content/error/request_error.rb
89
114
  - lib/gather_content/version.rb
@@ -101,7 +126,24 @@ files:
101
126
  - spec/gather_content/api/statuses_spec.rb
102
127
  - spec/gather_content/api/template_spec.rb
103
128
  - spec/gather_content/api/templates_spec.rb
129
+ - spec/gather_content/config/builder_spec.rb
130
+ - spec/gather_content/config/elements/choice_checkbox_spec.rb
131
+ - spec/gather_content/config/elements/choice_radio_spec.rb
132
+ - spec/gather_content/config/elements/files_spec.rb
133
+ - spec/gather_content/config/elements/option_spec.rb
134
+ - spec/gather_content/config/elements/other_option_spec.rb
135
+ - spec/gather_content/config/elements/section_spec.rb
136
+ - spec/gather_content/config/elements/text_spec.rb
137
+ - spec/gather_content/config/tab_spec.rb
138
+ - spec/gather_content/dsl/choice_checkbox_spec.rb
139
+ - spec/gather_content/dsl/choice_radio_spec.rb
140
+ - spec/gather_content/dsl/files_spec.rb
141
+ - spec/gather_content/dsl/section_spec.rb
142
+ - spec/gather_content/dsl/tab_spec.rb
143
+ - spec/gather_content/dsl/text_spec.rb
104
144
  - spec/spec_helper.rb
145
+ - spec/support/shared_examples/dsl.rb
146
+ - spec/support/shared_examples/element.rb
105
147
  - spec/vcr_cassettes/GatherContent_Api_Account/_/returns_the_data_related_to_the_supplied_key.yml
106
148
  - spec/vcr_cassettes/GatherContent_Api_Account/_fetch/1_2_1.yml
107
149
  - spec/vcr_cassettes/GatherContent_Api_Account/_fetch/1_3_1.yml
@@ -177,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
219
  version: '0'
178
220
  requirements: []
179
221
  rubyforge_project:
180
- rubygems_version: 2.6.13
222
+ rubygems_version: 2.5.2
181
223
  signing_key:
182
224
  specification_version: 4
183
225
  summary: Ruby wrapper for the GatherContent API
@@ -196,7 +238,24 @@ test_files:
196
238
  - spec/gather_content/api/statuses_spec.rb
197
239
  - spec/gather_content/api/template_spec.rb
198
240
  - spec/gather_content/api/templates_spec.rb
241
+ - spec/gather_content/config/builder_spec.rb
242
+ - spec/gather_content/config/elements/choice_checkbox_spec.rb
243
+ - spec/gather_content/config/elements/choice_radio_spec.rb
244
+ - spec/gather_content/config/elements/files_spec.rb
245
+ - spec/gather_content/config/elements/option_spec.rb
246
+ - spec/gather_content/config/elements/other_option_spec.rb
247
+ - spec/gather_content/config/elements/section_spec.rb
248
+ - spec/gather_content/config/elements/text_spec.rb
249
+ - spec/gather_content/config/tab_spec.rb
250
+ - spec/gather_content/dsl/choice_checkbox_spec.rb
251
+ - spec/gather_content/dsl/choice_radio_spec.rb
252
+ - spec/gather_content/dsl/files_spec.rb
253
+ - spec/gather_content/dsl/section_spec.rb
254
+ - spec/gather_content/dsl/tab_spec.rb
255
+ - spec/gather_content/dsl/text_spec.rb
199
256
  - spec/spec_helper.rb
257
+ - spec/support/shared_examples/dsl.rb
258
+ - spec/support/shared_examples/element.rb
200
259
  - spec/vcr_cassettes/GatherContent_Api_Account/_/returns_the_data_related_to_the_supplied_key.yml
201
260
  - spec/vcr_cassettes/GatherContent_Api_Account/_fetch/1_2_1.yml
202
261
  - spec/vcr_cassettes/GatherContent_Api_Account/_fetch/1_3_1.yml