placid 0.0.6 → 0.0.7

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.
data/.gitignore CHANGED
@@ -6,3 +6,5 @@ coverage/*
6
6
  doc/*
7
7
  *~
8
8
  pkg/*
9
+ .ruby-gemset
10
+ .ruby-version
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
data/History.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Placid History
2
2
  ==============
3
3
 
4
+ 0.0.7
5
+ -----
6
+
7
+ - Some support for coercion (requires Hashie >= 2.0.4)
8
+ - Allow '/' in request URL paths to pass through unescaped
9
+ - Add PlacidError base exception class
10
+
11
+
4
12
  0.0.6
5
13
  -----
6
14
 
data/Rakefile CHANGED
@@ -4,9 +4,12 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new(:spec) do |t|
5
5
  t.pattern = 'spec/**/*.rb'
6
6
  t.rspec_opts = ['--color', '--format doc']
7
- t.rcov = true
8
- t.rcov_opts = [
9
- '--exclude /.gem/,/gems/,spec',
10
- ]
7
+ if RUBY_VERSION < "1.9"
8
+ t.rcov = true
9
+ t.rcov_opts = [
10
+ '--exclude /.gem/,/gems/,spec',
11
+ ]
12
+ end
11
13
  end
12
14
 
15
+ task :default => :spec
@@ -1,6 +1,10 @@
1
1
  module Placid
2
+ # Generic Placid exception
3
+ class PlacidError < RuntimeError
4
+ end
5
+
2
6
  # Error parsing a JSON response
3
- class JSONParseError < RuntimeError
7
+ class JSONParseError < PlacidError
4
8
  def initialize(message, data='')
5
9
  super(message)
6
10
  @data = data
@@ -9,6 +13,10 @@ module Placid
9
13
  end
10
14
 
11
15
  # Error connecting to the REST API
12
- class RestConnectionError < RuntimeError
16
+ class RestConnectionError < PlacidError
17
+ end
18
+
19
+ # Error with request path
20
+ class PathError < PlacidError
13
21
  end
14
22
  end
@@ -7,13 +7,14 @@ require 'placid/exceptions'
7
7
 
8
8
  module Placid
9
9
  module Helper
10
- # Escape any special URI characters in `text` and return the escaped string.
11
- # `nil` is treated as an empty string.
10
+ # Escape any special URI characters in `text` (except for '/') and return
11
+ # the escaped string. `nil` is treated as an empty string.
12
12
  #
13
13
  # @return [String]
14
14
  #
15
15
  def escape(text)
16
- URI.escape(text.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
16
+ # Treat '/' as unreserved
17
+ URI.escape(text.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}/]"))
17
18
  end
18
19
 
19
20
  # Return a full URL for a REST API request to the given path, relative to
@@ -57,8 +58,13 @@ module Placid
57
58
  # If there is a problem connecting to the REST API
58
59
  # @raise [JSONParseError]
59
60
  # If the response from the REST API cannot be parsed as JSON
61
+ # @raise [PathError]
62
+ # If any part of the path is nil
60
63
  #
61
64
  def request(method, *path)
65
+ if path.any? {|p| p.nil?}
66
+ raise PathError, "Cannot use nil as a path component"
67
+ end
62
68
  method = method.to_sym
63
69
  params = path.extract_options!
64
70
  params = {:params => params} if method == :get
@@ -5,7 +5,7 @@ require 'active_support/inflector' # for `pluralize` and `underscore`
5
5
  module Placid
6
6
  # Base class for RESTful models
7
7
  class Model < Hashie::Mash
8
-
8
+ include Hashie::Extensions::Coercion
9
9
  include Placid::Helper
10
10
  extend Placid::Helper
11
11
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "placid"
3
- s.version = "0.0.6"
3
+ s.version = "0.0.7"
4
4
  s.summary = "Models from REST"
5
5
  s.description = <<-EOS
6
6
  Placid is an ActiveRecord-ish model using a REST API for storage. The REST API
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.homepage = "http://github.com/a-e/placid"
13
13
  s.platform = Gem::Platform::RUBY
14
14
 
15
- s.add_dependency 'hashie'
15
+ s.add_dependency 'hashie', '>= 2.0.4'
16
16
  s.add_dependency 'json'
17
17
  s.add_dependency 'rest-client'
18
18
  s.add_dependency 'activesupport'
@@ -20,7 +20,12 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency 'rspec'
21
21
  s.add_development_dependency 'yard' # For documentation
22
22
  s.add_development_dependency 'redcarpet' # For YARD / Markdown
23
- s.add_development_dependency 'rcov'
23
+
24
+ if RUBY_VERSION < "1.9"
25
+ s.add_development_dependency 'rcov'
26
+ else
27
+ s.add_development_dependency 'simplecov'
28
+ end
24
29
 
25
30
  s.files = `git ls-files`.split("\n")
26
31
 
@@ -3,7 +3,11 @@ require 'spec_helper'
3
3
  describe Placid::Helper do
4
4
  describe "#escape" do
5
5
  it "escapes all URI reserved characters" do
6
- escape(";/?:@&=+$,[]").should == "%3B%2F%3F%3A%40%26%3D%2B%24%2C%5B%5D"
6
+ escape(";?:@&=+$,[]").should == "%3B%3F%3A%40%26%3D%2B%24%2C%5B%5D"
7
+ end
8
+
9
+ it "does not escape '/'" do
10
+ escape("foo/bar/baz").should == "foo/bar/baz"
7
11
  end
8
12
  end
9
13
 
@@ -13,7 +17,11 @@ describe Placid::Helper do
13
17
  end
14
18
 
15
19
  it "escapes path components to make them URI-safe" do
16
- get_url('a b', 'c:d', 'e/f').should == 'http://localhost/a%20b/c%3Ad/e%2Ff'
20
+ get_url('a b', 'c:d').should == 'http://localhost/a%20b/c%3Ad'
21
+ end
22
+
23
+ it "does not escape '/'" do
24
+ get_url('a/b', 'c/d').should == 'http://localhost/a/b/c/d'
17
25
  end
18
26
  end
19
27
 
@@ -45,18 +53,24 @@ describe Placid::Helper do
45
53
  json.should == ["fail"]
46
54
  end
47
55
 
48
- it "returns a RestConnectionError when connection is refused" do
49
- RestClient.stub(:get).and_raise(Errno::ECONNREFUSED)
56
+ it "preserves '/' in path components" do
57
+ RestClient.should_receive(:post).
58
+ with('http://localhost/foo/bar/baz', {:x => '5'}).
59
+ and_return('{}')
60
+ request('post', 'foo/bar', 'baz', :x => '5')
61
+ end
62
+
63
+ it "raises a PathError if there's a nil in the path array" do
50
64
  lambda do
51
- json = request('get')
52
- end.should raise_error(Placid::RestConnectionError, /Could not connect/)
65
+ request('get', 'foo', nil, 'bar')
66
+ end.should raise_error(Placid::PathError, /Cannot use nil as a path component/)
53
67
  end
54
68
 
55
- it "passes other exceptions through" do
56
- RestClient.stub(:get).and_raise(URI::InvalidURIError)
69
+ it "raises a RestConnectionError when connection is refused" do
70
+ RestClient.stub(:get).and_raise(Errno::ECONNREFUSED)
57
71
  lambda do
58
72
  json = request('get')
59
- end.should raise_error(URI::InvalidURIError)
73
+ end.should raise_error(Placid::RestConnectionError, /Could not connect/)
60
74
  end
61
75
 
62
76
  it "raises a JSONParseError if there is no response" do
@@ -66,6 +80,13 @@ describe Placid::Helper do
66
80
  end.should raise_error(Placid::JSONParseError, /Cannot parse/)
67
81
  end
68
82
 
83
+ it "passes other exceptions through" do
84
+ RestClient.stub(:get).and_raise(URI::InvalidURIError)
85
+ lambda do
86
+ json = request('get')
87
+ end.should raise_error(URI::InvalidURIError)
88
+ end
89
+
69
90
  it "accepts a params hash as the last argument" do
70
91
  RestClient.should_receive(:post).
71
92
  with('http://localhost/foo', {:bar => 'hi'}).
@@ -4,6 +4,8 @@ describe Placid::Model do
4
4
  class Thing < Placid::Model
5
5
  end
6
6
 
7
+ subject { Thing }
8
+
7
9
  context "Instance methods" do
8
10
  describe "#id" do
9
11
  it "returns the value in the custom unique ID field" do
@@ -17,8 +19,8 @@ describe Placid::Model do
17
19
  end
18
20
 
19
21
  it "returns the value in the :id field if no custom field was set" do
20
- thing_1 = Thing.new(:id => '111')
21
- thing_2 = Thing.new(:id => '222')
22
+ thing_1 = subject.new(:id => '111')
23
+ thing_2 = subject.new(:id => '222')
22
24
  thing_1.id.should == '111'
23
25
  thing_2.id.should == '222'
24
26
  end
@@ -26,90 +28,90 @@ describe Placid::Model do
26
28
 
27
29
  describe "#save" do
28
30
  it "creates a new instance if one doesn't exist" do
29
- thing = Thing.new(:id => '123')
30
- Thing.stub(:find => nil)
31
- Thing.should_receive(:create).
31
+ thing = subject.new(:id => '123')
32
+ subject.stub(:find => nil)
33
+ subject.should_receive(:create).
32
34
  with({'id' => '123'}).
33
- and_return(Thing.new)
35
+ and_return(subject.new)
34
36
  thing.save
35
37
  end
36
38
 
37
39
  it "updates an existing instance" do
38
- thing = Thing.new(:id => '123')
39
- Thing.stub(:find => {:id => '123'})
40
- Thing.should_receive(:update).
40
+ thing = subject.new(:id => '123')
41
+ subject.stub(:find => {:id => '123'})
42
+ subject.should_receive(:update).
41
43
  with('123', {'id' => '123'}).
42
- and_return(Thing.new)
44
+ and_return(subject.new)
43
45
  thing.save
44
46
  end
45
47
 
46
48
  it "merges saved attributes on create" do
47
- thing = Thing.new(:id => '123')
49
+ thing = subject.new(:id => '123')
48
50
  saved_attribs = {'id' => '123', 'name' => 'foo'}
49
- Thing.stub(:find => nil)
50
- Thing.should_receive(:create).
51
+ subject.stub(:find => nil)
52
+ subject.should_receive(:create).
51
53
  with({'id' => '123'}).
52
- and_return(Thing.new(saved_attribs))
54
+ and_return(subject.new(saved_attribs))
53
55
  thing.save
54
56
  thing.should == saved_attribs
55
57
  end
56
58
 
57
59
  it "merges saved attributes on update" do
58
- thing = Thing.new(:id => '123')
60
+ thing = subject.new(:id => '123')
59
61
  saved_attribs = {'id' => '123', 'name' => 'foo'}
60
- Thing.stub(:find => {:id => '123'})
61
- Thing.should_receive(:update).
62
+ subject.stub(:find => {:id => '123'})
63
+ subject.should_receive(:update).
62
64
  with('123', {'id' => '123'}).
63
- and_return(Thing.new(saved_attribs))
65
+ and_return(subject.new(saved_attribs))
64
66
  thing.save
65
67
  thing.should == saved_attribs
66
68
  end
67
69
 
68
70
  it "returns false if errors were reported" do
69
- thing = Thing.new
70
- Thing.stub(:find => nil)
71
- Thing.stub(:request).with(:post, 'thing', {}) { {'errors' => 'Missing id'} }
71
+ thing = subject.new
72
+ subject.stub(:find => nil)
73
+ subject.stub(:request).with(:post, 'thing', {}) { {'errors' => 'Missing id'} }
72
74
  thing.save.should be_false
73
75
  end
74
76
 
75
77
  it "returns true if errors is an empty list" do
76
- thing = Thing.new(:id => '123')
77
- Thing.stub(:find => nil)
78
- Thing.stub(:request).with(:post, 'thing', {'id' => '123'}) { {'errors' => []} }
78
+ thing = subject.new(:id => '123')
79
+ subject.stub(:find => nil)
80
+ subject.stub(:request).with(:post, 'thing', {'id' => '123'}) { {'errors' => []} }
79
81
  thing.save.should be_true
80
82
  end
81
83
 
82
84
  it "returns true if no errors were reported" do
83
- thing = Thing.new(:id => '123')
84
- Thing.stub(:find => nil)
85
- Thing.stub(:request).with(:post, 'thing', {'id' => '123'}) { {} }
85
+ thing = subject.new(:id => '123')
86
+ subject.stub(:find => nil)
87
+ subject.stub(:request).with(:post, 'thing', {'id' => '123'}) { {} }
86
88
  thing.save.should be_true
87
89
  end
88
90
  end
89
91
 
90
92
  describe "#required?" do
91
93
  it "true if the given field is implicitly required" do
92
- Thing.stub(:meta => {:id => {:required => true}})
93
- thing = Thing.new
94
+ subject.stub(:meta => {:id => {:required => true}})
95
+ thing = subject.new
94
96
  thing.required?(:id).should == true
95
97
  end
96
98
 
97
99
  it "false if the given field is explicitly optional" do
98
- Thing.stub(:meta => {:id => {:required => false}})
99
- thing = Thing.new
100
+ subject.stub(:meta => {:id => {:required => false}})
101
+ thing = subject.new
100
102
  thing.required?(:id).should == false
101
103
  end
102
104
 
103
105
  it "false if the given field is implicitly optional" do
104
- Thing.stub(:meta => {:id => {}})
105
- thing = Thing.new
106
+ subject.stub(:meta => {:id => {}})
107
+ thing = subject.new
106
108
  thing.required?(:id).should == false
107
109
  end
108
110
  end
109
111
 
110
112
  describe "#errors=" do
111
113
  it "sets the list of errors on the instance" do
112
- thing = Thing.new
114
+ thing = subject.new
113
115
  thing.errors = ['missing id']
114
116
  thing['errors'].should == ['missing id']
115
117
  end
@@ -117,24 +119,24 @@ describe Placid::Model do
117
119
 
118
120
  describe "#errors" do
119
121
  it "returns errors set on initialization" do
120
- thing = Thing.new(:errors => ['missing id'])
122
+ thing = subject.new(:errors => ['missing id'])
121
123
  thing.errors = ['missing id']
122
124
  thing.errors.should == ['missing id']
123
125
  end
124
126
 
125
127
  it "returns errors set after initialization" do
126
- thing = Thing.new
128
+ thing = subject.new
127
129
  thing.errors = ['missing id']
128
130
  thing.errors.should == ['missing id']
129
131
  end
130
132
 
131
133
  it "returns [] if errors are not set" do
132
- thing = Thing.new
134
+ thing = subject.new
133
135
  thing.errors.should == []
134
136
  end
135
137
 
136
138
  it "returns [] if errors is set to nil" do
137
- thing = Thing.new
139
+ thing = subject.new
138
140
  thing.errors = nil
139
141
  thing.errors.should == []
140
142
  end
@@ -142,23 +144,23 @@ describe Placid::Model do
142
144
 
143
145
  describe "#errors?" do
144
146
  it "returns true if errors is set to a nonempty value" do
145
- thing = Thing.new(:errors => ['missing id'])
147
+ thing = subject.new(:errors => ['missing id'])
146
148
  thing.errors?.should be_true
147
149
  end
148
150
 
149
151
  it "returns false if errors it not set" do
150
- thing = Thing.new
152
+ thing = subject.new
151
153
  thing.errors?.should be_false
152
154
  end
153
155
 
154
156
  it "returns false if errors is set to nil" do
155
- thing = Thing.new
157
+ thing = subject.new
156
158
  thing.errors = nil
157
159
  thing.errors?.should be_false
158
160
  end
159
161
 
160
162
  it "returns false if errors is set to an empty list" do
161
- thing = Thing.new
163
+ thing = subject.new
162
164
  thing.errors = []
163
165
  thing.errors?.should be_false
164
166
  end
@@ -166,7 +168,7 @@ describe Placid::Model do
166
168
 
167
169
  describe "helpers" do
168
170
  it "can call #request on an instance" do
169
- thing = Thing.new
171
+ thing = subject.new
170
172
  RestClient.should_receive(:get).
171
173
  with('http://localhost/thing/foo', {:params => {:x => 'y'}}).
172
174
  and_return('{}')
@@ -207,7 +209,7 @@ describe Placid::Model do
207
209
  RestClient.should_receive(:get).
208
210
  with('http://localhost/thing/meta', {:params => {}}).
209
211
  and_return(JSON(thing_meta))
210
- Thing.meta.should == thing_meta
212
+ subject.meta.should == thing_meta
211
213
  end
212
214
 
213
215
  it "only sends a GET meta request once for the class" do
@@ -216,30 +218,30 @@ describe Placid::Model do
216
218
  }
217
219
  RestClient.stub(:get => JSON(thing_meta))
218
220
  RestClient.should_receive(:get).at_most(:once)
219
- Thing.meta.should == thing_meta
220
- Thing.meta.should == thing_meta
221
- Thing.meta.should == thing_meta
221
+ subject.meta.should == thing_meta
222
+ subject.meta.should == thing_meta
223
+ subject.meta.should == thing_meta
222
224
  end
223
225
 
224
226
  it "stores meta-data separately for each derived class" do
225
227
  class ThingOne < Placid::Model; end
226
228
  class ThingTwo < Placid::Model; end
227
-
228
229
  thing_one_meta = {
229
230
  'one' => {'type' => 'String', 'required' => true}
230
231
  }
231
- RestClient.should_receive(:get).
232
- with('http://localhost/thing_one/meta', {:params => {}}).
233
- and_return(JSON(thing_one_meta))
234
- ThingOne.meta.should == thing_one_meta
235
-
236
232
  thing_two_meta = {
237
233
  'two' => {'type' => 'String', 'required' => false}
238
234
  }
239
- RestClient.should_receive(:get).
235
+ RestClient.stub(:get).
236
+ with('http://localhost/thing_one/meta', {:params => {}}).
237
+ and_return(JSON(thing_one_meta))
238
+ RestClient.stub(:get).
240
239
  with('http://localhost/thing_two/meta', {:params => {}}).
241
240
  and_return(JSON(thing_two_meta))
241
+
242
+ ThingOne.meta.should == thing_one_meta
242
243
  ThingTwo.meta.should == thing_two_meta
244
+ ThingOne.meta.should_not == ThingTwo.meta
243
245
  end
244
246
  end
245
247
 
@@ -250,10 +252,10 @@ describe Placid::Model do
250
252
  {'name' => 'Bar'},
251
253
  ]
252
254
  RestClient.stub(:get => JSON(data))
253
- things = Thing.list
255
+ things = subject.list
254
256
  things.should == data
255
257
  things.each do |thing|
256
- thing.should be_a(Thing)
258
+ thing.should be_a(subject)
257
259
  end
258
260
  end
259
261
  end
@@ -262,8 +264,8 @@ describe Placid::Model do
262
264
  it "returns a Model instance matching the given id" do
263
265
  data = {'name' => 'Foo'}
264
266
  RestClient.stub(:get => JSON(data))
265
- thing = Thing.find(1)
266
- thing.should be_a(Thing)
267
+ thing = subject.find(1)
268
+ thing.should be_a(subject)
267
269
  thing.should == data
268
270
  end
269
271
  end
@@ -273,24 +275,24 @@ describe Placid::Model do
273
275
  it "posted attributes if no attributes were returned" do
274
276
  RestClient.stub(:post => '{}')
275
277
  attrs = {'name' => 'Foo'}
276
- thing = Thing.create(attrs)
277
- thing.should be_a(Thing)
278
+ thing = subject.create(attrs)
279
+ thing.should be_a(subject)
278
280
  thing.should == {'name' => 'Foo'}
279
281
  end
280
282
 
281
283
  it "returned attributes if no attributes were posted" do
282
284
  RestClient.stub(:post => '{"uri": "foo"}')
283
285
  attrs = {}
284
- thing = Thing.create(attrs)
285
- thing.should be_a(Thing)
286
+ thing = subject.create(attrs)
287
+ thing.should be_a(subject)
286
288
  thing.should == {'uri' => 'foo'}
287
289
  end
288
290
 
289
291
  it "original attributes merged with returned attributes" do
290
292
  RestClient.stub(:post => '{"uri": "foo"}')
291
293
  attrs = {'name' => 'Foo'}
292
- thing = Thing.create(attrs)
293
- thing.should be_a(Thing)
294
+ thing = subject.create(attrs)
295
+ thing.should be_a(subject)
294
296
  thing.should == {'name' => 'Foo', 'uri' => 'foo'}
295
297
  end
296
298
  end
@@ -298,8 +300,8 @@ describe Placid::Model do
298
300
  it "sets errors on the Model instance" do
299
301
  data = {'errors' => ['name is required']}
300
302
  RestClient.stub(:post => JSON(data))
301
- thing = Thing.create()
302
- thing.should be_a(Thing)
303
+ thing = subject.create()
304
+ thing.should be_a(subject)
303
305
  thing.errors.should == ['name is required']
304
306
  end
305
307
  end
@@ -309,25 +311,25 @@ describe Placid::Model do
309
311
  it "posted attributes if no attributes were returned" do
310
312
  RestClient.stub(:put => '{}')
311
313
  attrs = {'name' => 'Foo'}
312
- result = Thing.update(1, attrs)
313
- thing = Thing.update(1, attrs)
314
- thing.should be_a(Thing)
314
+ result = subject.update(1, attrs)
315
+ thing = subject.update(1, attrs)
316
+ thing.should be_a(subject)
315
317
  thing.should == {'name' => 'Foo'}
316
318
  end
317
319
 
318
320
  it "returned attributes if no attributes were posted" do
319
321
  RestClient.stub(:put => '{"uri": "foo"}')
320
322
  attrs = {}
321
- thing = Thing.update(1, attrs)
322
- thing.should be_a(Thing)
323
+ thing = subject.update(1, attrs)
324
+ thing.should be_a(subject)
323
325
  thing.should == {'uri' => 'foo'}
324
326
  end
325
327
 
326
328
  it "original attributes merged with returned attributes" do
327
329
  RestClient.stub(:put => '{"uri": "foo"}')
328
330
  attrs = {'name' => 'Foo'}
329
- thing = Thing.update(1, attrs)
330
- thing.should be_a(Thing)
331
+ thing = subject.update(1, attrs)
332
+ thing.should be_a(subject)
331
333
  thing.should == {'name' => 'Foo', 'uri' => 'foo'}
332
334
  end
333
335
  end
@@ -335,8 +337,8 @@ describe Placid::Model do
335
337
  it "sets errors on the Model instance" do
336
338
  data = {'errors' => ['name is required']}
337
339
  RestClient.stub(:put => JSON(data))
338
- thing = Thing.update(1, {})
339
- thing.should be_a(Thing)
340
+ thing = subject.update(1, {})
341
+ thing.should be_a(subject)
340
342
  thing.errors.should == ['name is required']
341
343
  end
342
344
  end
@@ -345,7 +347,43 @@ describe Placid::Model do
345
347
  it "returns the parsed JSON response" do
346
348
  data = {'status' => 'ok'}
347
349
  RestClient.stub(:delete => JSON(data))
348
- Thing.destroy(1).should == data
350
+ subject.destroy(1).should == data
351
+ end
352
+ end
353
+
354
+ describe "#coerce" do
355
+ before(:each) do
356
+ class User < Placid::Model
357
+ end
358
+ class Tweet < Placid::Model
359
+ coerce_key :user, 'user', User
360
+ end
361
+ @user_hash = {:email => 'foo@bar.com'}
362
+ end
363
+
364
+ it "coerces during initialization" do
365
+ pending("Awaiting release of https://github.com/intridea/hashie/issues/95")
366
+ tweet = Tweet.new({:message => "Hello", :user => @user_hash})
367
+ #tweet = Tweet.new('user' => @user_hash)
368
+ tweet.user.should be_a(User)
369
+ end
370
+
371
+ it "coerces using attribute reference" do
372
+ tweet = Tweet.new
373
+ tweet.user = @user_hash
374
+ tweet.user.should be_a(User)
375
+ end
376
+
377
+ it "coerces using string key" do
378
+ tweet = Tweet.new
379
+ tweet['user'] = @user_hash
380
+ tweet.user.should be_a(User)
381
+ end
382
+
383
+ it "coerces using symbolic key" do
384
+ tweet = Tweet.new
385
+ tweet[:user] = @user_hash
386
+ tweet.user.should be_a(User)
349
387
  end
350
388
  end
351
389
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: placid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Pierce
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-27 00:00:00 Z
18
+ date: 2013-06-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: hashie
@@ -25,10 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- hash: 3
28
+ hash: 7
29
29
  segments:
30
+ - 2
30
31
  - 0
31
- version: "0"
32
+ - 4
33
+ version: 2.0.4
32
34
  type: :runtime
33
35
  version_requirements: *id001
34
36
  - !ruby/object:Gem::Dependency
@@ -151,9 +153,9 @@ files:
151
153
  - lib/placid/helper.rb
152
154
  - lib/placid/model.rb
153
155
  - placid.gemspec
154
- - spec/placid_config_spec.rb
155
- - spec/placid_helper_spec.rb
156
- - spec/placid_model_spec.rb
156
+ - spec/placid/config_spec.rb
157
+ - spec/placid/helper_spec.rb
158
+ - spec/placid/model_spec.rb
157
159
  - spec/spec_helper.rb
158
160
  homepage: http://github.com/a-e/placid
159
161
  licenses: []
@@ -184,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
186
  requirements: []
185
187
 
186
188
  rubyforge_project:
187
- rubygems_version: 1.8.23
189
+ rubygems_version: 1.8.25
188
190
  signing_key:
189
191
  specification_version: 3
190
192
  summary: Models from REST