active_attr 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of active_attr might be problematic. Click here for more details.

@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+ require "active_attr/typecasting/unknown_typecaster_error"
3
+
4
+ module ActiveAttr
5
+ module Typecasting
6
+ describe UnknownTypecasterError do
7
+ it { should be_a_kind_of TypeError }
8
+ it { should be_a_kind_of Error }
9
+ end
10
+ end
11
+ end
@@ -12,80 +12,52 @@ module ActiveAttr
12
12
  end
13
13
 
14
14
  describe "#typecast_attribute" do
15
- let(:type) { String }
16
-
17
15
  it "raises an ArgumentError when a nil type is given" do
18
- expect { subject.typecast_attribute(nil, "foo") }.to raise_error(ArgumentError, "a Class must be given")
16
+ expect { subject.typecast_attribute(nil, "foo") }.to raise_error(ArgumentError, "a typecaster must be given")
19
17
  end
20
18
 
21
- context "when there is no way to typecast the value" do
22
- let(:value) { mock("SomeRandomValue") }
23
-
24
- it "returns nil" do
25
- subject.stub(:typecast_value).and_return(nil)
26
- subject.typecast_attribute(type, value).should be_nil
27
- end
19
+ it "raises an ArgumentError when the given typecaster argument does not respond to #call" do
20
+ expect { subject.typecast_attribute(Object.new, "foo") }.to raise_error(ArgumentError, "a typecaster must be given")
28
21
  end
29
22
 
30
- context "when the value is nil" do
31
- let(:name) { nil }
32
- let(:model) { model_class.new }
33
- subject { model.typecast_attribute(type, name) }
34
-
35
- it "returns the original value" do
36
- should eql name
37
- end
38
-
39
- it "does not call try to convert the value" do
40
- model.should_not_receive(:typecast_value)
41
- subject
42
- end
23
+ it "returns the original value when the value is nil" do
24
+ model_class.new.typecast_attribute(mock(:call => 1), nil).should be_nil
43
25
  end
44
26
  end
45
27
 
46
- describe "#typecast_value" do
28
+ describe "#typecaster_for" do
47
29
  let(:model) { model_class.new }
48
- subject { model.typecast_value(type, value) }
49
- let(:value) { mock }
50
30
 
51
- it "calls BigDecimalTypecaster when typecasting to BigDecimal" do
52
- Typecasting::BigDecimalTypecaster.any_instance.should_receive(:call).with(value)
53
- model.typecast_value(BigDecimal, value)
31
+ it "returns BigDecimalTypecaster for BigDecimal" do
32
+ model.typecaster_for(BigDecimal).should be_a_kind_of Typecasting::BigDecimalTypecaster
54
33
  end
55
34
 
56
- it "calls BooleanTypecaster when typecasting to Boolean" do
57
- Typecasting::BooleanTypecaster.any_instance.should_receive(:call).with(value)
58
- model.typecast_value(Typecasting::Boolean, value)
35
+ it "returns BooleanTypecaster for Boolean" do
36
+ model.typecaster_for(Typecasting::Boolean).should be_a_kind_of Typecasting::BooleanTypecaster
59
37
  end
60
38
 
61
- it "calls DateTypecaster when typecasting to Date" do
62
- Typecasting::DateTypecaster.any_instance.should_receive(:call).with(value)
63
- model.typecast_value(Date, value)
39
+ it "returns DateTypecaster for Date" do
40
+ model.typecaster_for(Date).should be_a_kind_of Typecasting::DateTypecaster
64
41
  end
65
42
 
66
- it "calls DateTypecaster when typecasting to Date" do
67
- Typecasting::DateTimeTypecaster.any_instance.should_receive(:call).with(value)
68
- model.typecast_value(DateTime, value)
43
+ it "returns DateTypecaster for Date" do
44
+ model.typecaster_for(DateTime).should be_a_kind_of Typecasting::DateTimeTypecaster
69
45
  end
70
46
 
71
- it "calls FloatTypecaster when typecasting to Float" do
72
- Typecasting::FloatTypecaster.any_instance.should_receive(:call).with(value)
73
- model.typecast_value(Float, value)
47
+ it "returns FloatTypecaster for Float" do
48
+ model.typecaster_for(Float).should be_a_kind_of Typecasting::FloatTypecaster
74
49
  end
75
50
 
76
- it "calls IntegerTypecaster when typecasting to Integer" do
77
- Typecasting::IntegerTypecaster.any_instance.should_receive(:call).with(value)
78
- model.typecast_value(Integer, value)
51
+ it "returns IntegerTypecaster for Integer" do
52
+ model.typecaster_for(Integer).should be_a_kind_of Typecasting::IntegerTypecaster
79
53
  end
80
54
 
81
- it "calls StringTypecaster when typecasting to String" do
82
- Typecasting::StringTypecaster.any_instance.should_receive(:call).with(value)
83
- model.typecast_value(String, value)
55
+ it "returns StringTypecaster for String" do
56
+ model.typecaster_for(String).should be_a_kind_of Typecasting::StringTypecaster
84
57
  end
85
58
 
86
- it "calls ObjectTypecaster when typecasting to Object" do
87
- Typecasting::ObjectTypecaster.any_instance.should_receive(:call).with(value)
88
- model.typecast_value(Object, value)
59
+ it "returns ObjectTypecaster for Object" do
60
+ model.typecaster_for(Object).should be_a_kind_of Typecasting::ObjectTypecaster
89
61
  end
90
62
  end
91
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_attr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-16 00:00:00.000000000Z
13
+ date: 2012-06-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
17
- requirement: &70128915108520 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -25,10 +25,18 @@ dependencies:
25
25
  version: '4.1'
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *70128915108520
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.2
34
+ - - <
35
+ - !ruby/object:Gem::Version
36
+ version: '4.1'
29
37
  - !ruby/object:Gem::Dependency
30
38
  name: activesupport
31
- requirement: &70128915106640 !ruby/object:Gem::Requirement
39
+ requirement: !ruby/object:Gem::Requirement
32
40
  none: false
33
41
  requirements:
34
42
  - - ! '>='
@@ -39,10 +47,18 @@ dependencies:
39
47
  version: '4.1'
40
48
  type: :runtime
41
49
  prerelease: false
42
- version_requirements: *70128915106640
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 3.0.2
56
+ - - <
57
+ - !ruby/object:Gem::Version
58
+ version: '4.1'
43
59
  - !ruby/object:Gem::Dependency
44
60
  name: bundler
45
- requirement: &70128915104720 !ruby/object:Gem::Requirement
61
+ requirement: !ruby/object:Gem::Requirement
46
62
  none: false
47
63
  requirements:
48
64
  - - ~>
@@ -50,21 +66,37 @@ dependencies:
50
66
  version: '1.0'
51
67
  type: :development
52
68
  prerelease: false
53
- version_requirements: *70128915104720
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: '1.0'
54
75
  - !ruby/object:Gem::Dependency
55
76
  name: factory_girl
56
- requirement: &70128915103800 !ruby/object:Gem::Requirement
77
+ requirement: !ruby/object:Gem::Requirement
57
78
  none: false
58
79
  requirements:
59
- - - ~>
80
+ - - ! '>='
60
81
  - !ruby/object:Gem::Version
61
82
  version: '2.2'
83
+ - - <
84
+ - !ruby/object:Gem::Version
85
+ version: '4.0'
62
86
  type: :development
63
87
  prerelease: false
64
- version_requirements: *70128915103800
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '2.2'
94
+ - - <
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
65
97
  - !ruby/object:Gem::Dependency
66
98
  name: rake
67
- requirement: &70128915102820 !ruby/object:Gem::Requirement
99
+ requirement: !ruby/object:Gem::Requirement
68
100
  none: false
69
101
  requirements:
70
102
  - - ~>
@@ -72,10 +104,15 @@ dependencies:
72
104
  version: 0.9.0
73
105
  type: :development
74
106
  prerelease: false
75
- version_requirements: *70128915102820
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 0.9.0
76
113
  - !ruby/object:Gem::Dependency
77
114
  name: rspec
78
- requirement: &70128915102080 !ruby/object:Gem::Requirement
115
+ requirement: !ruby/object:Gem::Requirement
79
116
  none: false
80
117
  requirements:
81
118
  - - ~>
@@ -83,10 +120,15 @@ dependencies:
83
120
  version: '2.6'
84
121
  type: :development
85
122
  prerelease: false
86
- version_requirements: *70128915102080
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ~>
127
+ - !ruby/object:Gem::Version
128
+ version: '2.6'
87
129
  - !ruby/object:Gem::Dependency
88
130
  name: tzinfo
89
- requirement: &70128915101040 !ruby/object:Gem::Requirement
131
+ requirement: !ruby/object:Gem::Requirement
90
132
  none: false
91
133
  requirements:
92
134
  - - ~>
@@ -94,7 +136,12 @@ dependencies:
94
136
  version: 0.3.29
95
137
  type: :development
96
138
  prerelease: false
97
- version_requirements: *70128915101040
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ~>
143
+ - !ruby/object:Gem::Version
144
+ version: 0.3.29
98
145
  description: Create plain old ruby models without reinventing the wheel.
99
146
  email:
100
147
  - cgriego@gmail.com
@@ -111,7 +158,7 @@ files:
111
158
  - CHANGELOG.md
112
159
  - Gemfile
113
160
  - Guardfile
114
- - MIT-LICENSE
161
+ - LICENSE
115
162
  - README.md
116
163
  - Rakefile
117
164
  - active_attr.gemspec
@@ -147,6 +194,7 @@ files:
147
194
  - lib/active_attr/typecasting/integer_typecaster.rb
148
195
  - lib/active_attr/typecasting/object_typecaster.rb
149
196
  - lib/active_attr/typecasting/string_typecaster.rb
197
+ - lib/active_attr/typecasting/unknown_typecaster_error.rb
150
198
  - lib/active_attr/unknown_attribute_error.rb
151
199
  - lib/active_attr/version.rb
152
200
  - spec/functional/active_attr/attribute_defaults_spec.rb
@@ -158,6 +206,7 @@ files:
158
206
  - spec/functional/active_attr/typecasted_attributes_spec.rb
159
207
  - spec/spec_helper.rb
160
208
  - spec/support/active_model_lint.rb
209
+ - spec/support/age.rb
161
210
  - spec/support/initialization_verifier.rb
162
211
  - spec/support/mass_assignment_shared_examples.rb
163
212
  - spec/unit/active_attr/attribute_defaults_spec.rb
@@ -183,6 +232,7 @@ files:
183
232
  - spec/unit/active_attr/typecasting/integer_typecaster_spec.rb
184
233
  - spec/unit/active_attr/typecasting/object_typecaster_spec.rb
185
234
  - spec/unit/active_attr/typecasting/string_typecaster_spec.rb
235
+ - spec/unit/active_attr/typecasting/unknown_typecaster_error_spec.rb
186
236
  - spec/unit/active_attr/typecasting_spec.rb
187
237
  - spec/unit/active_attr/unknown_attribute_error_spec.rb
188
238
  - spec/unit/active_attr/version_spec.rb
@@ -200,7 +250,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
250
  version: '0'
201
251
  segments:
202
252
  - 0
203
- hash: 4554673670402993662
253
+ hash: 1481400115643803652
204
254
  required_rubygems_version: !ruby/object:Gem::Requirement
205
255
  none: false
206
256
  requirements:
@@ -209,10 +259,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
259
  version: '0'
210
260
  segments:
211
261
  - 0
212
- hash: 4554673670402993662
262
+ hash: 1481400115643803652
213
263
  requirements: []
214
- rubyforge_project: active_attr
215
- rubygems_version: 1.8.10
264
+ rubyforge_project:
265
+ rubygems_version: 1.8.21
216
266
  signing_key:
217
267
  specification_version: 3
218
268
  summary: What ActiveModel left out
@@ -226,6 +276,7 @@ test_files:
226
276
  - spec/functional/active_attr/typecasted_attributes_spec.rb
227
277
  - spec/spec_helper.rb
228
278
  - spec/support/active_model_lint.rb
279
+ - spec/support/age.rb
229
280
  - spec/support/initialization_verifier.rb
230
281
  - spec/support/mass_assignment_shared_examples.rb
231
282
  - spec/unit/active_attr/attribute_defaults_spec.rb
@@ -251,7 +302,7 @@ test_files:
251
302
  - spec/unit/active_attr/typecasting/integer_typecaster_spec.rb
252
303
  - spec/unit/active_attr/typecasting/object_typecaster_spec.rb
253
304
  - spec/unit/active_attr/typecasting/string_typecaster_spec.rb
305
+ - spec/unit/active_attr/typecasting/unknown_typecaster_error_spec.rb
254
306
  - spec/unit/active_attr/typecasting_spec.rb
255
307
  - spec/unit/active_attr/unknown_attribute_error_spec.rb
256
308
  - spec/unit/active_attr/version_spec.rb
257
- has_rdoc:
@@ -1,18 +0,0 @@
1
- Copyright (C) 2011 by Chris Griego, Ben Poweski
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN