openbeautyfacts 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +6 -6
- data/lib/openbeautyfacts.rb +2 -0
- data/lib/openbeautyfacts/ingredient.rb +33 -0
- data/lib/openbeautyfacts/period_after_opening.rb +33 -0
- data/lib/openbeautyfacts/product.rb +2 -2
- data/lib/openbeautyfacts/version.rb +1 -1
- data/test/fixtures/ingredients.yml +13229 -0
- data/test/fixtures/ingredients_locale.yml +11256 -0
- data/test/fixtures/period_after_openings.yml +890 -0
- data/test/fixtures/period_after_openings_locale.yml +932 -0
- data/test/fixtures/products_for_ingredient.yml +1136 -0
- data/test/fixtures/products_for_period_after_opening.yml +1143 -0
- data/test/test_openbeautyfacts.rb +53 -5
- metadata +19 -11
@@ -66,8 +66,8 @@ class TestOpenbeautyfacts < Minitest::Test
|
|
66
66
|
products = ::Openbeautyfacts::Product.search(term, page_size: 24)
|
67
67
|
first_product = products.first
|
68
68
|
|
69
|
-
assert_match
|
70
|
-
assert_match
|
69
|
+
assert_match(/#{term}/i, products.last["product_name"])
|
70
|
+
assert_match(/#{term}/i, ::Openbeautyfacts::Product.search(term).last["product_name"])
|
71
71
|
assert_equal products.size, 24
|
72
72
|
end
|
73
73
|
|
@@ -121,7 +121,7 @@ class TestOpenbeautyfacts < Minitest::Test
|
|
121
121
|
def test_it_fetches_products_with_additive
|
122
122
|
additive = ::Openbeautyfacts::Additive.new("url" => "http://world.openbeautyfacts.org/additive/e539-sodium-thiosulfate")
|
123
123
|
VCR.use_cassette("products_with_additive") do
|
124
|
-
products_with_additive = additive.products(page:
|
124
|
+
products_with_additive = additive.products(page: 1)
|
125
125
|
refute_empty products_with_additive
|
126
126
|
end
|
127
127
|
end
|
@@ -145,7 +145,7 @@ class TestOpenbeautyfacts < Minitest::Test
|
|
145
145
|
def test_it_fetches_products_for_brand
|
146
146
|
brand = ::Openbeautyfacts::Brand.new("url" => "http://world.openbeautyfacts.org/brand/sedapoux")
|
147
147
|
VCR.use_cassette("products_for_brand") do
|
148
|
-
products_for_brand = brand.products(page:
|
148
|
+
products_for_brand = brand.products(page: 1)
|
149
149
|
refute_empty products_for_brand
|
150
150
|
end
|
151
151
|
end
|
@@ -169,11 +169,59 @@ class TestOpenbeautyfacts < Minitest::Test
|
|
169
169
|
def test_it_fetches_products_for_state
|
170
170
|
product_state = ::Openbeautyfacts::ProductState.new("url" => "http://world.openbeautyfacts.org/state/photos-uploaded", "products_count" => 22)
|
171
171
|
VCR.use_cassette("products_for_state") do
|
172
|
-
products_for_state = product_state.products(page:
|
172
|
+
products_for_state = product_state.products(page: 1)
|
173
173
|
refute_empty products_for_state
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
+
# Ingredients
|
178
|
+
|
179
|
+
def test_it_fetches_ingredients
|
180
|
+
VCR.use_cassette("ingredients") do
|
181
|
+
ingredients = ::Openbeautyfacts::Ingredient.all
|
182
|
+
assert_includes ingredients.map { |ingredient| ingredient['name'] }, "Water"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_it_fetches_ingredients_for_locale
|
187
|
+
VCR.use_cassette("ingredients_locale") do
|
188
|
+
ingredients = ::Openbeautyfacts::Ingredient.all(locale: 'fr')
|
189
|
+
assert_includes ingredients.map { |ingredient| ingredient['name'] }, "Eau"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_it_fetches_products_for_ingredient
|
194
|
+
ingredient = ::Openbeautyfacts::Ingredient.new("url" => "http://world.openbeautyfacts.org/ingredient/water")
|
195
|
+
VCR.use_cassette("products_for_ingredient") do
|
196
|
+
products_for_ingredient = ingredient.products(page: 1)
|
197
|
+
refute_empty products_for_ingredient
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Period after openings
|
202
|
+
|
203
|
+
def test_it_fetches_period_after_openings
|
204
|
+
VCR.use_cassette("period_after_openings") do
|
205
|
+
period_after_openings = ::Openbeautyfacts::PeriodAfterOpening.all
|
206
|
+
assert_includes period_after_openings.map { |period_after_opening| period_after_opening['name'] }, "12 months"
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_it_fetches_period_after_openings_for_locale
|
211
|
+
VCR.use_cassette("period_after_openings_locale") do
|
212
|
+
period_after_openings = ::Openbeautyfacts::PeriodAfterOpening.all(locale: 'fr')
|
213
|
+
assert_includes period_after_openings.map { |period_after_opening| period_after_opening['name'] }, "12 mois"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_it_fetches_products_for_period_after_opening
|
218
|
+
period_after_opening = ::Openbeautyfacts::PeriodAfterOpening.new("url" => "http://world.openbeautyfacts.org/period-after-opening/12-months")
|
219
|
+
VCR.use_cassette("products_for_period_after_opening") do
|
220
|
+
products_for_period_after_opening = period_after_opening.products(page: 1)
|
221
|
+
refute_empty products_for_period_after_opening
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
177
225
|
# FAQ
|
178
226
|
|
179
227
|
def test_it_fetches_faq
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openbeautyfacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Leger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.7'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '12.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '12.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '5.
|
75
|
+
version: '5.10'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '5.
|
82
|
+
version: '5.10'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: vcr
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '2.3'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '2.3'
|
111
111
|
description: Open Beauty Facts API Wrapper, the open database about beauty products.
|
112
112
|
email:
|
113
113
|
- nicolas.leger@nleger.com
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/openbeautyfacts/contributor.rb
|
128
128
|
- lib/openbeautyfacts/country.rb
|
129
129
|
- lib/openbeautyfacts/faq.rb
|
130
|
+
- lib/openbeautyfacts/ingredient.rb
|
130
131
|
- lib/openbeautyfacts/ingredient_that_may_be_from_palm_oil.rb
|
131
132
|
- lib/openbeautyfacts/label.rb
|
132
133
|
- lib/openbeautyfacts/locale.rb
|
@@ -134,6 +135,7 @@ files:
|
|
134
135
|
- lib/openbeautyfacts/origin.rb
|
135
136
|
- lib/openbeautyfacts/packager_code.rb
|
136
137
|
- lib/openbeautyfacts/packaging.rb
|
138
|
+
- lib/openbeautyfacts/period_after_opening.rb
|
137
139
|
- lib/openbeautyfacts/press.rb
|
138
140
|
- lib/openbeautyfacts/product.rb
|
139
141
|
- lib/openbeautyfacts/product_state.rb
|
@@ -149,12 +151,18 @@ files:
|
|
149
151
|
- test/fixtures/faq.yml
|
150
152
|
- test/fixtures/fetch_product_3600550362626.yml
|
151
153
|
- test/fixtures/index.yml
|
154
|
+
- test/fixtures/ingredients.yml
|
155
|
+
- test/fixtures/ingredients_locale.yml
|
152
156
|
- test/fixtures/login_user.yml
|
157
|
+
- test/fixtures/period_after_openings.yml
|
158
|
+
- test/fixtures/period_after_openings_locale.yml
|
153
159
|
- test/fixtures/press.yml
|
154
160
|
- test/fixtures/product_3600550362626.yml
|
155
161
|
- test/fixtures/product_states.yml
|
156
162
|
- test/fixtures/product_states_locale.yml
|
157
163
|
- test/fixtures/products_for_brand.yml
|
164
|
+
- test/fixtures/products_for_ingredient.yml
|
165
|
+
- test/fixtures/products_for_period_after_opening.yml
|
158
166
|
- test/fixtures/products_for_state.yml
|
159
167
|
- test/fixtures/products_with_additive.yml
|
160
168
|
- test/fixtures/search_doux.yml
|
@@ -181,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
189
|
version: '0'
|
182
190
|
requirements: []
|
183
191
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.6.
|
192
|
+
rubygems_version: 2.6.8
|
185
193
|
signing_key:
|
186
194
|
specification_version: 4
|
187
195
|
summary: Open Beauty Facts API Wrapper
|