minimapper-extras 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,5 +13,12 @@ class ToBoolean
13
13
  end
14
14
  end
15
15
 
16
+ class ToBigDecimal
17
+ def convert(value)
18
+ BigDecimal(value)
19
+ end
20
+ end
21
+
16
22
  Minimapper::Entity::Convert.register_converter(:date, ToDate.new)
17
23
  Minimapper::Entity::Convert.register_converter(:boolean, ToBoolean.new)
24
+ Minimapper::Entity::Convert.register_converter(:big_decimal, ToBigDecimal.new)
@@ -1,5 +1,5 @@
1
1
  module Minimapper
2
2
  module Extras
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -6,6 +6,7 @@ class User
6
6
 
7
7
  attribute :signed_up_on, :date
8
8
  attribute :flagged, :boolean
9
+ attribute :amount, :big_decimal
9
10
  end
10
11
 
11
12
  describe "Convertions" do
@@ -22,4 +23,9 @@ describe "Convertions" do
22
23
  User.new(:flagged => "1").flagged.should eq(true)
23
24
  User.new(:flagged => "0").flagged.should eq(false)
24
25
  end
26
+
27
+ it "can convert big decimals" do
28
+ User.new(amount: "500").amount.should == BigDecimal.new(500)
29
+ User.new(amount: "500.23").amount.should == BigDecimal.new("500.23")
30
+ end
25
31
  end
@@ -30,8 +30,8 @@ end
30
30
 
31
31
  describe CreateThroughRepositoryStrategy do
32
32
  let(:entity) { Location.new }
33
- let(:location_mapper) { mock }
34
- let(:evaluation) { mock(:object => entity) }
33
+ let(:location_mapper) { double }
34
+ let(:evaluation) { double(:object => entity) }
35
35
 
36
36
  before do
37
37
  Repository.stub(:locations).and_return(location_mapper)
@@ -52,8 +52,8 @@ describe CreateThroughRepositoryStrategy do
52
52
  end
53
53
 
54
54
  describe CreateThroughRepositoryStrategy, "when there are belongs_to associations" do
55
- let(:payment_mapper) { mock }
56
- let(:order_mapper) { mock }
55
+ let(:payment_mapper) { double }
56
+ let(:order_mapper) { double }
57
57
 
58
58
  before do
59
59
  Repository.stub(:orders => order_mapper)
@@ -65,14 +65,14 @@ describe CreateThroughRepositoryStrategy, "when there are belongs_to association
65
65
  order = Order.new(:payment => payment)
66
66
  payment_mapper.should_receive(:create).ordered.with(payment).and_return(true)
67
67
  order_mapper.should_receive(:create).ordered.with(order).and_return(true)
68
- evaluation = mock(:object => order)
68
+ evaluation = double(:object => order)
69
69
  CreateThroughRepositoryStrategy.new.result(evaluation)
70
70
  end
71
71
 
72
72
  it "does not create dependencies when not defined" do
73
73
  order = Order.new(:payment => nil)
74
74
  order_mapper.should_receive(:create).ordered.with(order).and_return(true)
75
- evaluation = mock(:object => order)
75
+ evaluation = double(:object => order)
76
76
  CreateThroughRepositoryStrategy.new.result(evaluation)
77
77
  end
78
78
 
@@ -81,7 +81,7 @@ describe CreateThroughRepositoryStrategy, "when there are belongs_to association
81
81
  order = Order.new(:payment => payment)
82
82
  payment_mapper.should_not_receive(:create)
83
83
  order_mapper.should_receive(:create).ordered.with(order).and_return(true)
84
- evaluation = mock(:object => order)
84
+ evaluation = double(:object => order)
85
85
  CreateThroughRepositoryStrategy.new.result(evaluation)
86
86
  end
87
87
  end
@@ -21,9 +21,9 @@ end
21
21
  describe Minimapper::Mapper::HasManyAssociation do
22
22
  let(:contact) { Contact.new(:name => "Joe", :id => 1) }
23
23
  let(:customer) { Customer.new(:id => 1, :contacts => [ contact ]) }
24
- let(:repository) { mock(:contacts => contacts_mapper) }
25
- let(:customer_mapper) { mock(:find => customer, :repository => repository) }
26
- let(:contacts_mapper) { mock }
24
+ let(:repository) { double(:contacts => contacts_mapper) }
25
+ let(:customer_mapper) { double(:find => customer, :repository => repository) }
26
+ let(:contacts_mapper) { double }
27
27
 
28
28
  it "updates changed associated entities" do
29
29
  contacts_mapper.should_receive(:update).with(contact)
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimapper-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Joakim Kolsjö
@@ -9,106 +10,85 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-07-19 00:00:00.000000000 Z
13
+ date: 2013-07-22 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: minimapper
16
- requirement: !ruby/object:Gem::Requirement
17
+ requirement: &70343866571880 !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - '>='
20
+ - - ! '>='
19
21
  - !ruby/object:Gem::Version
20
22
  version: '0.8'
21
23
  type: :runtime
22
24
  prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - '>='
26
- - !ruby/object:Gem::Version
27
- version: '0.8'
25
+ version_requirements: *70343866571880
28
26
  - !ruby/object:Gem::Dependency
29
27
  name: attr_extras
30
- requirement: !ruby/object:Gem::Requirement
28
+ requirement: &70343866571340 !ruby/object:Gem::Requirement
29
+ none: false
31
30
  requirements:
32
- - - '>='
31
+ - - ! '>='
33
32
  - !ruby/object:Gem::Version
34
33
  version: '0'
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - '>='
40
- - !ruby/object:Gem::Version
41
- version: '0'
36
+ version_requirements: *70343866571340
42
37
  - !ruby/object:Gem::Dependency
43
38
  name: backports
44
- requirement: !ruby/object:Gem::Requirement
39
+ requirement: &70343866570760 !ruby/object:Gem::Requirement
40
+ none: false
45
41
  requirements:
46
- - - '>='
42
+ - - ! '>='
47
43
  - !ruby/object:Gem::Version
48
44
  version: '0'
49
45
  type: :runtime
50
46
  prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - '>='
54
- - !ruby/object:Gem::Version
55
- version: '0'
47
+ version_requirements: *70343866570760
56
48
  - !ruby/object:Gem::Dependency
57
49
  name: bundler
58
- requirement: !ruby/object:Gem::Requirement
50
+ requirement: &70343866570140 !ruby/object:Gem::Requirement
51
+ none: false
59
52
  requirements:
60
53
  - - ~>
61
54
  - !ruby/object:Gem::Version
62
55
  version: '1.3'
63
56
  type: :development
64
57
  prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '1.3'
58
+ version_requirements: *70343866570140
70
59
  - !ruby/object:Gem::Dependency
71
60
  name: rake
72
- requirement: !ruby/object:Gem::Requirement
61
+ requirement: &70343866569480 !ruby/object:Gem::Requirement
62
+ none: false
73
63
  requirements:
74
- - - '>='
64
+ - - ! '>='
75
65
  - !ruby/object:Gem::Version
76
66
  version: '0'
77
67
  type: :development
78
68
  prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
69
+ version_requirements: *70343866569480
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: rspec
86
- requirement: !ruby/object:Gem::Requirement
72
+ requirement: &70343866568460 !ruby/object:Gem::Requirement
73
+ none: false
87
74
  requirements:
88
- - - '>='
75
+ - - ! '>='
89
76
  - !ruby/object:Gem::Version
90
77
  version: '0'
91
78
  type: :development
92
79
  prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - '>='
96
- - !ruby/object:Gem::Version
97
- version: '0'
80
+ version_requirements: *70343866568460
98
81
  - !ruby/object:Gem::Dependency
99
82
  name: activemodel
100
- requirement: !ruby/object:Gem::Requirement
83
+ requirement: &70343866567420 !ruby/object:Gem::Requirement
84
+ none: false
101
85
  requirements:
102
- - - '>='
86
+ - - ! '>='
103
87
  - !ruby/object:Gem::Version
104
88
  version: '0'
105
89
  type: :development
106
90
  prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - '>='
110
- - !ruby/object:Gem::Version
111
- version: '0'
91
+ version_requirements: *70343866567420
112
92
  description:
113
93
  email:
114
94
  - joakim.kolsjo@gmail.com
@@ -145,26 +125,27 @@ files:
145
125
  homepage: ''
146
126
  licenses:
147
127
  - MIT
148
- metadata: {}
149
128
  post_install_message:
150
129
  rdoc_options: []
151
130
  require_paths:
152
131
  - lib
153
132
  required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
154
134
  requirements:
155
- - - '>='
135
+ - - ! '>='
156
136
  - !ruby/object:Gem::Version
157
137
  version: '0'
158
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
159
140
  requirements:
160
- - - '>='
141
+ - - ! '>='
161
142
  - !ruby/object:Gem::Version
162
143
  version: '0'
163
144
  requirements: []
164
145
  rubyforge_project:
165
- rubygems_version: 2.0.3
146
+ rubygems_version: 1.8.6
166
147
  signing_key:
167
- specification_version: 4
148
+ specification_version: 3
168
149
  summary: Extras for Minimapper.
169
150
  test_files:
170
151
  - spec/minimapper/entity/belongs_to_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: edb130e5d2a4506574a9ee233267341ec60cec29
4
- data.tar.gz: cb71eaa99b8f5ae8b0711413c6a8035ce0eb9681
5
- SHA512:
6
- metadata.gz: 144868b83b8bc0eac44fc33872c43759eae2d5ab4cdf74370c46e71ecef3ae802947851431ebcf860aaffc5fd4253bd58115eb18ebf893e85a468d891ca63750
7
- data.tar.gz: 96e73ad707e7e649f2ce7686be070d5bff502c644e9faa2ccc053fac80abd88537cd7032db3494752b71522d21795ba7d81fa43f8ab61b0db246efb83c59441d