pdc 0.1.4 → 0.1.5

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.pronto.yml +13 -0
  3. data/.rubocop.yml +23 -0
  4. data/.travis.yml +13 -2
  5. data/Gemfile +16 -10
  6. data/Rakefile +4 -4
  7. data/bin/console +5 -5
  8. data/examples/logger.rb +14 -12
  9. data/examples/pdc_curb_access_token.rb +1 -1
  10. data/examples/pdc_release_rpm_mapping.rb +16 -0
  11. data/examples/pdc_resource_tests.rb +22 -0
  12. data/examples/pdc_test_cache.rb +9 -8
  13. data/examples/prod_failures.rb +1 -1
  14. data/examples/prod_pdc.rb +1 -1
  15. data/lib/pdc/base.rb +2 -2
  16. data/lib/pdc/config.rb +49 -49
  17. data/lib/pdc/http/request/append_slash.rb +1 -1
  18. data/lib/pdc/http/request/pdc_token.rb +5 -6
  19. data/lib/pdc/http/request/token_fetcher.rb +0 -1
  20. data/lib/pdc/http/response/pagination.rb +4 -5
  21. data/lib/pdc/http/response/parser.rb +6 -6
  22. data/lib/pdc/resource/attribute_store.rb +5 -9
  23. data/lib/pdc/resource/attributes.rb +22 -25
  24. data/lib/pdc/resource/identity.rb +7 -6
  25. data/lib/pdc/resource/path.rb +2 -4
  26. data/lib/pdc/resource/per_thread_registry.rb +10 -8
  27. data/lib/pdc/resource/relation/finder.rb +1 -1
  28. data/lib/pdc/resource/relation/pagination.rb +1 -1
  29. data/lib/pdc/resource/relation/query.rb +0 -1
  30. data/lib/pdc/resource/relation.rb +14 -13
  31. data/lib/pdc/resource/rest_api.rb +2 -3
  32. data/lib/pdc/resource/value_parser.rb +5 -6
  33. data/lib/pdc/v1/product.rb +0 -1
  34. data/lib/pdc/v1/release.rb +1 -1
  35. data/lib/pdc/v1/release_rpm_mapping.rb +9 -0
  36. data/lib/pdc/v1/release_variant.rb +1 -2
  37. data/lib/pdc/v1.rb +1 -0
  38. data/lib/pdc/version.rb +1 -1
  39. data/spec/fixtures/vcr/must_has_compose.yml +47 -0
  40. data/spec/pdc/config_spec.rb +2 -2
  41. data/spec/pdc/resource/attributes_spec.rb +46 -46
  42. data/spec/pdc/resource/cache_spec.rb +0 -1
  43. data/spec/pdc/resource/count_spec.rb +2 -2
  44. data/spec/pdc/resource/identity_spec.rb +0 -1
  45. data/spec/pdc/resource/pagination_spec.rb +3 -3
  46. data/spec/pdc/resource/path_spec.rb +10 -5
  47. data/spec/pdc/resource/relation_spec.rb +2 -3
  48. data/spec/pdc/v1/arch_spec.rb +1 -1
  49. data/spec/pdc/v1/release_rpm_mapping_spec.rb +16 -0
  50. data/spec/pdc/v1/release_spec.rb +2 -2
  51. data/spec/spec_helper.rb +4 -4
  52. data/spec/support/fixtures.rb +2 -4
  53. data/spec/support/vcr.rb +1 -1
  54. data/spec/support/webmock.rb +1 -3
  55. metadata +10 -2
@@ -27,7 +27,7 @@ module PDC::Resource
27
27
  end
28
28
 
29
29
  def attributes_metadata
30
- @attributes_metadata ||= HashWithIndifferentAccess.new(primary_key => default_metadata )
30
+ @attributes_metadata ||= HashWithIndifferentAccess.new(primary_key => default_metadata)
31
31
  end
32
32
 
33
33
  def attribute_parser(name)
@@ -38,30 +38,30 @@ module PDC::Resource
38
38
 
39
39
  private
40
40
 
41
- def default_metadata
42
- { parser: ValueParser }
43
- end
41
+ def default_metadata
42
+ { parser: ValueParser }
43
+ end
44
44
 
45
- def define_methods_in_container(names)
46
- instance_method_container.module_eval do
47
- Array.wrap(names).each do |name|
48
- define_method(name) do
49
- attribute(name)
50
- end
45
+ def define_methods_in_container(names)
46
+ instance_method_container.module_eval do
47
+ Array.wrap(names).each do |name|
48
+ define_method(name) do
49
+ attribute(name)
51
50
  end
52
51
  end
53
52
  end
53
+ end
54
54
 
55
- # By adding instance methods via an included module, they become
56
- # overridable with "super".
57
- # see: http://thepugautomatic.com/2013/07/dsom/
58
- def instance_method_container
59
- unless @instance_method_container
60
- @instance_method_container = Module.new
61
- include @instance_method_container
62
- end
63
- @instance_method_container
55
+ # By adding instance methods via an included module, they become
56
+ # overridable with "super".
57
+ # see: http://thepugautomatic.com/2013/07/dsom/
58
+ def instance_method_container
59
+ unless @instance_method_container
60
+ @instance_method_container = Module.new
61
+ include @instance_method_container
64
62
  end
63
+ @instance_method_container
64
+ end
65
65
  end # class methods
66
66
 
67
67
  def initialize(attributes = {})
@@ -90,10 +90,9 @@ module PDC::Resource
90
90
  end
91
91
 
92
92
  def method_missing(name, *args, &block)
93
- case
94
- when attribute?(name) then attribute(name)
95
- when predicate?(name) then predicate(name)
96
- when setter?(name) then set_attribute(name, args.first)
93
+ if attribute?(name) then attribute(name)
94
+ elsif predicate?(name) then predicate(name)
95
+ elsif setter?(name) then set_attribute(name, args.first)
97
96
  else super
98
97
  end
99
98
  end
@@ -138,7 +137,5 @@ module PDC::Resource
138
137
  def inspect_attributes
139
138
  attributes.map { |k, v| "#{k}: #{v.inspect}" }.join(' ')
140
139
  end
141
-
142
140
  end
143
141
  end
144
-
@@ -55,7 +55,7 @@ module PDC::Resource
55
55
  def ==(other)
56
56
  other.instance_of?(self.class) && id? && id == other.id
57
57
  end
58
- alias :eql? :==
58
+ alias eql? ==
59
59
 
60
60
  def as_json(options = nil)
61
61
  attributes.as_json(options)
@@ -66,10 +66,11 @@ module PDC::Resource
66
66
  end
67
67
 
68
68
  private
69
- # helper method so that primary_key can be called directly
70
- # from an instance
71
- def primary_key
72
- self.class.primary_key
73
- end
69
+
70
+ # helper method so that primary_key can be called directly
71
+ # from an instance
72
+ def primary_key
73
+ self.class.primary_key
74
+ end
74
75
  end
75
76
  end
@@ -2,7 +2,6 @@ require 'uri_template'
2
2
 
3
3
  module PDC::Resource
4
4
  class Path
5
-
6
5
  def initialize(pattern, params = {})
7
6
  @pattern = pattern
8
7
  @params = params.symbolize_keys
@@ -36,7 +35,7 @@ module PDC::Resource
36
35
  end
37
36
 
38
37
  def pattern_with_rfc_style_parens
39
- @pattern.gsub('(', '{').gsub(')', '}')
38
+ @pattern.tr('(', '{').tr(')', '}')
40
39
  end
41
40
 
42
41
  def validate_required_params!
@@ -56,8 +55,7 @@ module PDC::Resource
56
55
  end
57
56
 
58
57
  def required_params
59
- @pattern.scan(/\/:(\w+)/).flatten.map(&:to_sym)
58
+ @pattern.scan(%r{/:(\w+)}).flatten.map(&:to_sym)
60
59
  end
61
60
  end
62
61
  end
63
-
@@ -38,17 +38,19 @@ module PDC::Resource
38
38
  def self.extended(object)
39
39
  object.instance_variable_set '@per_thread_registry_key', object.name.freeze
40
40
  end
41
+
41
42
  def instance
42
43
  Thread.current[@per_thread_registry_key] ||= new
43
44
  end
45
+
44
46
  protected
45
- def method_missing(name, *args, &block) # :nodoc:
46
- # Caches the method definition as a singleton method of the receiver.
47
- #
48
- # By letting #delegate handle it, we avoid an enclosure that'll capture args.
49
- singleton_class.delegate name, to: :instance
50
- send(name, *args, &block)
51
- end
47
+
48
+ def method_missing(name, *args, &block) # :nodoc:
49
+ # Caches the method definition as a singleton method of the receiver.
50
+ #
51
+ # By letting #delegate handle it, we avoid an enclosure that'll capture args.
52
+ singleton_class.delegate name, to: :instance
53
+ send(name, *args, &block)
54
+ end
52
55
  end
53
56
  end
54
-
@@ -16,9 +16,9 @@ module PDC::Resource
16
16
  end
17
17
 
18
18
  private
19
+
19
20
  def result
20
21
  @result ||= fetch(clone)
21
22
  end
22
23
  end
23
24
  end
24
-
@@ -3,7 +3,7 @@ module PDC::Resource
3
3
  PAGINATION_KEYS = [
4
4
  :resource_count,
5
5
  :previous_page,
6
- :next_page,
6
+ :next_page
7
7
  ].freeze
8
8
 
9
9
  module Pagination
@@ -11,4 +11,3 @@ module PDC::Resource
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -13,7 +13,7 @@ module PDC::Resource
13
13
  attr_reader :klass
14
14
  attr_writer :params
15
15
 
16
- alias :all :to_a
16
+ alias all to_a
17
17
 
18
18
  def initialize(klass, options = {})
19
19
  @klass = klass
@@ -63,19 +63,20 @@ module PDC::Resource
63
63
 
64
64
  private
65
65
 
66
- def method_missing(name, *args, &block)
67
- # pass anything that relation doesn't know to the klass
68
- super unless klass.respond_to? name
66
+ def method_missing(name, *args, &block)
67
+ # pass anything that relation doesn't know to the klass
68
+ super unless klass.respond_to? name
69
69
 
70
- with_scope { klass.send(name, *args, &block) }
71
- end
70
+ with_scope { klass.send(name, *args, &block) }
71
+ end
72
72
 
73
- # Keep hold of current scope while running a method on the class
74
- def with_scope
75
- previous, klass.current_scope = klass.current_scope, self
76
- yield
77
- ensure
78
- klass.current_scope = previous
79
- end
73
+ # Keep hold of current scope while running a method on the class
74
+ def with_scope
75
+ previous = klass.current_scope
76
+ klass.current_scope = self
77
+ yield
78
+ ensure
79
+ klass.current_scope = previous
80
+ end
80
81
  end
81
82
  end
@@ -13,7 +13,8 @@ module PDC::Resource
13
13
  response = connection.send(method) do |request|
14
14
  request.url path, query
15
15
  end
16
- payload[:url], payload[:status] = response.env.url, response.status
16
+ payload[:url] = response.env.url
17
+ payload[:status] = response.status
17
18
  PDC::Http::Result.new(response)
18
19
  end
19
20
  end
@@ -35,7 +36,5 @@ module PDC::Resource
35
36
  @url = connection.build_url(uri).to_s
36
37
  end
37
38
  attr_reader :url
38
-
39
39
  end
40
40
  end
41
-
@@ -14,18 +14,17 @@ module PDC::Resource
14
14
  class ValueParser
15
15
  class << self
16
16
  def parse(value)
17
- case
18
- when value.is_a?(Array) then value.map { |v| parse(v) }
19
- when value.is_a?(Hash) then OpenStruct.new(parse_hash(value))
17
+ if value.is_a?(Array) then value.map { |v| parse(v) }
18
+ elsif value.is_a?(Hash) then OpenStruct.new(parse_hash(value))
20
19
  else value
21
20
  end
22
21
  end
23
22
 
24
23
  private
25
24
 
26
- def parse_hash(hash)
27
- hash.map { |k, v| [k.to_sym, parse(v)] }.to_h
28
- end
25
+ def parse_hash(hash)
26
+ hash.map { |k, v| [k.to_sym, parse(v)] }.to_h
27
+ end
29
28
  end
30
29
  end
31
30
  end
@@ -2,4 +2,3 @@ module PDC::V1
2
2
  class Product < PDC::Base
3
3
  end
4
4
  end
5
-
@@ -12,7 +12,7 @@ module PDC
12
12
 
13
13
  # TODO: implement using has_many association
14
14
  # has_many :variants, class_name: 'PDC::V1::ReleaseVariant',
15
- # uri: "#{api_path}/release-variants/?release=:release_id"
15
+ # uri: "#{api_path}/release-variants/?release=:release_id"
16
16
  end
17
17
  end
18
18
  end
@@ -0,0 +1,9 @@
1
+ module PDC::V1
2
+ class ReleaseRpmMapping < PDC::Base
3
+ attributes :compose, :mapping
4
+
5
+ def self.uri
6
+ @uri = PDC.config.site + '/rest_api/v1/releases/(:release_id)/rpm-mapping/(:package)/'
7
+ end
8
+ end
9
+ end
@@ -22,7 +22,6 @@ module PDC::V1
22
22
  # attribute_rename :release, :release_id
23
23
 
24
24
  # belongs_to :release, class_name: 'PDC::V1::Release',
25
- # uri: "#{api_path}/releases/:release_id"
25
+ # uri: "#{api_path}/releases/:release_id"
26
26
  end
27
27
  end
28
-
data/lib/pdc/v1.rb CHANGED
@@ -4,5 +4,6 @@ module PDC
4
4
  require 'pdc/v1/arch'
5
5
  require 'pdc/v1/release'
6
6
  require 'pdc/v1/release_variant'
7
+ require 'pdc/v1/release_rpm_mapping'
7
8
  end
8
9
  end
data/lib/pdc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PDC
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'.freeze
3
3
  end
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pdc.host.dev.eng.pek2.redhat.com//rest_api/v1/releases/rhel-7.1/rpm%2Dmapping/tuned/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Content-Type:
13
+ - application/json
14
+ User-Agent:
15
+ - Faraday v0.9.2
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ date:
22
+ - Tue, 10 Jan 2017 06:35:08 GMT
23
+ server:
24
+ - Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips mod_auth_kerb/5.4
25
+ mod_wsgi/3.4 Python/2.7.5
26
+ expires:
27
+ - Tue, 10 Jan 2017 06:35:40 GMT
28
+ vary:
29
+ - Accept,Cookie
30
+ last-modified:
31
+ - Tue, 10 Jan 2017 06:35:10 GMT
32
+ allow:
33
+ - GET, HEAD, OPTIONS
34
+ cache-control:
35
+ - max-age=30
36
+ x-frame-options:
37
+ - SAMEORIGIN
38
+ transfer-encoding:
39
+ - chunked
40
+ content-type:
41
+ - application/json
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"compose":"RHEL-7.1-20150219.1","mapping":{"Workstation":{"x86_64":{"tuned-utils":["noarch"],"tuned":["noarch","src"]}},"Workstation-optional":{"x86_64":{"tuned-gtk":["noarch"],"tuned-profiles-compat":["noarch"],"tuned-profiles-atomic":["noarch"],"tuned-utils-systemtap":["noarch"]}},"Server-SAP":{"x86_64":{"tuned-profiles-sap":["noarch"]}},"Server":{"x86_64":{"tuned-utils":["noarch"],"tuned":["noarch","src"]},"s390x":{"tuned-utils":["noarch"],"tuned":["noarch","src"]},"ppc64":{"tuned-utils":["noarch"],"tuned":["noarch","src"]}},"ComputeNode":{"x86_64":{"tuned-utils":["noarch"],"tuned":["noarch","src"]}},"Server-optional":{"x86_64":{"tuned-gtk":["noarch"],"tuned-profiles-compat":["noarch"],"tuned-profiles-atomic":["noarch"],"tuned-utils-systemtap":["noarch"]},"s390x":{"tuned-gtk":["noarch"],"tuned-profiles-compat":["noarch"],"tuned-profiles-atomic":["noarch"],"tuned-utils-systemtap":["noarch"]},"ppc64":{"tuned-gtk":["noarch"],"tuned-profiles-compat":["noarch"],"tuned-profiles-atomic":["noarch"],"tuned-utils-systemtap":["noarch"]}},"Client":{"x86_64":{"tuned-utils":["noarch"],"tuned":["noarch","src"]}},"ComputeNode-optional":{"x86_64":{"tuned-gtk":["noarch"],"tuned-profiles-compat":["noarch"],"tuned-profiles-atomic":["noarch"],"tuned-utils-systemtap":["noarch"]}},"Client-optional":{"x86_64":{"tuned-gtk":["noarch"],"tuned-profiles-compat":["noarch"],"tuned-profiles-atomic":["noarch"],"tuned-utils-systemtap":["noarch"]}}}}'
45
+ http_version:
46
+ recorded_at: Tue, 10 Jan 2017 06:35:44 GMT
47
+ recorded_with: VCR 3.0.3
@@ -147,8 +147,8 @@ describe PDC do
147
147
  PDC::Base.connection.must_equal old_connection
148
148
 
149
149
  new_connection = PDC.configure do |config|
150
- config.site = 'http://localhost:8888'
151
- config.token = :foobar
150
+ config.site = 'http://localhost:8888'
151
+ config.token = :foobar
152
152
  end
153
153
  PDC::Base.connection.must_equal new_connection
154
154
  new_connection.wont_equal old_connection
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe PDC::Resource::AttributeStore do
3
+ describe PDC::Resource::AttributeStore do
4
4
  subject { PDC::Resource::AttributeStore }
5
5
 
6
6
  it '#to_params' do
@@ -165,7 +165,6 @@ describe 'nested hash attributes' do
165
165
  end
166
166
  end
167
167
 
168
-
169
168
  describe 'Custom ValueParser' do
170
169
  subject { CustomParserModel }
171
170
  it 'must return fixnum for age' do
@@ -184,48 +183,49 @@ end
184
183
 
185
184
  # class AttributesTest < MiniTest::Test
186
185
 
187
- # def test_equality
188
- # assert_equal Product.new(id: 2, title: 'Fish'), Product.new(id: 2, title: 'Fish')
189
- # refute_equal Product.new(id: 2, title: 'Fish'), Product.new(id: 1, title: 'Fish')
190
- # refute_equal Product.new(id: 2, title: 'Fish'), 'not_a_spyke_object'
191
- # refute_equal Product.new(id: 2, title: 'Fish'), Image.new(id: 2, title: 'Fish')
192
- # refute_equal Product.new, Product.new
193
- # refute_equal StepImage.new(id: 1), Image.new(id: 1)
194
- # end
195
-
196
- # def test_uniqueness
197
- # product_1 = Product.new(id: 1)
198
- # product_2 = Product.new(id: 1)
199
- # product_3 = Product.new(id: 2)
200
- # image_1 = Image.new(id: 2)
201
- # records = [product_1, product_2, product_3, image_1]
202
- # assert_equal [product_1, product_3, image_1], records.uniq
203
- # end
204
-
205
- # def test_super_with_explicit_attributes
206
- # assert_equal nil, Product.new.description
207
- # end
208
-
209
- # def test_inheriting_explicit_attributes
210
- # assert_equal nil, Image.new.description
211
- # assert_equal nil, Image.new.caption
212
- # assert_raises NoMethodError do
213
- # Image.new.note
214
- # end
215
- # assert_equal nil, StepImage.new.description
216
- # assert_equal nil, StepImage.new.caption
217
- # assert_equal nil, StepImage.new.note
218
- # end
219
-
220
- # def test_inspect
221
- # product = Product.new(id: 2, title: 'Pizza', description: 'Delicious')
222
- # assert_equal '#<Product(products/(:id)) id: 2 title: "Pizza" description: "Delicious">', product.inspect
223
- # product = Product.new
224
- # assert_equal '#<Product(products/(:id)) id: nil >', product.inspect
225
- # require 'pry'; binding.pry
226
- # user = Product.new.build_user
227
- # assert_equal '#<User(users/:uuid) id: nil >', user.inspect
228
- # group = Product.new.groups.build
229
- # assert_equal '#<Group(products/:product_id/groups/(:id)) id: nil product_id: nil>', group.inspect
230
- # end
186
+ # def test_equality
187
+ # assert_equal Product.new(id: 2, title: 'Fish'), Product.new(id: 2, title: 'Fish')
188
+ # refute_equal Product.new(id: 2, title: 'Fish'), Product.new(id: 1, title: 'Fish')
189
+ # refute_equal Product.new(id: 2, title: 'Fish'), 'not_a_spyke_object'
190
+ # refute_equal Product.new(id: 2, title: 'Fish'), Image.new(id: 2, title: 'Fish')
191
+ # refute_equal Product.new, Product.new
192
+ # refute_equal StepImage.new(id: 1), Image.new(id: 1)
193
+ # end
194
+
195
+ # def test_uniqueness
196
+ # product_1 = Product.new(id: 1)
197
+ # product_2 = Product.new(id: 1)
198
+ # product_3 = Product.new(id: 2)
199
+ # image_1 = Image.new(id: 2)
200
+ # records = [product_1, product_2, product_3, image_1]
201
+ # assert_equal [product_1, product_3, image_1], records.uniq
202
+ # end
203
+
204
+ # def test_super_with_explicit_attributes
205
+ # assert_equal nil, Product.new.description
206
+ # end
207
+
208
+ # def test_inheriting_explicit_attributes
209
+ # assert_equal nil, Image.new.description
210
+ # assert_equal nil, Image.new.caption
211
+ # assert_raises NoMethodError do
212
+ # Image.new.note
213
+ # end
214
+ # assert_equal nil, StepImage.new.description
215
+ # assert_equal nil, StepImage.new.caption
216
+ # assert_equal nil, StepImage.new.note
217
+ # end
218
+
219
+ # def test_inspect
220
+ # product = Product.new(id: 2, title: 'Pizza', description: 'Delicious')
221
+ # output = '#<Product(products/(:id)) id: 2 title: "Pizza" description: "Delicious">'
222
+ # assert_equal output, product.inspect
223
+ # product = Product.new
224
+ # assert_equal '#<Product(products/(:id)) id: nil >', product.inspect
225
+ # require 'pry'; binding.pry
226
+ # user = Product.new.build_user
227
+ # assert_equal '#<User(users/:uuid) id: nil >', user.inspect
228
+ # group = Product.new.groups.build
229
+ # assert_equal '#<Group(products/:product_id/groups/(:id)) id: nil product_id: nil>', group.inspect
230
+ # end
231
231
  # end
@@ -28,7 +28,6 @@ def record_cache_access(&block)
28
28
  cache_access
29
29
  end
30
30
 
31
-
32
31
  describe 'Caching' do
33
32
  before do
34
33
  @old_config = PDC.config
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- #WebMock.disable! # enable to re-record
3
+ # WebMock.disable! # enable to re-record
4
4
 
5
5
  describe PDC do
6
6
  before do
@@ -38,7 +38,7 @@ describe PDC do
38
38
  pg2 = arch.page(2)
39
39
  pg2_count = pg2.all.length
40
40
 
41
- arches_count = pg2.count # must return all arches count
41
+ arches_count = pg2.count # must return all arches count
42
42
  arches_count.wont_equal pg2_count
43
43
  end
44
44
  end
@@ -66,7 +66,6 @@ describe CustomPrimaryKeyModel do
66
66
  end
67
67
  end
68
68
 
69
-
70
69
  describe V1::Foobar do
71
70
  subject { V1::Foobar }
72
71
  it 'must have a pkey' do
@@ -14,7 +14,7 @@ describe PDC do
14
14
  let(:release_variant) { PDC::V1::ReleaseVariant }
15
15
 
16
16
  it 'can iterate using each' do
17
- count = arch.count # makes single call
17
+ count = arch.count # makes single call
18
18
 
19
19
  all = arch.scoped.each_with_object([]) do |a, o|
20
20
  o << a
@@ -37,13 +37,13 @@ describe PDC do
37
37
  subject { PDC::V1::Arch }
38
38
  it 'returns resources on that page' do
39
39
  pg2 = subject.page(2)
40
- resources = pg2.contents!
40
+ resources = pg2.contents!
41
41
  resources.length.must_equal 20
42
42
  end
43
43
 
44
44
  it 'should not be in the list of attributes' do
45
45
  pg2 = subject.page(2)
46
- arch = pg2.all.first
46
+ arch = pg2.all.first
47
47
  arch.attributes.wont_include :page
48
48
  arch.attributes.wont_include 'page'
49
49
  end
@@ -17,14 +17,19 @@ describe PDC::Resource::Path do
17
17
  assert_equal '/users/1/recipes', path.expanded
18
18
  end
19
19
 
20
-
21
20
  it 'nested_resource_path' do
22
- assert_equal '/users/1/recipes/2', subject.new('/users/:user_id/recipes/:id', user_id: 1, id: 2).expanded
21
+ expanded_path = subject.new(
22
+ '/users/:user_id/recipes/:id',
23
+ user_id: 1,
24
+ id: 2
25
+ ).expanded
26
+ assert_equal '/users/1/recipes/2', expanded_path
23
27
  end
24
28
 
25
29
  it 'raises if required_params are missing' do
26
- lambda {
27
- subject.new('/users/:user_id/recipes/(:id)', id: 2).expanded
28
- }.must_raise PDC::InvalidPathError, 'Missing required params: user_id in /users/:user_id/recipes/(:id)'
30
+ l = -> { subject.new('/users/:user_id/recipes/(:id)', id: 2).expanded }
31
+
32
+ err = 'Missing required params: user_id in /users/:user_id/recipes/(:id)'
33
+ l.must_raise PDC::InvalidPathError, err
29
34
  end
30
35
  end
@@ -8,11 +8,11 @@ class SearchableModel < Base
8
8
  [
9
9
  { name: 'foobar-1', product: 'prod' },
10
10
  { name: 'foobar-2', product: 'prod' },
11
- { name: 'foobar-3', product: 'prod' },
11
+ { name: 'foobar-3', product: 'prod' }
12
12
  ]
13
13
  end
14
14
 
15
- def self.fetch(params)
15
+ def self.fetch(_params)
16
16
  response = OpenStruct.new(
17
17
  body: { data: fake_data },
18
18
  status: 200,
@@ -26,7 +26,6 @@ end
26
26
  describe SearchableModel do
27
27
  subject { SearchableModel }
28
28
 
29
-
30
29
  describe '#where' do
31
30
  it 'returns a scope with params' do
32
31
  filters = { name: :foobar, age: 10 }
@@ -28,7 +28,7 @@ describe PDC do
28
28
  pg2 = arch.page(2)
29
29
  pg2_count = pg2.all.length
30
30
 
31
- arches_count = pg2.count # must return all arches count
31
+ arches_count = pg2.count # must return all arches count
32
32
  arches_count.wont_equal pg2_count
33
33
  end
34
34
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe PDC::V1::ReleaseRpmMapping do
4
+ before do
5
+ VCR.insert_cassette fixture_name
6
+ end
7
+
8
+ after do
9
+ VCR.eject_cassette
10
+ end
11
+
12
+ let(:mapping) { PDC::V1::ReleaseRpmMapping.where(release_id: 'rhel-7.1', package: 'tuned').first }
13
+ it 'must has compose' do
14
+ mapping.mapping.must_be_instance_of OpenStruct
15
+ end
16
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- #WebMock.disable! # enable to re-record
3
+ # WebMock.disable! # enable to re-record
4
4
 
5
5
  describe PDC::V1::Release do
6
6
  before do
@@ -47,7 +47,7 @@ describe PDC::V1::Release do
47
47
  rhel7_1 = release.find('rhel-7.1')
48
48
  variants = rhel7_1.variants.all
49
49
  variants.length.must_equal 12
50
- releases = variants.map {|v| v.release }
50
+ releases = variants.map(&:release)
51
51
  releases.must_equal [rhel7_1] * variants.length
52
52
  end
53
53
  end