serial_preference 1.1.4 → 1.2.0
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/.travis.yml +8 -0
- data/README.md +5 -0
- data/lib/serial_preference/preference_definition.rb +24 -2
- data/lib/serial_preference/version.rb +1 -1
- data/serial_preference.gemspec +1 -0
- data/spec/has_preference_map_spec.rb +21 -21
- data/spec/preference_definition_spec.rb +29 -29
- data/spec/preferenzer_spec.rb +16 -16
- data/spec/spec_helper.rb +3 -2
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db6bc7111161f864fadcbb7878a264501beb7514
|
|
4
|
+
data.tar.gz: 7d47f5fc3201e10311f6696e794698fa14d35640
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20a7add6cc6780cfa01c4b30d948a4048c7e8870a1290720086c3defa51e7a9fb66cbf2a8e26076bd7397daf5d7c358953e19789df12b0f648e8aa1e5444541b
|
|
7
|
+
data.tar.gz: e9396b647dcf00583ff800c50ab1a362f830dc98125fb83729c191f3570c79f84eb82f065ae345d8fffc9b5a3e73288f7c4faed98fae7691e83a3d46f7188132
|
data/.travis.yml
ADDED
data/README.md
CHANGED
|
@@ -79,6 +79,7 @@ Or install it yourself as:
|
|
|
79
79
|
````ruby
|
|
80
80
|
# List of Preferences
|
|
81
81
|
Company.preference_names # => [:income_ledger_id]
|
|
82
|
+
````
|
|
82
83
|
|
|
83
84
|
## Contributing
|
|
84
85
|
|
|
@@ -87,3 +88,7 @@ Or install it yourself as:
|
|
|
87
88
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
88
89
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
89
90
|
5. Create new Pull Request
|
|
91
|
+
|
|
92
|
+
## Build Status
|
|
93
|
+
|
|
94
|
+
* [](https://travis-ci.org/asanghi/serial_preference)
|
|
@@ -10,7 +10,7 @@ module SerialPreference
|
|
|
10
10
|
self.name = name.to_s
|
|
11
11
|
opts.assert_valid_keys(:data_type,:default,:required,:field_type)
|
|
12
12
|
self.data_type = @type = opts[:data_type] || :string
|
|
13
|
-
@column = ActiveRecord::ConnectionAdapters::Column.new(name.to_s,opts[:default]
|
|
13
|
+
@column = ActiveRecord::ConnectionAdapters::Column.new(name.to_s, opts[:default], column_type(@type))
|
|
14
14
|
self.default = opts[:default]
|
|
15
15
|
self.required = !!opts[:required]
|
|
16
16
|
self.field_type = opts[:field_type]
|
|
@@ -79,5 +79,27 @@ module SerialPreference
|
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
def column_type(type)
|
|
83
|
+
if rails_42?
|
|
84
|
+
case type
|
|
85
|
+
when :boolean
|
|
86
|
+
ActiveRecord::Type::Boolean.new
|
|
87
|
+
when :integer
|
|
88
|
+
ActiveRecord::Type::Integer.new
|
|
89
|
+
when :float
|
|
90
|
+
ActiveRecord::Type::Float.new
|
|
91
|
+
when :decimal
|
|
92
|
+
ActiveRecord::Type::Decimal.new
|
|
93
|
+
else
|
|
94
|
+
ActiveRecord::Type::String.new
|
|
95
|
+
end
|
|
96
|
+
else
|
|
97
|
+
type.to_s
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def rails_42?
|
|
102
|
+
ActiveRecord::VERSION::MAJOR >= 4 && ActiveRecord::VERSION::MINOR == 2
|
|
103
|
+
end
|
|
82
104
|
end
|
|
83
|
-
end
|
|
105
|
+
end
|
data/serial_preference.gemspec
CHANGED
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
|
21
21
|
gem.add_runtime_dependency "activerecord", ">= 3.0.0"
|
|
22
22
|
|
|
23
23
|
gem.add_development_dependency 'sqlite3'
|
|
24
|
+
gem.add_development_dependency 'rspec', ">= 3.0.0"
|
|
24
25
|
gem.add_development_dependency 'rspec-rails'
|
|
25
26
|
gem.add_development_dependency "shoulda"
|
|
26
27
|
|
|
@@ -8,7 +8,7 @@ describe SerialPreference::HasSerialPreferences do
|
|
|
8
8
|
|
|
9
9
|
context "default behaviour" do
|
|
10
10
|
it "should return preferences as a default _preferences_attribute" do
|
|
11
|
-
DummyClass._preferences_attribute.
|
|
11
|
+
expect(DummyClass._preferences_attribute).to eq(:preferences)
|
|
12
12
|
end
|
|
13
13
|
it "should return settings as a _preferences_attribute" do
|
|
14
14
|
class OverriddenPreferenceAttributeClass < ActiveRecord::Base
|
|
@@ -17,21 +17,21 @@ describe SerialPreference::HasSerialPreferences do
|
|
|
17
17
|
preference :abc
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
-
OverriddenPreferenceAttributeClass._preferences_attribute.
|
|
20
|
+
expect(OverriddenPreferenceAttributeClass._preferences_attribute).to eq(:settings)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
context "class methods behaviour" do
|
|
25
25
|
it "should be possible to describe preference map thru preferences" do
|
|
26
|
-
DummyClass.respond_to?(:preferences).
|
|
26
|
+
expect(DummyClass.respond_to?(:preferences)).to be_truthy
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "should be possble to retrieve preference groups from class" do
|
|
30
|
-
DummyClass.respond_to?(:preference_groups).
|
|
30
|
+
expect(DummyClass.respond_to?(:preference_groups)).to be_truthy
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "should be possble to retrieve preference names from class" do
|
|
34
|
-
DummyClass.respond_to?(:preference_names).
|
|
34
|
+
expect(DummyClass.respond_to?(:preference_names)).to be_truthy
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -39,38 +39,38 @@ describe SerialPreference::HasSerialPreferences do
|
|
|
39
39
|
context "should define accessors" do
|
|
40
40
|
it "should have readers available" do
|
|
41
41
|
d = DummyClass.new
|
|
42
|
-
d.respond_to?(:taxable).
|
|
43
|
-
d.respond_to?(:vat_no).
|
|
44
|
-
d.respond_to?(:max_invoice_items).
|
|
45
|
-
d.respond_to?(:income_ledger_id).
|
|
42
|
+
expect(d.respond_to?(:taxable)).to be_truthy
|
|
43
|
+
expect(d.respond_to?(:vat_no)).to be_truthy
|
|
44
|
+
expect(d.respond_to?(:max_invoice_items)).to be_truthy
|
|
45
|
+
expect(d.respond_to?(:income_ledger_id)).to be_truthy
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "should ensure that the readers returns the correct data" do
|
|
49
49
|
d = DummyClass.new
|
|
50
50
|
d.preferences = {:vat_no => "abc"}
|
|
51
|
-
d.vat_no.
|
|
51
|
+
expect(d.vat_no).to eq("abc")
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "should have writers available" do
|
|
55
55
|
d = DummyClass.new
|
|
56
|
-
d.respond_to?(:taxable=).
|
|
57
|
-
d.respond_to?(:vat_no=).
|
|
58
|
-
d.respond_to?(:max_invoice_items=).
|
|
59
|
-
d.respond_to?(:income_ledger_id=).
|
|
56
|
+
expect(d.respond_to?(:taxable=)).to be_truthy
|
|
57
|
+
expect(d.respond_to?(:vat_no=)).to be_truthy
|
|
58
|
+
expect(d.respond_to?(:max_invoice_items=)).to be_truthy
|
|
59
|
+
expect(d.respond_to?(:income_ledger_id=)).to be_truthy
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it "should ensure that the writer write the correct data" do
|
|
63
63
|
d = DummyClass.new
|
|
64
64
|
d.vat_no = "abc"
|
|
65
|
-
d.vat_no.
|
|
65
|
+
expect(d.vat_no).to eq("abc")
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "should ensure that the querier the correct data" do
|
|
69
69
|
d = DummyClass.new
|
|
70
70
|
d.taxable = true
|
|
71
|
-
d.
|
|
71
|
+
expect(d).to be_taxable
|
|
72
72
|
d.taxable = false
|
|
73
|
-
d.
|
|
73
|
+
expect(d).to_not be_taxable
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "should have query methods available for booleans" do
|
|
@@ -78,13 +78,13 @@ describe SerialPreference::HasSerialPreferences do
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "should respond properly for default true preferences" do
|
|
81
|
-
DummyClass.new.taxable.
|
|
82
|
-
DummyClass.new.taxable
|
|
81
|
+
expect(DummyClass.new.taxable).to eq(true)
|
|
82
|
+
expect(DummyClass.new.taxable?).to eq(true)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "should respond properly for default false preferences" do
|
|
86
|
-
DummyClass.new.creditable.
|
|
87
|
-
DummyClass.new.creditable
|
|
86
|
+
expect(DummyClass.new.creditable).to eq(false)
|
|
87
|
+
expect(DummyClass.new.creditable?).to eq(false)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
end
|
|
@@ -8,84 +8,84 @@ describe SerialPreference::PreferenceDefinition do
|
|
|
8
8
|
|
|
9
9
|
it "should have proper accessors" do
|
|
10
10
|
[:data_type, :name, :default, :required, :field_type].each do |a|
|
|
11
|
-
@blank_pref.respond_to?(a).
|
|
11
|
+
expect(@blank_pref.respond_to?(a)).to be_truthy
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should declare supported data types" do
|
|
16
|
-
described_class.constants.
|
|
16
|
+
expect(described_class.constants).to include(:SUPPORTED_TYPES)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should stringify its name" do
|
|
20
|
-
described_class.new(:whatever).name.
|
|
20
|
+
expect(described_class.new(:whatever).name).to eq("whatever")
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
context "required behaviour" do
|
|
24
24
|
it "should not be required when no required option provided" do
|
|
25
|
-
@blank_pref.
|
|
25
|
+
expect(@blank_pref).to_not be_required
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "should be required when required option is truthy" do
|
|
29
29
|
[0,"yes","no","false",true].each do |truthy_values|
|
|
30
30
|
p = described_class.new("whatever",{required: truthy_values})
|
|
31
|
-
p.
|
|
31
|
+
expect(p).to be_required
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "should not be required when required option is falsy" do
|
|
36
36
|
[false,nil].each do |falsy_values|
|
|
37
37
|
p = described_class.new("whatever",{required: falsy_values})
|
|
38
|
-
p.
|
|
38
|
+
expect(p).to_not be_required
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
context "numericality behaviour" do
|
|
44
44
|
it "should not be numerical when no data_type is provided" do
|
|
45
|
-
@blank_pref.
|
|
45
|
+
expect(@blank_pref).to_not be_numerical
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "should be numerical when data_type is numerical" do
|
|
49
49
|
[:integer,:float,:decimal].each do |dt|
|
|
50
|
-
described_class.new("whatever",{data_type: dt}).
|
|
50
|
+
expect(described_class.new("whatever",{data_type: dt})).to be_numerical
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "should be not numerical when data_type is non numerical" do
|
|
55
55
|
[:string,:boolean,:password,:whatever].each do |dt|
|
|
56
|
-
described_class.new("whatever",{data_type: dt}).
|
|
56
|
+
expect(described_class.new("whatever",{data_type: dt})).to_not be_numerical
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
context "default behaviour" do
|
|
62
62
|
it "should report correct name" do
|
|
63
|
-
@blank_pref.name.
|
|
63
|
+
expect(@blank_pref.name).to eq("whatever")
|
|
64
64
|
end
|
|
65
65
|
it "should be a string" do
|
|
66
|
-
@blank_pref.data_type.
|
|
66
|
+
expect(@blank_pref.data_type).to eq(:string)
|
|
67
67
|
end
|
|
68
68
|
it "should have nil default" do
|
|
69
|
-
@blank_pref.default.
|
|
69
|
+
expect(@blank_pref.default).to be_nil
|
|
70
70
|
end
|
|
71
71
|
it "should be false for required" do
|
|
72
|
-
@blank_pref.required.
|
|
72
|
+
expect(@blank_pref.required).to be_falsy
|
|
73
73
|
end
|
|
74
74
|
it "should have string field_type" do
|
|
75
|
-
@blank_pref.field_type.
|
|
75
|
+
expect(@blank_pref.field_type).to eq(:string)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
context "field_type behaviour" do
|
|
80
80
|
it "should report field_type as provided" do
|
|
81
|
-
described_class.new("whatever",{field_type: :xyz}).field_type.
|
|
81
|
+
expect(described_class.new("whatever",{field_type: :xyz}).field_type).to eq(:xyz)
|
|
82
82
|
end
|
|
83
83
|
it "should report string for numerical data types" do
|
|
84
|
-
described_class.new("whatever",{data_type: :integer}).field_type.
|
|
84
|
+
expect(described_class.new("whatever",{data_type: :integer}).field_type).to eq(:string)
|
|
85
85
|
end
|
|
86
86
|
it "should report data type for non numeric data types" do
|
|
87
87
|
p = described_class.new("whatever",{data_type: :xyz})
|
|
88
|
-
p.field_type.
|
|
88
|
+
expect(p.field_type).to eq(p.data_type)
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -93,17 +93,17 @@ describe SerialPreference::PreferenceDefinition do
|
|
|
93
93
|
|
|
94
94
|
context "when input is nil" do
|
|
95
95
|
it "should report nil when no default is given" do
|
|
96
|
-
@blank_pref.value(nil).
|
|
96
|
+
expect(@blank_pref.value(nil)).to be_nil
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "should report default when input is nil" do
|
|
100
100
|
p = described_class.new("whatever",{default: "dog"})
|
|
101
|
-
p.value(nil).
|
|
101
|
+
expect(p.value(nil)).to eq("dog")
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
it "should report default in appropriate data type when input is nil" do
|
|
105
105
|
p = described_class.new("whatever",{default: "dog", data_type: :integer})
|
|
106
|
-
p.value(nil).
|
|
106
|
+
expect(p.value(nil)).to eq("dog".to_i)
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -114,7 +114,7 @@ describe SerialPreference::PreferenceDefinition do
|
|
|
114
114
|
|
|
115
115
|
it "should return correct strings as passthru" do
|
|
116
116
|
["",3.0,[],{},"dog",1].each do |input_val|
|
|
117
|
-
@preference.value(input_val).
|
|
117
|
+
expect(@preference.value(input_val)).to eq(input_val.to_s)
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -127,13 +127,13 @@ describe SerialPreference::PreferenceDefinition do
|
|
|
127
127
|
|
|
128
128
|
it "should return correct integers" do
|
|
129
129
|
["",1,3.0,"dog"].each do |input_val|
|
|
130
|
-
@preference.value(input_val).
|
|
130
|
+
expect(@preference.value(input_val)).to eq(input_val.to_i)
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
it "should report nil for non numeric input" do
|
|
135
135
|
[[],{}].each do |input_val|
|
|
136
|
-
@preference.value(input_val).
|
|
136
|
+
expect(@preference.value(input_val)).to be_nil
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
end
|
|
@@ -145,13 +145,13 @@ describe SerialPreference::PreferenceDefinition do
|
|
|
145
145
|
|
|
146
146
|
it "should return correct floats" do
|
|
147
147
|
["",1,3.0,"dog"].each do |input_val|
|
|
148
|
-
@preference.value(input_val).
|
|
148
|
+
expect(@preference.value(input_val)).to eq(input_val.to_f)
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
it "should report nil for non numeric input" do
|
|
153
153
|
[[],{}].each do |input_val|
|
|
154
|
-
@preference.value(input_val).
|
|
154
|
+
expect(@preference.value(input_val)).to be_nil
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
157
|
end
|
|
@@ -162,23 +162,23 @@ describe SerialPreference::PreferenceDefinition do
|
|
|
162
162
|
end
|
|
163
163
|
it "should report false for falsy values" do
|
|
164
164
|
[nil,false].each do |falsy|
|
|
165
|
-
@preference.value(falsy).
|
|
165
|
+
expect(@preference.value(falsy)).to be_falsy
|
|
166
166
|
end
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
it "should report false for false looking values" do
|
|
170
170
|
[0,"0","false","FALSE","False","no","NO","No"].each do |falsy|
|
|
171
|
-
@preference.value(falsy).
|
|
171
|
+
expect(@preference.value(falsy)).to be_falsy
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
it "should report true for truthy values" do
|
|
176
176
|
["yes",true,100,0.1,[],{}].each do |truthy_value|
|
|
177
|
-
@preference.value(truthy_value).
|
|
177
|
+
expect(@preference.value(truthy_value)).to be_truthy
|
|
178
178
|
end
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
end
|
|
183
183
|
|
|
184
|
-
end
|
|
184
|
+
end
|
data/spec/preferenzer_spec.rb
CHANGED
|
@@ -9,22 +9,22 @@ describe SerialPreference::Preferenzer do
|
|
|
9
9
|
|
|
10
10
|
it "should have proper readers" do
|
|
11
11
|
[:preference_groups,:preference,:preference_groups,:all_preference_definitions,:all_preference_names,:current_group].each do |a|
|
|
12
|
-
@preferenzer.
|
|
12
|
+
expect(@preferenzer).to respond_to(a)
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
context "default instance behaviour" do
|
|
17
17
|
it "should report empty preference groups" do
|
|
18
|
-
@preferenzer.preference_groups.
|
|
18
|
+
expect(@preferenzer.preference_groups).to include(@base)
|
|
19
19
|
end
|
|
20
20
|
it "should report current_contex to be nil" do
|
|
21
|
-
@preferenzer.current_group.
|
|
21
|
+
expect(@preferenzer.current_group).to eq(@base)
|
|
22
22
|
end
|
|
23
23
|
it "should report all preference name to be empty" do
|
|
24
|
-
@preferenzer.all_preference_names.
|
|
24
|
+
expect(@preferenzer.all_preference_names).to be_empty
|
|
25
25
|
end
|
|
26
26
|
it "should report all preference definitions to be empty" do
|
|
27
|
-
@preferenzer.all_preference_definitions.
|
|
27
|
+
expect(@preferenzer.all_preference_definitions).to be_empty
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -32,23 +32,23 @@ describe SerialPreference::Preferenzer do
|
|
|
32
32
|
|
|
33
33
|
it "should allow for addition of preference using pref" do
|
|
34
34
|
@preferenzer.pref("whatever")
|
|
35
|
-
@preferenzer.all_preference_names.
|
|
35
|
+
expect(@preferenzer.all_preference_names).to include("whatever")
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "should allow for addition of preference using preference" do
|
|
39
39
|
@preferenzer.preference("whatever")
|
|
40
|
-
@preferenzer.all_preference_names.
|
|
40
|
+
expect(@preferenzer.all_preference_names).to include("whatever")
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "should alias preference to pref" do
|
|
44
|
-
described_class.instance_method(:pref).
|
|
44
|
+
expect(described_class.instance_method(:pref)).to eq(described_class.instance_method(:preference))
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "should allow for addition of preference group" do
|
|
48
48
|
@preferenzer.preference_group(:new_group) do
|
|
49
49
|
preference :new_preference
|
|
50
50
|
end
|
|
51
|
-
@preferenzer.all_preference_names.
|
|
51
|
+
expect(@preferenzer.all_preference_names).to include("new_preference")
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
end
|
|
@@ -64,15 +64,15 @@ describe SerialPreference::Preferenzer do
|
|
|
64
64
|
switch_off_hour default: 23
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
|
-
@preferenzer.all_preference_names.
|
|
67
|
+
expect(@preferenzer.all_preference_names).to include("age","name","sex","email","switch_off_hour")
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "should allow for addition of preference in given context" do
|
|
71
|
-
@preferenzer.all_groups.
|
|
71
|
+
expect(@preferenzer.all_groups).to_not include(:new_group)
|
|
72
72
|
@preferenzer.preference_group(:new_group) do
|
|
73
73
|
preference "addition"
|
|
74
74
|
end
|
|
75
|
-
@preferenzer.all_preference_names.
|
|
75
|
+
expect(@preferenzer.all_preference_names).to include("addition")
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it "should allow overriding of preference if defined twice" do
|
|
@@ -80,14 +80,14 @@ describe SerialPreference::Preferenzer do
|
|
|
80
80
|
preference :overriding_name
|
|
81
81
|
preference :overriding_name
|
|
82
82
|
end
|
|
83
|
-
@preferenzer.all_preference_names.
|
|
83
|
+
expect(@preferenzer.all_preference_names).to include("overriding_name", "overriding_name")
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
it "should allow addition of preference to an existing preference group" do
|
|
87
87
|
@preferenzer.preference_group(:notifications) do
|
|
88
88
|
preference :new_preference
|
|
89
89
|
end
|
|
90
|
-
@preferenzer.all_preference_names.
|
|
90
|
+
expect(@preferenzer.all_preference_names).to include("new_preference")
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
it "should allow for preference names to be strings or symbols" do
|
|
@@ -95,7 +95,7 @@ describe SerialPreference::Preferenzer do
|
|
|
95
95
|
preference "string"
|
|
96
96
|
preference :symbol
|
|
97
97
|
end
|
|
98
|
-
@preferenzer.all_preference_names.
|
|
98
|
+
expect(@preferenzer.all_preference_names).to include("string", "symbol")
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "should allow for preference_group names to be strings or symbols" do
|
|
@@ -105,7 +105,7 @@ describe SerialPreference::Preferenzer do
|
|
|
105
105
|
@preferenzer.preference_group("string") do
|
|
106
106
|
preference :symbol
|
|
107
107
|
end
|
|
108
|
-
@preferenzer.all_groups.
|
|
108
|
+
expect(@preferenzer.all_groups).to include("string", :symbol)
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -2,6 +2,7 @@ $:.unshift File.expand_path('..', __FILE__)
|
|
|
2
2
|
$:.unshift File.expand_path('../../lib', __FILE__)
|
|
3
3
|
require 'active_support/all'
|
|
4
4
|
require 'active_record'
|
|
5
|
+
require 'yaml'
|
|
5
6
|
require 'rspec'
|
|
6
7
|
require 'shoulda'
|
|
7
8
|
require "serial_preference/version"
|
|
@@ -11,7 +12,7 @@ require "serial_preference/has_preference_map"
|
|
|
11
12
|
|
|
12
13
|
FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
|
|
13
14
|
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
|
14
|
-
ActiveRecord::Base.logger = ActiveSupport::
|
|
15
|
+
ActiveRecord::Base.logger = ActiveSupport::Logger.new(File.dirname(__FILE__) + "/debug.log")
|
|
15
16
|
ActiveRecord::Base.establish_connection(config['test'])
|
|
16
17
|
|
|
17
18
|
RSpec.configure do |config|
|
|
@@ -21,4 +22,4 @@ def rebuild_model options = {}
|
|
|
21
22
|
ActiveRecord::Base.connection.create_table :dummy_classes, :force => true do |table|
|
|
22
23
|
table.column :preferences, :text
|
|
23
24
|
end
|
|
24
|
-
end
|
|
25
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: serial_preference
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aditya Sanghi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 3.0.0
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 3.0.0
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rspec-rails
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -89,6 +103,7 @@ extra_rdoc_files: []
|
|
|
89
103
|
files:
|
|
90
104
|
- ".gitignore"
|
|
91
105
|
- ".rspec"
|
|
106
|
+
- ".travis.yml"
|
|
92
107
|
- Gemfile
|
|
93
108
|
- LICENSE.txt
|
|
94
109
|
- README.md
|