active_remote 7.0.0 → 7.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/{ruby.yml → main.yml} +15 -6
  3. data/.rubocop.yml +2 -27
  4. data/.standard.yml +2 -0
  5. data/CHANGES.md +190 -53
  6. data/README.md +6 -5
  7. data/Rakefile +2 -5
  8. data/active_remote.gemspec +17 -20
  9. data/lib/active_remote/association.rb +3 -3
  10. data/lib/active_remote/base.rb +12 -12
  11. data/lib/active_remote/dirty.rb +2 -2
  12. data/lib/active_remote/dsl.rb +14 -14
  13. data/lib/active_remote/integration.rb +7 -7
  14. data/lib/active_remote/persistence.rb +7 -7
  15. data/lib/active_remote/query_attributes.rb +3 -3
  16. data/lib/active_remote/rpc.rb +2 -3
  17. data/lib/active_remote/rpc_adapters/protobuf_adapter.rb +2 -2
  18. data/lib/active_remote/search.rb +25 -8
  19. data/lib/active_remote/serializers/protobuf.rb +10 -9
  20. data/lib/active_remote/validations.rb +2 -2
  21. data/lib/active_remote/version.rb +1 -1
  22. data/spec/lib/active_remote/association_spec.rb +25 -25
  23. data/spec/lib/active_remote/dirty_spec.rb +8 -8
  24. data/spec/lib/active_remote/dsl_spec.rb +7 -7
  25. data/spec/lib/active_remote/errors_spec.rb +2 -2
  26. data/spec/lib/active_remote/integration_spec.rb +2 -2
  27. data/spec/lib/active_remote/persistence_spec.rb +34 -34
  28. data/spec/lib/active_remote/primary_key_spec.rb +2 -2
  29. data/spec/lib/active_remote/rpc_adapters/protobuf_adapter_spec.rb +1 -1
  30. data/spec/lib/active_remote/rpc_spec.rb +13 -15
  31. data/spec/lib/active_remote/scope_keys_spec.rb +2 -2
  32. data/spec/lib/active_remote/search_spec.rb +31 -4
  33. data/spec/lib/active_remote/serialization_spec.rb +2 -2
  34. data/spec/lib/active_remote/serializers/protobuf_spec.rb +7 -7
  35. data/spec/lib/active_remote/validations_spec.rb +1 -1
  36. data/spec/support/models/author.rb +3 -3
  37. data/spec/support/models/category.rb +3 -3
  38. data/spec/support/models/default_author.rb +3 -3
  39. data/spec/support/models/post.rb +4 -4
  40. data/spec/support/protobuf/author.pb.rb +5 -11
  41. data/spec/support/protobuf/category.pb.rb +5 -11
  42. data/spec/support/protobuf/error.pb.rb +1 -6
  43. data/spec/support/protobuf/post.pb.rb +6 -12
  44. data/spec/support/protobuf/serializer.pb.rb +1 -8
  45. data/spec/support/protobuf/tag.pb.rb +5 -11
  46. metadata +29 -80
  47. data/.travis.yml +0 -5
@@ -9,7 +9,7 @@ module ActiveRemote
9
9
  # versioning is off. Accepts any of the symbols in <tt>Time::DATE_FORMATS</tt>.
10
10
  #
11
11
  # This is +:usec+, by default.
12
- class_attribute :cache_timestamp_format, :instance_writer => false, :default => :usec
12
+ class_attribute :cache_timestamp_format, instance_writer: false, default: :usec
13
13
 
14
14
  ##
15
15
  # :singleton-method:
@@ -17,7 +17,7 @@ module ActiveRemote
17
17
  # by a changing version in the #cache_version method.
18
18
  #
19
19
  # This is +false+, by default until Rails 6.0.
20
- class_attribute :cache_versioning, :instance_writer => false, :default => false
20
+ class_attribute :cache_versioning, instance_writer: false, default: false
21
21
  end
22
22
 
23
23
  # Returns a +String+, which Action Pack uses for constructing a URL to this
@@ -60,10 +60,10 @@ module ActiveRemote
60
60
  # Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available)
61
61
  #
62
62
  def cache_key
63
- case
64
- when new_record? then
63
+ if new_record?
64
+
65
65
  "#{model_name.cache_key}/new"
66
- when ::ActiveRemote.config.default_cache_key_updated_at? && (self.respond_to?(:[]) && timestamp = self["updated_at"]) then
66
+ elsif ::ActiveRemote.config.default_cache_key_updated_at? && (respond_to?(:[]) && (timestamp = self["updated_at"]))
67
67
  timestamp = timestamp.utc.to_fs(self.class.cache_timestamp_format)
68
68
  "#{model_name.cache_key}/#{send(primary_key)}-#{timestamp}"
69
69
  else
@@ -123,8 +123,8 @@ module ActiveRemote
123
123
  else
124
124
  define_method :to_param do
125
125
  if (default = super()) &&
126
- (result = send(method_name).to_s).present? &&
127
- (param = result.squish.parameterize.truncate(20, :separator => /-/, :omission => "")).present?
126
+ (result = send(method_name).to_s).present? &&
127
+ (param = result.squish.parameterize.truncate(20, separator: /-/, omission: "")).present?
128
128
  "#{default}-#{param}"
129
129
  else
130
130
  default
@@ -28,7 +28,7 @@ module ActiveRemote
28
28
  # The newly created record is returned if it was successfully saved or not.
29
29
  #
30
30
  def create(attributes)
31
- remote = self.new(attributes)
31
+ remote = new(attributes)
32
32
  remote.save
33
33
  remote
34
34
  end
@@ -40,7 +40,7 @@ module ActiveRemote
40
40
  # an ActiveRemote::RemoteRecordNotSaved exception.
41
41
  #
42
42
  def create!(attributes)
43
- remote = self.new(attributes)
43
+ remote = new(attributes)
44
44
  remote.save!
45
45
  remote
46
46
  end
@@ -49,8 +49,8 @@ module ActiveRemote
49
49
  # when retrieving records that already exist, so @new_record is set to false.
50
50
  #
51
51
  def instantiate(new_attributes = {}, options = {})
52
- attributes = self.build_from_rpc(new_attributes)
53
- new_object = self.allocate.init_with(attributes)
52
+ attributes = build_from_rpc(new_attributes)
53
+ new_object = allocate.init_with(attributes)
54
54
  new_object.readonly! if options[:readonly]
55
55
 
56
56
  new_object
@@ -220,8 +220,8 @@ module ActiveRemote
220
220
  raise ReadOnlyRemoteRecord if readonly?
221
221
 
222
222
  name = name.to_s
223
- send("#{name}=", value)
224
- save(:validate => false)
223
+ send(:"#{name}=", value)
224
+ save(validate: false)
225
225
  end
226
226
 
227
227
  # Updates the attributes of the remote record from the passed-in hash and
@@ -244,7 +244,7 @@ module ActiveRemote
244
244
  end
245
245
  alias_method :update!, :update_attributes!
246
246
 
247
- private
247
+ private
248
248
 
249
249
  # Handles creating a remote object and serializing it's attributes and
250
250
  # errors from the response.
@@ -25,14 +25,14 @@ module ActiveRemote
25
25
  value = self[attr_name]
26
26
 
27
27
  case value
28
- when true then true
29
- when false, nil then false
28
+ when true then true
29
+ when false, nil then false
30
30
  else
31
31
  value.present?
32
32
  end
33
33
  end
34
34
 
35
- private
35
+ private
36
36
 
37
37
  def attribute?(attribute_name)
38
38
  query_attribute(attribute_name)
@@ -11,13 +11,12 @@ module ActiveRemote
11
11
 
12
12
  module ClassMethods
13
13
  # Builds an attribute hash that be assigned directly
14
- # to an object from an rpc response
14
+ # to an object from an RPC response
15
15
  def build_from_rpc(values)
16
16
  values = values.stringify_keys
17
17
 
18
- attribute_names.inject(_default_attributes.deep_dup) do |attributes, name|
18
+ attribute_names.each_with_object(_default_attributes.deep_dup) do |name, attributes|
19
19
  attributes.write_from_database(name, values[name])
20
- attributes
21
20
  end
22
21
  end
23
22
 
@@ -8,7 +8,7 @@ module ActiveRemote
8
8
  attr_reader :service_class
9
9
  attr_accessor :endpoints
10
10
 
11
- delegate :client, :to => :service_class
11
+ delegate :client, to: :service_class
12
12
 
13
13
  ##
14
14
  # Constructor!
@@ -41,7 +41,7 @@ module ActiveRemote
41
41
  response
42
42
  end
43
43
 
44
- private
44
+ private
45
45
 
46
46
  # Return a protobuf request object for the given rpc request.
47
47
  #
@@ -25,12 +25,29 @@ module ActiveRemote
25
25
  # Tag.find(Generic::Remote::TagRequest.new(:guid => 'foo'))
26
26
  #
27
27
  def find(args)
28
- remote = self.search(args).first
28
+ remote = search(args).first
29
29
  raise RemoteRecordNotFound, self if remote.nil?
30
30
 
31
31
  remote
32
32
  end
33
33
 
34
+ # Tries to load the first record; if it fails, returns nil.
35
+ #
36
+ # ====Examples
37
+ #
38
+ # # A single hash
39
+ # Tag.find_by(:guid => 'foo')
40
+ #
41
+ # # Active remote object
42
+ # Tag.find_by(Tag.new(:guid => 'foo'))
43
+ #
44
+ # # Protobuf object
45
+ # Tag.find_by(Generic::Remote::TagRequest.new(:guid => 'foo'))
46
+ #
47
+ def find_by(args)
48
+ search(args).first
49
+ end
50
+
34
51
  # Tries to load the first record; if it fails, then create is called
35
52
  # with the same arguments.
36
53
  #
@@ -43,8 +60,8 @@ module ActiveRemote
43
60
  # Tag.first_or_create(Generic::Remote::TagRequest.new(:name => 'foo'))
44
61
  #
45
62
  def first_or_create(attributes)
46
- remote = self.search(attributes).first
47
- remote ||= self.create(attributes)
63
+ remote = search(attributes).first
64
+ remote ||= create(attributes)
48
65
  remote
49
66
  end
50
67
 
@@ -52,8 +69,8 @@ module ActiveRemote
52
69
  # with the same arguments.
53
70
  #
54
71
  def first_or_create!(attributes)
55
- remote = self.search(attributes).first
56
- remote ||= self.create!(attributes)
72
+ remote = search(attributes).first
73
+ remote ||= create!(attributes)
57
74
  remote
58
75
  end
59
76
 
@@ -69,8 +86,8 @@ module ActiveRemote
69
86
  # Tag.first_or_initialize(Generic::Remote::TagRequest.new(:name => 'foo'))
70
87
  #
71
88
  def first_or_initialize(attributes)
72
- remote = self.search(attributes).first
73
- remote ||= self.new(attributes)
89
+ remote = search(attributes).first
90
+ remote ||= new(attributes)
74
91
  remote
75
92
  end
76
93
 
@@ -117,7 +134,7 @@ module ActiveRemote
117
134
  #
118
135
  def reload
119
136
  fresh_object = self.class.find(scope_key_hash)
120
- @attributes = fresh_object.instance_variable_get("@attributes")
137
+ @attributes = fresh_object.instance_variable_get(:@attributes)
121
138
  self
122
139
  end
123
140
  end
@@ -50,7 +50,7 @@ module ActiveRemote
50
50
  # Class methods
51
51
  #
52
52
  def self.from_attributes(message_class, attributes)
53
- fields = self.new(message_class, attributes)
53
+ fields = new(message_class, attributes)
54
54
  fields.from_attributes
55
55
  end
56
56
 
@@ -58,12 +58,11 @@ module ActiveRemote
58
58
  # Instance methods
59
59
  #
60
60
  def from_attributes
61
- attributes.inject({}) do |hash, (key, value)|
61
+ attributes.each_with_object({}) do |(key, value), hash|
62
62
  field = message_class.get_field(key, true) # Check extension fields, too
63
63
  value = Field.from_attribute(field, value) if field
64
64
 
65
65
  hash[key] = value
66
- hash
67
66
  end
68
67
  end
69
68
  end
@@ -83,7 +82,7 @@ module ActiveRemote
83
82
  # Class methods
84
83
  #
85
84
  def self.from_attribute(field, value)
86
- field = self.new(field, value)
85
+ field = new(field, value)
87
86
  field.from_attribute
88
87
  end
89
88
 
@@ -91,19 +90,21 @@ module ActiveRemote
91
90
  # Instance methods
92
91
  #
93
92
  def from_attribute
94
- case
95
- when field.repeated_message? then
93
+ if field.repeated_message?
94
+
96
95
  repeated_message_value
97
- when field.message? then
96
+ elsif field.message?
97
+
98
98
  message_value
99
- when field.repeated? then
99
+ elsif field.repeated?
100
+
100
101
  repeated_value.map { |value| cast(value) }
101
102
  else
102
103
  cast_value
103
104
  end
104
105
  end
105
106
 
106
- private
107
+ private
107
108
 
108
109
  def cast(value)
109
110
  type.cast(value)
@@ -45,13 +45,13 @@ module ActiveRemote
45
45
  #
46
46
  def valid?(context = nil)
47
47
  context ||= (new_record? ? :create : :update)
48
- output = super(context)
48
+ output = super
49
49
  errors.empty? && output
50
50
  end
51
51
 
52
52
  alias_method :validate, :valid?
53
53
 
54
- protected
54
+ protected
55
55
 
56
56
  def raise_validation_error
57
57
  fail ActiveRemote::RemoteRecordInvalid, self
@@ -1,3 +1,3 @@
1
1
  module ActiveRemote
2
- VERSION = "7.0.0"
2
+ VERSION = "7.1.0"
3
3
  end
@@ -9,18 +9,18 @@ describe ActiveRemote::Association do
9
9
  let(:author_guid) { "AUT-123" }
10
10
  let(:user_guid) { "USR-123" }
11
11
  let(:default_category_guid) { "CAT-123" }
12
- subject { Post.new(:author_guid => author_guid, :user_guid => user_guid) }
12
+ subject { Post.new(author_guid: author_guid, user_guid: user_guid) }
13
13
 
14
14
  it { is_expected.to respond_to(:author) }
15
15
  it { is_expected.to respond_to(:author=) }
16
16
 
17
17
  it "searches the associated model for a single record" do
18
- expect(Author).to receive(:search).with({:guid => subject.author_guid}).and_return(records)
18
+ expect(Author).to receive(:search).with({guid: subject.author_guid}).and_return(records)
19
19
  expect(subject.author).to eq record
20
20
  end
21
21
 
22
22
  it "memoizes the result record" do
23
- expect(Author).to receive(:search).once.with({:guid => subject.author_guid}).and_return(records)
23
+ expect(Author).to receive(:search).once.with({guid: subject.author_guid}).and_return(records)
24
24
  3.times { expect(subject.author).to eq record }
25
25
  end
26
26
 
@@ -34,7 +34,7 @@ describe ActiveRemote::Association do
34
34
 
35
35
  context "when the search is empty" do
36
36
  it "returns a nil" do
37
- expect(Author).to receive(:search).with({:guid => subject.author_guid}).and_return([])
37
+ expect(Author).to receive(:search).with({guid: subject.author_guid}).and_return([])
38
38
  expect(subject.author).to be_nil
39
39
  end
40
40
  end
@@ -43,7 +43,7 @@ describe ActiveRemote::Association do
43
43
  it { is_expected.to respond_to(:user) }
44
44
 
45
45
  it "searches the associated model for multiple records" do
46
- expect(Author).to receive(:search).with({:guid => subject.author_guid, :user_guid => subject.user_guid}).and_return(records)
46
+ expect(Author).to receive(:search).with({guid: subject.author_guid, user_guid: subject.user_guid}).and_return(records)
47
47
  expect(subject.user).to eq(record)
48
48
  end
49
49
 
@@ -68,16 +68,16 @@ describe ActiveRemote::Association do
68
68
  context "specific association with class name" do
69
69
  let(:author_guid) { "AUT-456" }
70
70
 
71
- subject { Post.new(:author_guid => author_guid) }
71
+ subject { Post.new(author_guid: author_guid) }
72
72
  it { is_expected.to respond_to(:coauthor) }
73
73
 
74
74
  it "searches the associated model for a single record" do
75
- expect(Author).to receive(:search).with({:guid => subject.author_guid}).and_return(records)
75
+ expect(Author).to receive(:search).with({guid: subject.author_guid}).and_return(records)
76
76
  expect(subject.coauthor).to eq record
77
77
  end
78
78
 
79
79
  it "creates a setter method" do
80
- author = Author.new(:guid => author_guid)
80
+ author = Author.new(guid: author_guid)
81
81
  subject.coauthor = author
82
82
  expect(subject.coauthor).to eq(author)
83
83
  end
@@ -86,11 +86,11 @@ describe ActiveRemote::Association do
86
86
  context "specific association with class name and foreign_key" do
87
87
  let(:author_guid) { "AUT-456" }
88
88
 
89
- subject { Post.new(:bestseller_guid => author_guid) }
89
+ subject { Post.new(bestseller_guid: author_guid) }
90
90
  it { is_expected.to respond_to(:bestseller) }
91
91
 
92
92
  it "searches the associated model for a single record" do
93
- expect(Author).to receive(:search).with({:guid => subject.bestseller_guid}).and_return(records)
93
+ expect(Author).to receive(:search).with({guid: subject.bestseller_guid}).and_return(records)
94
94
  expect(subject.bestseller).to eq record
95
95
  end
96
96
  end
@@ -101,18 +101,18 @@ describe ActiveRemote::Association do
101
101
  let(:guid) { "AUT-123" }
102
102
  let(:user_guid) { "USR-123" }
103
103
 
104
- subject { Author.new(:guid => guid, :user_guid => user_guid) }
104
+ subject { Author.new(guid: guid, user_guid: user_guid) }
105
105
 
106
106
  it { is_expected.to respond_to(:posts) }
107
107
  it { is_expected.to respond_to(:posts=) }
108
108
 
109
109
  it "searches the associated model for all associated records" do
110
- expect(Post).to receive(:search).with({:author_guid => subject.guid}).and_return(records)
110
+ expect(Post).to receive(:search).with({author_guid: subject.guid}).and_return(records)
111
111
  expect(subject.posts).to eq records
112
112
  end
113
113
 
114
114
  it "memoizes the result record" do
115
- expect(Post).to receive(:search).once.with({:author_guid => subject.guid}).and_return(records)
115
+ expect(Post).to receive(:search).once.with({author_guid: subject.guid}).and_return(records)
116
116
  3.times { expect(subject.posts).to eq records }
117
117
  end
118
118
 
@@ -126,7 +126,7 @@ describe ActiveRemote::Association do
126
126
 
127
127
  context "when the search is empty" do
128
128
  it "returns the empty set" do
129
- expect(Post).to receive(:search).with({:author_guid => subject.guid}).and_return([])
129
+ expect(Post).to receive(:search).with({author_guid: subject.guid}).and_return([])
130
130
  expect(subject.posts).to be_empty
131
131
  end
132
132
  end
@@ -135,7 +135,7 @@ describe ActiveRemote::Association do
135
135
  it { is_expected.to respond_to(:flagged_posts) }
136
136
 
137
137
  it "searches the associated model for a single record" do
138
- expect(Post).to receive(:search).with({:author_guid => subject.guid}).and_return([])
138
+ expect(Post).to receive(:search).with({author_guid: subject.guid}).and_return([])
139
139
  expect(subject.flagged_posts).to be_empty
140
140
  end
141
141
  end
@@ -144,7 +144,7 @@ describe ActiveRemote::Association do
144
144
  it { is_expected.to respond_to(:bestseller_posts) }
145
145
 
146
146
  it "searches the associated model for multiple record" do
147
- expect(Post).to receive(:search).with({:bestseller_guid => subject.guid}).and_return(records)
147
+ expect(Post).to receive(:search).with({bestseller_guid: subject.guid}).and_return(records)
148
148
  expect(subject.bestseller_posts).to eq(records)
149
149
  end
150
150
  end
@@ -153,7 +153,7 @@ describe ActiveRemote::Association do
153
153
  it { is_expected.to respond_to(:user_posts) }
154
154
 
155
155
  it "searches the associated model for multiple records" do
156
- expect(Post).to receive(:search).with({:author_guid => subject.guid, :user_guid => subject.user_guid}).and_return(records)
156
+ expect(Post).to receive(:search).with({author_guid: subject.guid, user_guid: subject.user_guid}).and_return(records)
157
157
  expect(subject.user_posts).to eq(records)
158
158
  end
159
159
 
@@ -180,8 +180,8 @@ describe ActiveRemote::Association do
180
180
  let(:user_guid) { "USR-123" }
181
181
  let(:category_attributes) {
182
182
  {
183
- :guid => guid,
184
- :user_guid => user_guid
183
+ guid: guid,
184
+ user_guid: user_guid
185
185
  }
186
186
  }
187
187
 
@@ -191,12 +191,12 @@ describe ActiveRemote::Association do
191
191
  it { is_expected.to respond_to(:author=) }
192
192
 
193
193
  it "searches the associated model for all associated records" do
194
- expect(Author).to receive(:search).with({:category_guid => subject.guid}).and_return(records)
194
+ expect(Author).to receive(:search).with({category_guid: subject.guid}).and_return(records)
195
195
  expect(subject.author).to eq record
196
196
  end
197
197
 
198
198
  it "memoizes the result record" do
199
- expect(Author).to receive(:search).once.with({:category_guid => subject.guid}).and_return(records)
199
+ expect(Author).to receive(:search).once.with({category_guid: subject.guid}).and_return(records)
200
200
  3.times { expect(subject.author).to eq record }
201
201
  end
202
202
 
@@ -210,7 +210,7 @@ describe ActiveRemote::Association do
210
210
 
211
211
  context "when the search is empty" do
212
212
  it "returns a nil value" do
213
- expect(Author).to receive(:search).with({:category_guid => subject.guid}).and_return([])
213
+ expect(Author).to receive(:search).with({category_guid: subject.guid}).and_return([])
214
214
  expect(subject.author).to be_nil
215
215
  end
216
216
  end
@@ -219,7 +219,7 @@ describe ActiveRemote::Association do
219
219
  it { is_expected.to respond_to(:senior_author) }
220
220
 
221
221
  it "searches the associated model for a single record" do
222
- expect(Author).to receive(:search).with({:category_guid => subject.guid}).and_return(records)
222
+ expect(Author).to receive(:search).with({category_guid: subject.guid}).and_return(records)
223
223
  expect(subject.senior_author).to eq record
224
224
  end
225
225
 
@@ -232,7 +232,7 @@ describe ActiveRemote::Association do
232
232
  it { is_expected.to respond_to(:primary_editor) }
233
233
 
234
234
  it "searches the associated model for a single record" do
235
- expect(Author).to receive(:search).with({:editor_guid => subject.guid}).and_return(records)
235
+ expect(Author).to receive(:search).with({editor_guid: subject.guid}).and_return(records)
236
236
  expect(subject.primary_editor).to eq record
237
237
  end
238
238
  end
@@ -241,7 +241,7 @@ describe ActiveRemote::Association do
241
241
  it { is_expected.to respond_to(:chief_editor) }
242
242
 
243
243
  it "searches the associated model for multiple records" do
244
- expect(Author).to receive(:search).with({:chief_editor_guid => subject.guid, :user_guid => subject.user_guid}).and_return(records)
244
+ expect(Author).to receive(:search).with({chief_editor_guid: subject.guid, user_guid: subject.user_guid}).and_return(records)
245
245
  expect(subject.chief_editor).to eq(record)
246
246
  end
247
247
 
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe ActiveRemote::Dirty do
4
4
  context "when writing attributes through the setter" do
5
- subject { Post.new(:name => "foo") }
5
+ subject { Post.new(name: "foo") }
6
6
 
7
7
  before do
8
8
  subject.changes_applied
@@ -23,7 +23,7 @@ describe ActiveRemote::Dirty do
23
23
  end
24
24
 
25
25
  context "when writing attributes directly" do
26
- subject { Post.new(:name => "foo") }
26
+ subject { Post.new(name: "foo") }
27
27
 
28
28
  before do
29
29
  subject.changes_applied
@@ -44,10 +44,10 @@ describe ActiveRemote::Dirty do
44
44
  end
45
45
 
46
46
  describe "#reload" do
47
- subject { Post.new(:name => "foo") }
47
+ subject { Post.new(name: "foo") }
48
48
 
49
49
  before do
50
- allow(Post).to receive(:find).and_return(Post.new(:name => "foo"))
50
+ allow(Post).to receive(:find).and_return(Post.new(name: "foo"))
51
51
  subject.reload
52
52
  end
53
53
 
@@ -55,10 +55,10 @@ describe ActiveRemote::Dirty do
55
55
  end
56
56
 
57
57
  describe "#remote" do
58
- let(:post) { Post.new(:name => "foo") }
58
+ let(:post) { Post.new(name: "foo") }
59
59
 
60
60
  it "clears changes information" do
61
- allow(post).to receive(:remote_call).and_return(::Generic::Remote::Post.new(:name => "foo"))
61
+ allow(post).to receive(:remote_call).and_return(::Generic::Remote::Post.new(name: "foo"))
62
62
  expect { post.remote(:reload) }.to change { post.changed? }.to(false)
63
63
  end
64
64
  end
@@ -66,7 +66,7 @@ describe ActiveRemote::Dirty do
66
66
  describe "#save" do
67
67
  let!(:changes) { subject.changes }
68
68
 
69
- subject { Post.new(:name => "foo") }
69
+ subject { Post.new(name: "foo") }
70
70
 
71
71
  before do
72
72
  allow(subject).to receive(:create_or_update).and_return(true)
@@ -80,7 +80,7 @@ describe ActiveRemote::Dirty do
80
80
  describe "#save!" do
81
81
  let!(:changes) { subject.changes }
82
82
 
83
- subject { Post.new(:name => "foo") }
83
+ subject { Post.new(name: "foo") }
84
84
 
85
85
  before do
86
86
  allow(subject).to receive(:save).and_return(true)
@@ -24,19 +24,19 @@ describe ActiveRemote::DSL do
24
24
  describe ".endpoints" do
25
25
  it "has default values" do
26
26
  expect(Tag.endpoints).to eq(
27
- :create => :create,
28
- :delete => :delete,
29
- :destroy => :destroy,
30
- :search => :search,
31
- :update => :update
27
+ create: :create,
28
+ delete: :delete,
29
+ destroy: :destroy,
30
+ search: :search,
31
+ update: :update
32
32
  )
33
33
  end
34
34
 
35
35
  context "given a new value for an endpoint" do
36
- after { Tag.endpoints(:create => :create) }
36
+ after { Tag.endpoints(create: :create) }
37
37
 
38
38
  it "overwrites default values" do
39
- Tag.endpoints(:create => :register)
39
+ Tag.endpoints(create: :register)
40
40
  expect(Tag.endpoints[:create]).to eq(:register)
41
41
  end
42
42
  end
@@ -4,8 +4,8 @@ describe ::ActiveRemote::RemoteRecordNotSaved do
4
4
  let(:record) { ::Tag.new }
5
5
 
6
6
  before do
7
- record.errors.add(:base, :invalid, :message => "Some error one!")
8
- record.errors.add(:base, :invalid, :message => "Some error two!")
7
+ record.errors.add(:base, :invalid, message: "Some error one!")
8
+ record.errors.add(:base, :invalid, message: "Some error two!")
9
9
  end
10
10
 
11
11
  context "when an active remote record is used" do
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe ::ActiveRemote::Integration do
4
4
  let(:guid) { "GUID-derp" }
5
- let(:tag) { ::Tag.new(:guid => guid) }
5
+ let(:tag) { ::Tag.new(guid: guid) }
6
6
 
7
7
  subject { tag }
8
8
 
@@ -46,7 +46,7 @@ describe ::ActiveRemote::Integration do
46
46
  end
47
47
 
48
48
  describe "#cache_key_with_version" do
49
- let(:tag) { ::Tag.new(:guid => guid, :updated_at => ::DateTime.current) }
49
+ let(:tag) { ::Tag.new(guid: guid, updated_at: ::DateTime.current) }
50
50
 
51
51
  specify { expect(subject).to respond_to(:cache_key_with_version) }
52
52