hstore_accessor 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e53358ab1b69b9ae41faf29e52c620348a9241e
4
- data.tar.gz: dbccbde5437d1aa332eaa60f0d8d500bd822b720
3
+ metadata.gz: 0e928299cf27b02a28b2befe1c083ae3ccc28d0b
4
+ data.tar.gz: ab166cb7bc0ca541efa7b3a32c1a10278e948c2f
5
5
  SHA512:
6
- metadata.gz: 69c6b255e86c6f15e96011c3641c0719bc7629927c96d9438368b7daaaf0ea6713393f4b17e69fa3d12bd12dac7a66738c5bb1b7c5027b822d5d1bafbe5274ca
7
- data.tar.gz: dd2450efa79dcac2f941348471d8775207b0f6682a7f531025c6c08d505170d21cea39cfb4e7e4dca71db311244292fe7bb9048e94e556661e26553d3bcf228e
6
+ metadata.gz: 8561b5b3348763342973cb9eaef55363cd554f071bb54a81ae8587f8f38341b88a0d94f6f7ea53250df4723688bf2c3af82f34291e55dcf5dda0ab2bc9551f01
7
+ data.tar.gz: a2494d775159bb399923d4aa0db058513da29c365e6851538f93765379cd1051caa7a6d286c64a282562ad443a75b2a9a2f824172420b32a182d81a0249753dc
@@ -32,10 +32,8 @@ module HstoreAccessor
32
32
  deserialize(data_type, value)
33
33
  end
34
34
 
35
- if type == :boolean
36
- define_method("#{key}?") do
37
- return send("#{key}")
38
- end
35
+ define_method("#{key}?") do
36
+ send("#{key}").present?
39
37
  end
40
38
 
41
39
  query_field = "#{hstore_attribute} -> '#{store_key}'"
@@ -1,3 +1,3 @@
1
1
  module HstoreAccessor
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
@@ -90,38 +90,54 @@ describe HstoreAccessor do
90
90
 
91
91
  let!(:product) { Product.new }
92
92
 
93
- it "return the state for true boolean fields" do
94
- product.popular = true
95
- product.save
96
- product.reload
97
- expect(product.popular?).to be_true
93
+ it "exist for each field" do
94
+ FIELDS.keys.each do |field|
95
+ expect(product).to respond_to "#{field}?"
96
+ end
98
97
  end
99
98
 
100
- it "return the state for false boolean fields" do
101
- product.popular = false
102
- product.save
103
- product.reload
104
- expect(product.popular?).to be_false
99
+ it "uses 'present?' to determine return value" do
100
+ stub = double(present?: :result_of_present)
101
+ expect(stub).to receive(:present?)
102
+ product.stub(color: stub)
103
+ expect(product.color?).to eq(:result_of_present)
105
104
  end
106
105
 
107
- it "return true for boolean field set via hash using real boolean" do
108
- product.options = { "popular" => true }
109
- expect(product.popular?).to be_true
110
- end
106
+ context "boolean fields" do
111
107
 
112
- it "return false for boolean field set via hash using real boolean" do
113
- product.options = { "popular" => false }
114
- expect(product.popular?).to be_false
115
- end
108
+ it "return the state for true boolean fields" do
109
+ product.popular = true
110
+ product.save
111
+ product.reload
112
+ expect(product.popular?).to be_true
113
+ end
116
114
 
117
- it "return true for boolean field set via hash using string" do
118
- product.options = { "popular" => "true" }
119
- expect(product.popular?).to be_true
120
- end
115
+ it "return the state for false boolean fields" do
116
+ product.popular = false
117
+ product.save
118
+ product.reload
119
+ expect(product.popular?).to be_false
120
+ end
121
+
122
+ it "return true for boolean field set via hash using real boolean" do
123
+ product.options = { "popular" => true }
124
+ expect(product.popular?).to be_true
125
+ end
121
126
 
122
- it "return false for boolean field set via hash using string" do
123
- product.options = { "popular" => "false" }
124
- expect(product.popular?).to be_false
127
+ it "return false for boolean field set via hash using real boolean" do
128
+ product.options = { "popular" => false }
129
+ expect(product.popular?).to be_false
130
+ end
131
+
132
+ it "return true for boolean field set via hash using string" do
133
+ product.options = { "popular" => "true" }
134
+ expect(product.popular?).to be_true
135
+ end
136
+
137
+ it "return false for boolean field set via hash using string" do
138
+ product.options = { "popular" => "false" }
139
+ expect(product.popular?).to be_false
140
+ end
125
141
  end
126
142
 
127
143
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hstore_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Hirn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-22 00:00:00.000000000 Z
13
+ date: 2014-04-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport