hstore_accessor 0.5.5 → 0.5.6
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.
- checksums.yaml +4 -4
- data/lib/hstore_accessor/macro.rb +2 -4
- data/lib/hstore_accessor/version.rb +1 -1
- data/spec/hstore_accessor_spec.rb +41 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e928299cf27b02a28b2befe1c083ae3ccc28d0b
|
4
|
+
data.tar.gz: ab166cb7bc0ca541efa7b3a32c1a10278e948c2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
36
|
-
|
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}'"
|
@@ -90,38 +90,54 @@ describe HstoreAccessor do
|
|
90
90
|
|
91
91
|
let!(:product) { Product.new }
|
92
92
|
|
93
|
-
it "
|
94
|
-
|
95
|
-
|
96
|
-
|
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 "
|
101
|
-
|
102
|
-
|
103
|
-
product.
|
104
|
-
expect(product.
|
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
|
-
|
108
|
-
product.options = { "popular" => true }
|
109
|
-
expect(product.popular?).to be_true
|
110
|
-
end
|
106
|
+
context "boolean fields" do
|
111
107
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
123
|
-
|
124
|
-
|
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.
|
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-
|
13
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|