daylight 0.9.0.rc1 → 0.9.0.rc2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a160432a89b2031c5897592fcf570c6de41cef69
4
- data.tar.gz: 52b800d5206e184a13cb0eaf1dc721b4af820897
3
+ metadata.gz: 6bf59fd5ce024afa3fc59ddb2d66363f8f5d5209
4
+ data.tar.gz: 7dfddabc42f86705bf30f51cdbe41cd879e58bb6
5
5
  SHA512:
6
- metadata.gz: 9b5aa0bfa3e0524fc7d2b86052fb7137bbcdd75c86d21d34346b89cf81240c4311f2b5554b2d56144f2f0565a0668e9ef8c7939e1f815e50b17ee6a7a67deae1
7
- data.tar.gz: e97de04202276572bd099e6b9244b840087110effa934d73949b11150714e3f21ccff519ed119f70817cb60bb2b0691612c1daf97ecfd01a80d0470c1cc8bd72
6
+ metadata.gz: 97b17af7fc52458bf4f0b255aaf404fa55821ca6b28b2be6885ecadd3618a22ccbc613b8c64ef011aebc4b12e905164ce29619598fd6b63ed19a0c169d28d5c9
7
+ data.tar.gz: 757ffe41b8d52bc4fd6e373a3a2041541c1549e8f7878d88fa9c45d5d5ccdca7b546a58164588e59c30c52a62433adf5321bb4b889efe543bcc20dd1f4aed39a
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Daylight
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/daylight.svg)](http://badge.fury.io/rb/daylight)
4
+ [![Build Status](https://travis-ci.org/att-cloud/daylight.svg?branch=master)](https://travis-ci.org/att-cloud/daylight)
5
+
3
6
  Daylight extends Rails and ActiveResource to allow your client API to perform
4
7
  akin to ActiveRecord
5
8
 
data/doc/develop.md CHANGED
@@ -681,7 +681,7 @@ Once all client models are setup, associationed models will be fetched and
681
681
  initialized:
682
682
 
683
683
  ````ruby
684
- post = Daylight::Post.first
684
+ post = API::V1::Post.first
685
685
 
686
686
  post.blog #=> #<API::V1::Blog:0x007fd8ca4717d8 ...>
687
687
  post.comments #=> [#<API::V1::Comment:0x007fd8ca538ce8...>, ...]
@@ -705,7 +705,7 @@ in `ActiveRecord`:
705
705
  The `User` will be correctly retrieved for the `author` association:
706
706
 
707
707
  ````ruby
708
- Daylight::Post.first.author #=> #<API::V1::User:0x007fd8ca543e90 ...>
708
+ API::V1::Post.first.author #=> #<API::V1::User:0x007fd8ca543e90 ...>
709
709
  ````
710
710
 
711
711
  #### Through Associations
@@ -774,7 +774,7 @@ associations.
774
774
 
775
775
  #### Scopes and Remoted Methods
776
776
 
777
- Adding adding scopes and remoted methods are very simple.
777
+ Adding scopes and remoted methods is very simple.
778
778
 
779
779
 
780
780
  Given the `ActiveRecord` model setup:
data/doc/principles.md CHANGED
@@ -25,9 +25,9 @@ be reviewed and changed as the need arises.
25
25
 
26
26
  4. Expected behavior of dependent software _should_ not change when extended
27
27
  * Developers should not be surprised by unexpected results from software they know and love
28
- * Exception is to fix exposed problems in the underlying software or if the benefits are highly valueble
29
- * Changes to the underlying software can be triggered through configuration
30
- * **Examples**:`AutosaveAssociationFix`, `ActiveResource::Base#has_one`, `ReflectionExt`
28
+ * Exception is to fix exposed problems in the underlying software or if the benefits are highly valueble, consistant
29
+ * Changes to the underlying software (or default behavior) can be triggered through configuration
30
+ * **Examples**:`AutosaveAssociationFix`, `ActiveResource::Base#has_one`, `ReflectionExt`, `Daylight::Association::ClassMethods#has_many`
31
31
 
32
32
  5. Extend dependent software (gems) by including changes using `ActiveSupport::Concerns`
33
33
  * Concerns show in ancestor lists and can chain to original methods via `super`
data/doc/usage.md CHANGED
@@ -53,8 +53,8 @@ refer to these client models in the following `Post` example:
53
53
 
54
54
  has_one :company, through: :blog
55
55
 
56
- has_many :comments
57
- has_many :commenters, through: :associated, class_name: 'api/v1/user'
56
+ has_many :comments, use: 'resource'
57
+ has_many :commenters, class_name: 'api/v1/user'
58
58
 
59
59
  remote :top_comments, class_name: 'api/v1/comment'
60
60
  end
@@ -354,9 +354,9 @@ original result set.
354
354
 
355
355
  ## Associations
356
356
 
357
- Associations work as they do today in `ActiveResource` One one notable
358
- exception. Client models that have the `has_many through: :associated` will
359
- perform the lookup for associated objects server-side.
357
+ Associations work as they do today in `ActiveResource` with one notable
358
+ exception: client models will perform the lookup for associated objects
359
+ server-side.
360
360
 
361
361
  > NOTE: This is useful if conditions or configuration is defined on the
362
362
  > server-side model to perform correctly. Refer to
@@ -371,6 +371,18 @@ Daylight adds additional functionality directly on the association:
371
371
  Currently, `ActiveResource` will only let you associate a resource by setting
372
372
  the `foreign_key` directly on a model.
373
373
 
374
+ If you want to use the original behavior where the `foreign_key` is used to
375
+ lookup up associated objects, you can pass the `use: 'resource'` to the
376
+ `has_many` association.
377
+
378
+ ````ruby
379
+ has_many :comments, use: 'resource'
380
+ ````
381
+
382
+ Like the default `ActiveResource` behavior, this will return a
383
+ `ActiveResource::Collection` that cannot be [chained](#chaining), nor can
384
+ [nested resources](#nested-resources) be set in the collection.
385
+
374
386
  ### Nested Resources
375
387
 
376
388
  When manipulating resources on an association, we call these _Nested Resources_.
@@ -829,7 +841,7 @@ Given the client model:
829
841
  scopes :published
830
842
  remote :top_comments
831
843
 
832
- has_many :author, through: :associated
844
+ has_many :author
833
845
  end
834
846
  ````
835
847
 
data/lib/daylight/api.rb CHANGED
@@ -151,10 +151,13 @@ class Daylight::API < ActiveResource::Base
151
151
  raise "Unsupported version #{v} is not one of #{versions.join(', ')}"
152
152
  end
153
153
 
154
- @version = v.upcase
155
- version_path = "/#{v.downcase}/".gsub(/\/+/, '/')
154
+ # Set the version string as the path prefix.
155
+ #
156
+ # Explicitly adding the endpoint.path here because ActiveResource ignores it
157
+ # when a prefix path has been set.
158
+ set_prefix "/#{endpoint.path}/#{v.downcase}/".gsub(/\/+/, '/')
156
159
 
157
- set_prefix version_path
160
+ @version = v.upcase
158
161
  end
159
162
 
160
163
  ##
@@ -55,8 +55,8 @@ module Daylight::Associations
55
55
  # ActiveResource::Associations#has_many
56
56
 
57
57
  def has_many name, options={}
58
- through = options.delete(:through).to_s
59
- return super unless through == 'associated'
58
+ through = options.delete(:use).to_s
59
+ return super if through == 'resource'
60
60
 
61
61
  create_reflection(:has_many, name, options).tap do |reflection|
62
62
  nested_attribute_key = "#{reflection.name}_attributes"
@@ -1,5 +1,5 @@
1
1
  ##
2
- # Runs `alias_api` in the console during API development to re-alias the to the
2
+ # Runs `alias_api` in the console during API development to re-alias the
3
3
  # reloaded constants. Otherwise, they will hold onto the old un-reloaded
4
4
  # constants in memory.
5
5
  #
data/lib/daylight/mock.rb CHANGED
@@ -90,6 +90,8 @@ module Daylight
90
90
  :created
91
91
  when :put
92
92
  :updated
93
+ when :patch
94
+ :patched
93
95
  when :delete
94
96
  :deleted
95
97
  end
@@ -97,6 +99,9 @@ module Daylight
97
99
 
98
100
  private
99
101
  def model_class(model_name)
102
+ candidate_name = [Daylight::API.namespace, Daylight::API.version, model_name.classify].join("::")
103
+ candidate_name.constantize
104
+ rescue
100
105
  model_name.classify.constantize
101
106
  end
102
107
 
@@ -141,6 +146,14 @@ module Daylight
141
146
  respond_with(status: 201)
142
147
  end
143
148
 
149
+ def process_patched
150
+ clazz = model_class(path_parts.resource)
151
+ data = post_data[path_parts.resource.singularize]
152
+ @target_object = new_record(clazz, data.merge(id: path_parts.id.to_i))
153
+
154
+ respond_with(status: 204)
155
+ end
156
+
144
157
  def process_deleted
145
158
  clazz = model_class(path_parts.resource)
146
159
  @target_object = new_record(clazz, id: path_parts.id.to_i)
@@ -190,7 +203,7 @@ module Daylight
190
203
  end
191
204
  end
192
205
 
193
- %w[created updated associated indexed shown deleted].each do |action|
206
+ %w[created updated patched associated indexed shown deleted].each do |action|
194
207
  define_method action do |resource|
195
208
  @storage[action.to_s][resource.to_s.pluralize]
196
209
  end
@@ -243,7 +256,7 @@ module Daylight
243
256
  def setup_minitest
244
257
  require 'webmock/minitest'
245
258
 
246
- clazz = MiniTest::Test rescue MiniTest::Unit::TestCase
259
+ clazz = MiniTest::Test rescue Minitest::Test
247
260
 
248
261
  clazz.class_eval do
249
262
  include Daylight::Mock
@@ -274,7 +287,7 @@ module Daylight
274
287
  # it does matching.
275
288
  def site_with_credentials
276
289
  @site_with_credentials ||= Daylight::API.site.dup.tap do |site|
277
- site.userinfo = "#{Daylight::API.user}:#{Daylight::API.password}"
290
+ site.userinfo = [Daylight::API.user, Daylight::API.password].compact.join(':')
278
291
  site.to_s
279
292
  end
280
293
  end
@@ -1,5 +1,5 @@
1
1
  ##
2
- # Support for handling ActiveRecord-like refinementmes and chaining them together
2
+ # Support for handling ActiveRecord-like refinements and chaining them together
3
3
  # These refinements include: +where+, +find_by+, +order+, +limit+, and +offset+
4
4
  # Named +scopes+ are also supported.
5
5
  module Daylight::Refinements
@@ -3,7 +3,7 @@ module Daylight
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
5
  PATCH = 0
6
- BUILD = 'rc1'
6
+ BUILD = 'rc2'
7
7
 
8
8
  Daylight::VERSION = STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
9
  end
@@ -34,8 +34,8 @@
34
34
  # controller name. If you need to customize these, you can change them:
35
35
  #
36
36
  # class ExampleController < APIController
37
- # self.model_name = :news
38
- # self.record_name = :post
37
+ # set_model_name :news
38
+ # set_record_name :post
39
39
  #
40
40
  # handles :index
41
41
  # end
@@ -50,11 +50,7 @@ class Daylight::APIController < ApplicationController
50
50
  include VersionedUrlFor
51
51
 
52
52
  API_ACTIONS = [:index, :create, :show, :update, :destroy, :associated, :remoted].freeze
53
- class_attribute :record_name, :collection_name, :model_name
54
-
55
- alias_method :set_record_name, :record_name= #:nodoc:
56
- alias_method :set_collection_name, :collection_name= #:nodoc:
57
- alias_method :set_model_name, :model_name= #:nodoc:
53
+ class_attribute :record_name, :collection_name, :model_name, instance_predicate: false
58
54
 
59
55
  ##
60
56
  # Ensure messaging when sending unknown attributes or improper SQL
@@ -87,6 +83,11 @@ class Daylight::APIController < ApplicationController
87
83
 
88
84
 
89
85
  class << self
86
+
87
+ alias_method :set_record_name, :record_name= #:nodoc:
88
+ alias_method :set_collection_name, :collection_name= #:nodoc:
89
+ alias_method :set_model_name, :model_name= #:nodoc:
90
+
90
91
  protected
91
92
  ##
92
93
  # Turns on common actions based on subclass needs (sets them as public methods).
@@ -1,22 +1,27 @@
1
1
  ##
2
2
  # Methods in which to refine a query by a model's scopes or attributes
3
3
  module Daylight::Refiners
4
- extend ActiveSupport::Concern
5
-
6
- module Extension
7
- extend ActiveSupport::Concern
8
-
9
- module ClassMethods
10
- ##
11
- # Extends subclasses of ActiveRecord::Base with the Daylight::Refiners features
12
- # This hooks into the `inherited` method chain to perform this extension.
13
- def inherited active_record
14
- active_record.send(:include, Daylight::Refiners)
15
- super
16
- end
4
+
5
+ ##
6
+ # Prepend class methods onto ActiveResource
7
+ def self.prepended(base)
8
+ class << base
9
+ prepend ClassMethods
17
10
  end
18
11
  end
19
12
 
13
+ ##
14
+ # Helper to follow a named association if it exists
15
+ def associated name
16
+ raise ArgumentError, "Unknown association: #{name}" unless self.class.reflection_names.include? name.to_s
17
+ public_send(name)
18
+ end
19
+
20
+ def remoted method
21
+ raise ArgumentError, "Unknown remote: #{method}" unless self.class.remoted?(method)
22
+ public_send(method)
23
+ end
24
+
20
25
  ##
21
26
  # Helper to determine whether a request to use an attribute is valid or invalid
22
27
  # Keeps track of which attributes are part of the request.
@@ -170,17 +175,9 @@ module Daylight::Refiners
170
175
  end
171
176
  end
172
177
 
173
- included do
174
- ##
175
- # Helper to follow a named association if it exists
176
- def associated name
177
- raise ArgumentError, "Unknown association: #{name}" unless self.class.reflection_names.include? name.to_s
178
- public_send(name)
179
- end
178
+ end
180
179
 
181
- def remoted method
182
- raise ArgumentError, "Unknown remote: #{method}" unless self.class.remoted?(method)
183
- public_send(method)
184
- end
185
- end
180
+ # Mix into ActiveRecord::Base
181
+ ActiveSupport.on_load :active_record do
182
+ prepend Daylight::Refiners
186
183
  end
@@ -18,12 +18,14 @@ module Daylight
18
18
 
19
19
  autoload :Helpers
20
20
  autoload :Params
21
- autoload :Refiners
22
21
  autoload :APIController
22
+
23
+ eager_autoload do
24
+ autoload :Refiners
25
+ end
23
26
  end
24
27
 
25
28
  # A convinience alias that will avoids any name collisions
26
29
  APIController = Daylight::APIController unless defined?(APIController)
27
30
 
28
- # Hook into ActiveRecord::Base `inherited` chain to extend subclasses
29
- ActiveRecord::Base.send(:include, Daylight::Refiners::Extension)
31
+ Daylight.eager_load!
@@ -3,10 +3,8 @@ module ReadOnlyAttributes
3
3
 
4
4
  included do
5
5
  # place the read_only attributes along side the other class_attributes for a Serializer
6
- class << self
7
- class_attribute :_read_only
8
- self._read_only = []
9
- end
6
+ class_attribute :_read_only
7
+ self._read_only = []
10
8
  end
11
9
 
12
10
  module ClassMethods
@@ -1 +1 @@
1
- Daylight::API.setup! namespace: 'test_api', password: 'test', endpoint: 'http://daylight.test', version: 'v1'
1
+ Daylight::API.setup! namespace: 'test_api', endpoint: 'http://daylight.test', version: 'v1'
@@ -5,7 +5,7 @@ describe DaylightDocumentation::DocumentationHelper do
5
5
  class TestModel < ActiveRecord::Base
6
6
  include Daylight::Associations
7
7
 
8
- has_many :users
8
+ has_many :users, use: 'resource'
9
9
 
10
10
  # override attribute names so we don't have to mock
11
11
  # out the database table
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class TestDescendant < Daylight::API
4
- self.password = nil
5
-
6
4
  has_one :child, class_name: 'TestDescendant'
7
5
  end
8
6
 
@@ -53,13 +51,28 @@ describe Daylight::API do
53
51
 
54
52
  it 'sets up site and prefix' do
55
53
  silence_warnings do
56
- Daylight::API.setup! endpoint: 'http://api.Daylight.test/', version: 'v1'
54
+ Daylight::API.setup! endpoint: 'http://api.daylight.test/', version: 'v1'
57
55
  end
58
56
 
59
- Daylight::API.site.to_s.should == 'http://api.Daylight.test/'
57
+ Daylight::API.site.to_s.should == 'http://api.daylight.test/'
60
58
  Daylight::API.prefix.should == '/v1/'
61
59
  end
62
60
 
61
+ it 'handles sites with paths' do
62
+ silence_warnings do
63
+ Daylight::API.setup! endpoint: 'http://api.daylight.test/myapi', version: 'v1'
64
+ end
65
+
66
+ Daylight::API.site.to_s.should == 'http://api.daylight.test/myapi'
67
+ Daylight::API.prefix.should == '/myapi/v1/'
68
+
69
+ stub_request(:get, %r{#{TestDescendant.site}}).to_return(body: {}.to_json)
70
+
71
+ TestDescendant.find(1)
72
+
73
+ assert_requested :get, 'http://api.daylight.test/myapi/v1/test_descendants/1.json'
74
+ end
75
+
63
76
  it 'sets request_root_in_json to true by default' do
64
77
  Daylight::API.request_root_in_json.should == true
65
78
  TestAPIDescendantJSON.request_root_in_json.should == true
@@ -146,7 +159,7 @@ describe Daylight::API do
146
159
  describe 'metadata' do
147
160
  before do
148
161
  data = {
149
- test_descendant: { name: "foo", immutable: "readme"},
162
+ test_descendant: { id: 1, name: "foo", immutable: "readme"},
150
163
  meta: { test_descendant: { read_only: ["immutable"], nested_resources: ["test_resource"] } }
151
164
  }
152
165
 
@@ -3,16 +3,14 @@ require 'spec_helper'
3
3
  describe Daylight::Associations do
4
4
 
5
5
  class RelatedTestClass < Daylight::API
6
- self.password = nil
7
6
  self.include_format_in_path = false
8
7
  end
9
8
 
10
9
  class AssociationsTestClass < Daylight::API
11
- self.password = nil
12
10
  self.include_format_in_path = false
13
11
 
14
- has_many :related_test_classes, through: :associated
15
- has_many :things, class_name: 'RelatedTestClass', through: :associated
12
+ has_many :related_test_classes
13
+ has_many :things, class_name: 'RelatedTestClass'
16
14
  belongs_to :parent, class_name: 'RelatedTestClass'
17
15
  has_one :grandparent, class_name: 'RelatedTestClass', through: :parent
18
16
  has_one :associate, class_name: 'RelatedTestClass'
@@ -3,8 +3,6 @@ require 'spec_helper'
3
3
  describe Daylight::Collection do
4
4
 
5
5
  class CollectionTestClass < Daylight::API
6
- self.password = nil
7
-
8
6
  scopes :foo, :bar
9
7
  end
10
8
 
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
  require 'daylight/mock'
3
3
 
4
4
  describe Daylight::Mock do
5
- class MiniTest::Spec ; end
6
- class MiniTest::Test ; end
5
+ class Minitest::Spec ; end
6
+ class Minitest::Test ; end
7
7
 
8
8
  class TestClient < Daylight::API
9
- has_many :test_client_children, through: :associated, class_name: 'TestClientChild'
9
+ has_many :test_client_children, class_name: 'TestClientChild'
10
10
  end
11
11
 
12
12
  class TestClientChild < Daylight::API ; end
@@ -64,6 +64,15 @@ describe Daylight::Mock do
64
64
  end
65
65
  end
66
66
 
67
+ describe 'patch' do
68
+ let(:data) { {test_client: {name: 'wibble'}}.to_json }
69
+
70
+ it "updates the attributes" do
71
+ object = TestClient.find(1)
72
+ object.patch(:test, {}, data).should be_true
73
+ end
74
+ end
75
+
67
76
  describe 'create' do
68
77
  it "returns the created object" do
69
78
  object = TestClient.new(name: 'foo')
@@ -125,11 +134,10 @@ describe Daylight::Mock do
125
134
  daylight_mock.last_created(:test_clients).target_object.code.should == 'foo'
126
135
  end
127
136
  end
128
-
129
137
  end
130
138
 
131
139
  describe 'minitest setup' do
132
- let(:minitest) { Minitest::Test.new }
140
+ let(:minitest) { Minitest::Test.new(:foo) rescue MiniTest::Test.new }
133
141
 
134
142
  it "adds our mock methods to Minitest::Test" do
135
143
  minitest.should respond_to(:daylight_mock)
@@ -140,5 +148,4 @@ describe Daylight::Mock do
140
148
  minitest.before_setup
141
149
  end
142
150
  end
143
-
144
151
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class TestReadOnly < Daylight::API
4
- self.password = nil
5
-
6
4
  has_one :child, class_name: 'TestReadOnly'
7
5
  end
8
6
 
@@ -3,8 +3,6 @@ require 'spec_helper'
3
3
  describe Daylight do
4
4
 
5
5
  class RefinementTestClass < Daylight::API
6
- self.password = nil
7
-
8
6
  scopes :foo, :bar
9
7
  end
10
8
 
@@ -11,8 +11,8 @@ describe Daylight::ReflectionExt do
11
11
  class TestAPI::V1::Comment < Daylight::API; end
12
12
 
13
13
  class TestAPI::V1::Post < Daylight::API
14
- has_many :comments
15
- has_many :top_comments, class_name: 'test_api/v1/comment'
14
+ has_many :comments, use: 'resource'
15
+ has_many :top_comments, use: 'resource', class_name: 'test_api/v1/comment'
16
16
 
17
17
  belongs_to :test_fallback
18
18
  end
@@ -3,10 +3,8 @@ require 'spec_helper'
3
3
  describe Daylight::ResourceProxy do
4
4
 
5
5
  class ProxyTestClass < Daylight::API
6
- self.password = nil
7
-
8
6
  scopes :foo, :bar
9
- has_many :related_proxy_test_classes, through: :associated
7
+ has_many :related_proxy_test_classes
10
8
 
11
9
  def self.wibble
12
10
  'wibble'
@@ -15,17 +13,11 @@ describe Daylight::ResourceProxy do
15
13
 
16
14
  class RelatedProxyTestClass < Daylight::API
17
15
  scopes :baz
18
-
19
- self.password = nil
20
16
  end
21
17
 
22
- class ProxyTestClass1 < Daylight::API
23
- self.password = nil
24
- end
18
+ class ProxyTestClass1 < Daylight::API ; end
25
19
 
26
- class ProxyTestClass2 < Daylight::API
27
- self.password = nil
28
- end
20
+ class ProxyTestClass2 < Daylight::API ; end
29
21
 
30
22
  before do
31
23
  data = [{name: 'one'}, {name: 'two'}]
@@ -27,16 +27,16 @@ end
27
27
  class TestCasesController < Daylight::APIController
28
28
  handles :create, :update, :destroy
29
29
 
30
- self.model_name = :case
31
- self.record_name = :result
32
- self.collection_name = :results
30
+ set_model_name :case
31
+ set_record_name :result
32
+ set_collection_name :results
33
33
  end
34
34
 
35
35
  class TestAppRecord < ActiveResource::Base
36
36
  end
37
37
 
38
38
  class TestErrorsController < Daylight::APIController
39
- self.model_name = :test_app_record
39
+ set_model_name :test_app_record
40
40
 
41
41
  def raise_argument_error
42
42
  raise ArgumentError.new('this is my message')
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class RefinerMockActiveRecordBase
4
- include Daylight::Refiners::Extension
4
+ prepend Daylight::Refiners
5
5
 
6
6
  def self.scope(name, body, &block); end
7
7
  def self.where(*args); end
@@ -56,10 +56,21 @@ describe Daylight::Refiners::AttributeSeive do
56
56
  end
57
57
 
58
58
  describe Daylight::Refiners do
59
+ class AnotherRefinersTestClass < RefinerMockActiveRecordBase
60
+ scope :scope_c, -> { 'c' }
61
+ end
62
+
59
63
  it 'tracks registered scopes' do
60
64
  RefinersTestClass.registered_scopes.should == %w[scope_a scope_b]
61
65
  end
62
66
 
67
+ it 'keeps track of different scopes on different classes' do
68
+ RefinersTestClass.registered_scopes.should == %w[scope_a scope_b]
69
+ AnotherRefinersTestClass.registered_scopes.should == %w[scope_c]
70
+
71
+ RefinerMockActiveRecordBase.scope :scope_x, -> { 'x' }
72
+ end
73
+
63
74
  it 'returns true if scoped? finds a match' do
64
75
  RefinersTestClass.should be_scoped(:scope_a)
65
76
  RefinersTestClass.should_not be_scoped(:foo)
@@ -100,7 +111,7 @@ describe Daylight::Refiners do
100
111
  end
101
112
 
102
113
  it 'raises an error if an unknown attribute is supplied' do
103
- expect { RefinersTestClass.filter_by(baz: 'wibble') }.to raise_error(ArgumentError, 'Unknown key: baz')
114
+ expect { RefinersTestClass.filter_by(baz: 'wibble') }.to raise_error(ArgumentError, /Unknown key: "?baz"?/)
104
115
  end
105
116
 
106
117
  it 'applies where clause for all supplied attributes' do
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,9 @@ require 'rspec/autorun'
11
11
 
12
12
  require 'webmock/rspec'
13
13
 
14
+ require 'factory_girl'
15
+ require 'faker'
16
+
14
17
  WebMock.disable_net_connect!
15
18
 
16
19
  # Load additional rspec configuration files first
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.rc1
4
+ version: 0.9.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid MacDonald
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-25 00:00:00.000000000 Z
12
+ date: 2014-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ~>
19
- - !ruby/object:Gem::Version
20
- version: 4.0.1
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ~>
26
- - !ruby/object:Gem::Version
27
- version: 4.0.1
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: activeresource
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -193,6 +179,20 @@ dependencies:
193
179
  - - '>='
194
180
  - !ruby/object:Gem::Version
195
181
  version: '0'
182
+ - !ruby/object:Gem::Dependency
183
+ name: rake
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
196
  description: |2
197
197
  Daylight extends Rails on the server and ActiveResource in the client to
198
198
  allow your ActiveResource client API to perform more like to ActiveRecord
@@ -263,7 +263,6 @@ files:
263
263
  - doc/testing.md
264
264
  - doc/usage.md
265
265
  - README.md
266
- - spec/config/dependencies.rb
267
266
  - spec/config/factory_girl.rb
268
267
  - spec/config/simplecov_rcov.rb
269
268
  - spec/config/test_api.rb
@@ -354,7 +353,6 @@ signing_key:
354
353
  specification_version: 4
355
354
  summary: Allow ActiveResource to function more like ActiveRecord
356
355
  test_files:
357
- - spec/config/dependencies.rb
358
356
  - spec/config/factory_girl.rb
359
357
  - spec/config/simplecov_rcov.rb
360
358
  - spec/config/test_api.rb
@@ -1,2 +0,0 @@
1
- require 'factory_girl'
2
- require 'faker'