noun-project-api 0.2.2 → 3.1.0
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 +5 -5
- data/Rakefile +9 -7
- data/lib/noun_project_api.rb +38 -0
- data/lib/noun_project_api/base_item.rb +30 -0
- data/lib/noun_project_api/collection.rb +36 -0
- data/lib/noun_project_api/collection_retriever.rb +14 -0
- data/lib/{noun-project-api → noun_project_api}/connection.rb +3 -1
- data/lib/noun_project_api/errors.rb +14 -0
- data/lib/noun_project_api/icon.rb +41 -0
- data/lib/noun_project_api/icon_retriever.rb +14 -0
- data/lib/noun_project_api/icons_retriever.rb +66 -0
- data/lib/noun_project_api/reporter.rb +22 -0
- data/lib/noun_project_api/retriever.rb +18 -0
- data/spec/lib/noun_project_api/base_item_spec.rb +13 -0
- data/spec/lib/noun_project_api/collection_retriever_spec.rb +87 -0
- data/spec/lib/noun_project_api/collection_spec.rb +66 -0
- data/spec/lib/{noun-project-api → noun_project_api}/icon_retriever_spec.rb +20 -18
- data/spec/lib/{noun-project-api → noun_project_api}/icon_spec.rb +21 -19
- data/spec/lib/{noun-project-api → noun_project_api}/icons_retriever_spec.rb +27 -25
- data/spec/lib/{noun-project-api → noun_project_api}/reporter_spec.rb +24 -24
- data/spec/lib/noun_project_api/retriever_spec.rb +22 -0
- data/spec/lib/{nount_project_api_spec.rb → noun_project_api_spec.rb} +5 -3
- data/spec/spec_helper.rb +3 -4
- data/spec/support/fakes.rb +93 -10
- metadata +90 -45
- data/lib/noun-project-api.rb +0 -30
- data/lib/noun-project-api/icon.rb +0 -52
- data/lib/noun-project-api/icon_retriever.rb +0 -20
- data/lib/noun-project-api/icons_retriever.rb +0 -51
- data/lib/noun-project-api/reporter.rb +0 -20
- data/lib/noun-project-api/retriever.rb +0 -6
- data/spec/lib/noun-project-api/retriever_spec.rb +0 -20
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "ostruct"
|
5
|
+
|
6
|
+
RSpec.describe NounProjectApi::CollectionRetriever do
|
7
|
+
it "raises an error on empty initialization input" do
|
8
|
+
expect { NounProjectApi::Collection.new }.to raise_error(ArgumentError)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "accepts JSON string input" do
|
12
|
+
data = JSON.parse(Fakes::Results::COLLECTION_VALID)
|
13
|
+
expect { NounProjectApi::Collection.new(JSON.dump(data["collection"])) }.to_not raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it "accepts JSON string input with collection encapsulation" do
|
17
|
+
expect { NounProjectApi::Collection.new(Fakes::Results::COLLECTION_VALID) }.to_not raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it "accepts hash input" do
|
21
|
+
data = JSON.parse(Fakes::Results::COLLECTION_VALID)
|
22
|
+
expect { NounProjectApi::Collection.new(data) }.to_not raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
context "exposed attributes" do
|
26
|
+
before :each do
|
27
|
+
@json = JSON.parse(Fakes::Results::COLLECTION_VALID)
|
28
|
+
@valid_collection = NounProjectApi::Collection.new(Fakes::Results::COLLECTION_VALID)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "id as number" do
|
32
|
+
expect(@valid_collection.id).to be_a(Integer)
|
33
|
+
expect(@valid_collection.id).to eq(@json["collection"]["id"].to_i)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "author id as number" do
|
37
|
+
expect(@valid_collection.author_id).to eq(@json["collection"]["author_id"].to_i)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "author name" do
|
41
|
+
expect(@valid_collection.author_name).to eq(@json["collection"]["author"]["name"])
|
42
|
+
end
|
43
|
+
|
44
|
+
it "icon count as number" do
|
45
|
+
expect(@valid_collection.icon_count).to eq(@json["collection"]["icon_count"].to_i)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "is published" do
|
49
|
+
expect(@valid_collection.published?).to eq(@json["collection"]["is_published"].to_i == 1)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "builds a simple hash" do
|
53
|
+
expect(@valid_collection.to_hash).to eq(
|
54
|
+
id: @valid_collection.id,
|
55
|
+
author_id: @valid_collection.author_id,
|
56
|
+
author_name: @valid_collection.author_name,
|
57
|
+
icon_count: @valid_collection.icon_count,
|
58
|
+
published: @valid_collection.published?
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "json formats the hash" do
|
63
|
+
expect(@valid_collection.to_json).to eq JSON.dump @valid_collection.to_hash
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,26 +1,28 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "ostruct"
|
3
5
|
|
4
6
|
RSpec.describe NounProjectApi::IconRetriever do
|
5
7
|
before :each do
|
6
|
-
@icon = NounProjectApi::IconRetriever.new(Faker::Internet.password(16), Faker::Internet.password(16))
|
7
|
-
@valid_hash = JSON.parse(Fakes::Results::ICON_VALID)
|
8
|
+
@icon = NounProjectApi::IconRetriever.new(Faker::Internet.password(min_length: 16), Faker::Internet.password(min_length: 16))
|
9
|
+
@valid_hash = JSON.parse(Fakes::Results::ICON_VALID, symbolize_names: true)
|
8
10
|
@valid_response = OpenStruct.new(
|
9
11
|
body: Fakes::Results::ICON_VALID,
|
10
|
-
code:
|
12
|
+
code: "200"
|
11
13
|
)
|
12
14
|
|
13
15
|
@missing_response = OpenStruct.new(
|
14
|
-
code:
|
16
|
+
code: "404"
|
15
17
|
)
|
16
18
|
end
|
17
19
|
|
18
20
|
context "id" do
|
19
|
-
it
|
21
|
+
it "raises an error when no id is provided" do
|
20
22
|
expect { @icon.find(nil) }.to raise_error(ArgumentError)
|
21
23
|
end
|
22
24
|
|
23
|
-
it
|
25
|
+
it "returns a proper result with a correct id" do
|
24
26
|
id = 1
|
25
27
|
expect(@icon.access_token).to receive(
|
26
28
|
:get
|
@@ -32,10 +34,10 @@ RSpec.describe NounProjectApi::IconRetriever do
|
|
32
34
|
|
33
35
|
result = @icon.find(id)
|
34
36
|
expect(result).to be_a(NounProjectApi::Icon)
|
35
|
-
expect(result.original_hash).to eq(@valid_hash[
|
37
|
+
expect(result.original_hash).to eq(@valid_hash[:icon])
|
36
38
|
end
|
37
39
|
|
38
|
-
it
|
40
|
+
it "raises an error with a missing id" do
|
39
41
|
id = 1
|
40
42
|
expect(@icon.access_token).to receive(
|
41
43
|
:get
|
@@ -45,17 +47,17 @@ RSpec.describe NounProjectApi::IconRetriever do
|
|
45
47
|
@missing_response
|
46
48
|
)
|
47
49
|
|
48
|
-
expect { @icon.find(id) }.to raise_error(
|
50
|
+
expect { @icon.find(id) }.to raise_error(NounProjectApi::ServiceError)
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
54
|
context "slug" do
|
53
|
-
it
|
55
|
+
it "raises an error when no slug is provided" do
|
54
56
|
expect { @icon.find_by_slug(nil) }.to raise_error(ArgumentError)
|
55
57
|
end
|
56
58
|
|
57
|
-
it
|
58
|
-
slug =
|
59
|
+
it "returns a proper result with a correct slug" do
|
60
|
+
slug = "existing_slug"
|
59
61
|
expect(@icon.access_token).to receive(
|
60
62
|
:get
|
61
63
|
).with(
|
@@ -66,11 +68,11 @@ RSpec.describe NounProjectApi::IconRetriever do
|
|
66
68
|
|
67
69
|
result = @icon.find(slug)
|
68
70
|
expect(result).to be_a(NounProjectApi::Icon)
|
69
|
-
expect(result.original_hash).to eq(@valid_hash[
|
71
|
+
expect(result.original_hash).to eq(@valid_hash[:icon])
|
70
72
|
end
|
71
73
|
|
72
|
-
it
|
73
|
-
slug =
|
74
|
+
it "raises an error with a missing slug" do
|
75
|
+
slug = "missing_slug"
|
74
76
|
expect(@icon.access_token).to receive(
|
75
77
|
:get
|
76
78
|
).with(
|
@@ -79,7 +81,7 @@ RSpec.describe NounProjectApi::IconRetriever do
|
|
79
81
|
@missing_response
|
80
82
|
)
|
81
83
|
|
82
|
-
expect { @icon.find_by_slug(slug) }.to raise_error(
|
84
|
+
expect { @icon.find_by_slug(slug) }.to raise_error(NounProjectApi::ServiceError)
|
83
85
|
end
|
84
86
|
end
|
85
87
|
end
|
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "ostruct"
|
3
5
|
|
4
6
|
RSpec.describe NounProjectApi::IconRetriever do
|
5
|
-
it
|
7
|
+
it "raises an error on empty initialization input" do
|
6
8
|
expect { NounProjectApi::Icon.new }.to raise_error(ArgumentError)
|
7
9
|
end
|
8
10
|
|
9
|
-
it
|
11
|
+
it "accepts JSON string input" do
|
10
12
|
data = JSON.parse(Fakes::Results::ICON_VALID)
|
11
13
|
expect { NounProjectApi::Icon.new(JSON.dump(data["icon"])) }.to_not raise_error
|
12
14
|
end
|
13
15
|
|
14
|
-
it
|
16
|
+
it "accepts JSON string input with icon encapsulation" do
|
15
17
|
expect { NounProjectApi::Icon.new(Fakes::Results::ICON_VALID) }.to_not raise_error
|
16
18
|
end
|
17
19
|
|
18
|
-
it
|
20
|
+
it "accepts hash input" do
|
19
21
|
data = JSON.parse(Fakes::Results::ICON_VALID)
|
20
22
|
expect { NounProjectApi::Icon.new(data) }.to_not raise_error
|
21
23
|
end
|
@@ -26,51 +28,51 @@ RSpec.describe NounProjectApi::IconRetriever do
|
|
26
28
|
@valid_icon = NounProjectApi::Icon.new(Fakes::Results::ICON_VALID)
|
27
29
|
end
|
28
30
|
|
29
|
-
it
|
31
|
+
it "public domain" do
|
30
32
|
expect(@valid_icon.public_domain?).to eq(@json["icon"]["license_description"] == "public-domain")
|
31
33
|
end
|
32
34
|
|
33
|
-
it
|
35
|
+
it "SVG url" do
|
34
36
|
expect(@valid_icon.svg_url).to eq(@json["icon"]["icon_url"])
|
35
37
|
end
|
36
38
|
|
37
|
-
it
|
39
|
+
it "nil on missing SVG url" do
|
38
40
|
@json["icon"].delete("icon_url")
|
39
41
|
icon = NounProjectApi::Icon.new(@json)
|
40
42
|
expect(icon.svg_url).to be_nil
|
41
43
|
end
|
42
44
|
|
43
|
-
it
|
45
|
+
it "preview url defaults at 200 size" do
|
44
46
|
expect(@valid_icon.preview_url).to eq(@json["icon"]["preview_url"])
|
45
47
|
end
|
46
48
|
|
47
|
-
it
|
49
|
+
it "preview url for 200 size" do
|
48
50
|
expect(@valid_icon.preview_url(NounProjectApi::Icon::PREVIEW_SIZE_200)).to eq(@json["icon"]["preview_url"])
|
49
51
|
end
|
50
52
|
|
51
|
-
it
|
53
|
+
it "preview url for 84 size" do
|
52
54
|
expect(@valid_icon.preview_url(NounProjectApi::Icon::PREVIEW_SIZE_84)).to eq(@json["icon"]["preview_url_84"])
|
53
55
|
end
|
54
56
|
|
55
|
-
it
|
57
|
+
it "preview url for 42 size" do
|
56
58
|
expect(@valid_icon.preview_url(NounProjectApi::Icon::PREVIEW_SIZE_42)).to eq(@json["icon"]["preview_url_42"])
|
57
59
|
end
|
58
60
|
|
59
|
-
it
|
60
|
-
expect(@valid_icon.id).to be_a(
|
61
|
+
it "id as number" do
|
62
|
+
expect(@valid_icon.id).to be_a(Integer)
|
61
63
|
expect(@valid_icon.id).to eq(@json["icon"]["id"].to_i)
|
62
64
|
end
|
63
65
|
|
64
|
-
it
|
65
|
-
expect(@valid_icon.to_hash).to eq(
|
66
|
+
it "builds a simple hash" do
|
67
|
+
expect(@valid_icon.to_hash).to eq(
|
66
68
|
id: @valid_icon.id,
|
67
69
|
preview_url_200: @valid_icon.preview_url(NounProjectApi::Icon::PREVIEW_SIZE_200),
|
68
70
|
preview_url_84: @valid_icon.preview_url(NounProjectApi::Icon::PREVIEW_SIZE_84),
|
69
71
|
preview_url_42: @valid_icon.preview_url(NounProjectApi::Icon::PREVIEW_SIZE_42)
|
70
|
-
|
72
|
+
)
|
71
73
|
end
|
72
74
|
|
73
|
-
it
|
75
|
+
it "json formats the hash" do
|
74
76
|
expect(@valid_icon.to_json).to eq JSON.dump @valid_icon.to_hash
|
75
77
|
end
|
76
78
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
2
4
|
|
3
5
|
RSpec.describe NounProjectApi::IconsRetriever do
|
4
6
|
before :each do
|
5
|
-
@icons = NounProjectApi::IconsRetriever.new(Faker::Internet.password(16), Faker::Internet.password(16))
|
7
|
+
@icons = NounProjectApi::IconsRetriever.new(Faker::Internet.password(min_length: 16), Faker::Internet.password(min_length: 16))
|
6
8
|
end
|
7
9
|
|
8
10
|
context "recent uploads" do
|
@@ -10,7 +12,7 @@ RSpec.describe NounProjectApi::IconsRetriever do
|
|
10
12
|
valid_hash = JSON.parse(Fakes::Results::ICONS_RECENT_VALID)
|
11
13
|
valid_response = OpenStruct.new(
|
12
14
|
body: Fakes::Results::ICONS_RECENT_VALID,
|
13
|
-
code:
|
15
|
+
code: "200"
|
14
16
|
)
|
15
17
|
|
16
18
|
expect(@icons.access_token).to receive(
|
@@ -31,7 +33,7 @@ RSpec.describe NounProjectApi::IconsRetriever do
|
|
31
33
|
it "returns the recent uploads and passes limit when passed" do
|
32
34
|
valid_response = OpenStruct.new(
|
33
35
|
body: Fakes::Results::ICONS_RECENT_VALID,
|
34
|
-
code:
|
36
|
+
code: "200"
|
35
37
|
)
|
36
38
|
|
37
39
|
limit = 3
|
@@ -53,22 +55,22 @@ RSpec.describe NounProjectApi::IconsRetriever do
|
|
53
55
|
end
|
54
56
|
|
55
57
|
context "Icons search" do
|
56
|
-
it
|
58
|
+
it "raises an error when no phrase is provided" do
|
57
59
|
expect { @icons.find(nil) }.to raise_error(ArgumentError)
|
58
60
|
end
|
59
61
|
|
60
|
-
it
|
62
|
+
it "properly URI encodes search patterns" do
|
61
63
|
valid_hash = JSON.parse(Fakes::Results::ICONS_VALID)
|
62
64
|
valid_response = OpenStruct.new(
|
63
65
|
body: Fakes::Results::ICONS_VALID,
|
64
|
-
code:
|
66
|
+
code: "200"
|
65
67
|
)
|
66
68
|
|
67
|
-
term = 'some search with
|
69
|
+
term = 'some search with ",] bad chars'
|
68
70
|
expect(@icons.access_token).to receive(
|
69
71
|
:get
|
70
72
|
).with(
|
71
|
-
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper
|
73
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper.escape(term)}?limit_to_public_domain=0"
|
72
74
|
).and_return(
|
73
75
|
valid_response
|
74
76
|
)
|
@@ -80,18 +82,18 @@ RSpec.describe NounProjectApi::IconsRetriever do
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
83
|
-
it
|
85
|
+
it "returns a proper result with a correct phrase" do
|
84
86
|
valid_hash = JSON.parse(Fakes::Results::ICONS_VALID)
|
85
87
|
valid_response = OpenStruct.new(
|
86
88
|
body: Fakes::Results::ICONS_VALID,
|
87
|
-
code:
|
89
|
+
code: "200"
|
88
90
|
)
|
89
91
|
|
90
|
-
term =
|
92
|
+
term = "some search"
|
91
93
|
expect(@icons.access_token).to receive(
|
92
94
|
:get
|
93
95
|
).with(
|
94
|
-
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper
|
96
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper.escape(term)}?limit_to_public_domain=0"
|
95
97
|
).and_return(
|
96
98
|
valid_response
|
97
99
|
)
|
@@ -103,18 +105,18 @@ RSpec.describe NounProjectApi::IconsRetriever do
|
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
106
|
-
it
|
108
|
+
it "properly handles public domain only config" do
|
107
109
|
valid_hash = JSON.parse(Fakes::Results::ICONS_VALID)
|
108
110
|
valid_response = OpenStruct.new(
|
109
111
|
body: Fakes::Results::ICONS_VALID,
|
110
|
-
code:
|
112
|
+
code: "200"
|
111
113
|
)
|
112
114
|
|
113
|
-
term =
|
115
|
+
term = "some search"
|
114
116
|
expect(@icons.access_token).to receive(
|
115
117
|
:get
|
116
118
|
).with(
|
117
|
-
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper
|
119
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper.escape(term)}?limit_to_public_domain=1"
|
118
120
|
).and_return(
|
119
121
|
valid_response
|
120
122
|
)
|
@@ -128,18 +130,18 @@ RSpec.describe NounProjectApi::IconsRetriever do
|
|
128
130
|
NounProjectApi.configuration.public_domain = false
|
129
131
|
end
|
130
132
|
|
131
|
-
it
|
133
|
+
it "returns a proper result with a correct phrase and passes the args" do
|
132
134
|
valid_response = OpenStruct.new(
|
133
135
|
body: Fakes::Results::ICONS_VALID,
|
134
|
-
code:
|
136
|
+
code: "200"
|
135
137
|
)
|
136
138
|
|
137
|
-
term =
|
139
|
+
term = "some search"
|
138
140
|
limit = 4
|
139
141
|
expect(@icons.access_token).to receive(
|
140
142
|
:get
|
141
143
|
).with(
|
142
|
-
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper
|
144
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper.escape(term)}?limit_to_public_domain=0&limit=#{limit}"
|
143
145
|
).and_return(
|
144
146
|
valid_response
|
145
147
|
)
|
@@ -151,16 +153,16 @@ RSpec.describe NounProjectApi::IconsRetriever do
|
|
151
153
|
end
|
152
154
|
end
|
153
155
|
|
154
|
-
it
|
156
|
+
it "returns an empty array for no result" do
|
155
157
|
missing_response = OpenStruct.new(
|
156
|
-
code:
|
158
|
+
code: "404"
|
157
159
|
)
|
158
160
|
|
159
|
-
term =
|
161
|
+
term = "missing search"
|
160
162
|
expect(@icons.access_token).to receive(
|
161
163
|
:get
|
162
164
|
).with(
|
163
|
-
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper
|
165
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper.escape(term)}?limit_to_public_domain=0"
|
164
166
|
).and_return(
|
165
167
|
missing_response
|
166
168
|
)
|
@@ -1,34 +1,36 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
2
4
|
|
3
5
|
RSpec.describe NounProjectApi::Reporter do
|
4
|
-
it
|
5
|
-
expect { NounProjectApi::Reporter.new(nil, Faker::Internet.password(16)) }.to raise_error(ArgumentError)
|
6
|
+
it "raises an error when initialized without token" do
|
7
|
+
expect { NounProjectApi::Reporter.new(nil, Faker::Internet.password(min_length: 16)) }.to raise_error(ArgumentError)
|
6
8
|
end
|
7
9
|
|
8
|
-
it
|
9
|
-
expect { NounProjectApi::Reporter.new(Faker::Internet.password(16), nil) }.to raise_error(ArgumentError)
|
10
|
+
it "raises an error when initialized without secret" do
|
11
|
+
expect { NounProjectApi::Reporter.new(Faker::Internet.password(min_length: 16), nil) }.to raise_error(ArgumentError)
|
10
12
|
end
|
11
13
|
|
12
|
-
it
|
13
|
-
token = Faker::Internet.password(16)
|
14
|
-
secret = Faker::Internet.password(16)
|
14
|
+
it "initializes the values properly" do
|
15
|
+
token = Faker::Internet.password(min_length: 16)
|
16
|
+
secret = Faker::Internet.password(min_length: 16)
|
15
17
|
reporter = NounProjectApi::Reporter.new(token, secret)
|
16
18
|
|
17
19
|
expect(reporter.token).to eq(token)
|
18
20
|
expect(reporter.secret).to eq(secret)
|
19
21
|
end
|
20
22
|
|
21
|
-
context
|
23
|
+
context "reports ids usage" do
|
22
24
|
before :each do
|
23
|
-
token = Faker::Internet.password(16)
|
24
|
-
secret = Faker::Internet.password(16)
|
25
|
+
token = Faker::Internet.password(min_length: 16)
|
26
|
+
secret = Faker::Internet.password(min_length: 16)
|
25
27
|
@reporter = NounProjectApi::Reporter.new(token, secret)
|
26
28
|
end
|
27
29
|
|
28
|
-
it
|
30
|
+
it "reports a singular id" do
|
29
31
|
valid_response = OpenStruct.new(
|
30
32
|
body: Fakes::Results::REPORTED_ONE,
|
31
|
-
code:
|
33
|
+
code: "200"
|
32
34
|
)
|
33
35
|
|
34
36
|
id = 122
|
@@ -38,7 +40,7 @@ RSpec.describe NounProjectApi::Reporter do
|
|
38
40
|
).with(
|
39
41
|
"#{NounProjectApi::API_BASE}#{NounProjectApi::Reporter::API_PATH}",
|
40
42
|
{ icons: id.to_s }.to_json,
|
41
|
-
|
43
|
+
"Accept" => "application/json", "Content-Type" => "application/json"
|
42
44
|
).and_return(
|
43
45
|
valid_response
|
44
46
|
)
|
@@ -47,20 +49,20 @@ RSpec.describe NounProjectApi::Reporter do
|
|
47
49
|
expect(result).to be true
|
48
50
|
end
|
49
51
|
|
50
|
-
it
|
52
|
+
it "reports a singular id for a string" do
|
51
53
|
valid_response = OpenStruct.new(
|
52
54
|
body: Fakes::Results::REPORTED_ONE,
|
53
|
-
code:
|
55
|
+
code: "200"
|
54
56
|
)
|
55
57
|
|
56
|
-
id =
|
58
|
+
id = "122"
|
57
59
|
|
58
60
|
expect(@reporter.access_token).to receive(
|
59
61
|
:post
|
60
62
|
).with(
|
61
63
|
"#{NounProjectApi::API_BASE}#{NounProjectApi::Reporter::API_PATH}",
|
62
64
|
{ icons: id }.to_json,
|
63
|
-
|
65
|
+
"Accept" => "application/json", "Content-Type" => "application/json"
|
64
66
|
).and_return(
|
65
67
|
valid_response
|
66
68
|
)
|
@@ -69,12 +71,10 @@ RSpec.describe NounProjectApi::Reporter do
|
|
69
71
|
expect(result).to be true
|
70
72
|
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
it 'reports multiple ids' do
|
74
|
+
it "reports multiple ids" do
|
75
75
|
valid_response = OpenStruct.new(
|
76
76
|
body: Fakes::Results::REPORTED_ONE,
|
77
|
-
code:
|
77
|
+
code: "200"
|
78
78
|
)
|
79
79
|
|
80
80
|
ids = [122, 4541, 342_11, 4352]
|
@@ -83,8 +83,8 @@ RSpec.describe NounProjectApi::Reporter do
|
|
83
83
|
:post
|
84
84
|
).with(
|
85
85
|
"#{NounProjectApi::API_BASE}#{NounProjectApi::Reporter::API_PATH}",
|
86
|
-
{ icons: ids.join(
|
87
|
-
|
86
|
+
{ icons: ids.join(",") }.to_json,
|
87
|
+
"Accept" => "application/json", "Content-Type" => "application/json"
|
88
88
|
).and_return(
|
89
89
|
valid_response
|
90
90
|
)
|