symbolize 4.5.0 → 4.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Symbolize
2
- VERSION = '4.5.0'
2
+ VERSION = '4.5.1'
3
3
  end
@@ -9,7 +9,7 @@ class CreateTestingStructure < ActiveRecord::Migration
9
9
  t.boolean :public
10
10
  t.boolean :cool
11
11
  t.string :role
12
- t.string :country, :default => "pt"
12
+ t.string :country, :default => 'pt'
13
13
  t.string :some_attr # used in name collision tests
14
14
  end
15
15
  create_table :user_skills do |t|
@@ -21,8 +21,8 @@ class CreateTestingStructure < ActiveRecord::Migration
21
21
  t.string :key, :null => false
22
22
  end
23
23
  create_table :permissions do |t|
24
- t.string :name, :null => false
25
- t.string :kind, :null => false
24
+ t.string :name, :null => false
25
+ t.string :kind, :null => false
26
26
  t.integer :lvl, :null => false
27
27
  end
28
28
  end
@@ -10,10 +10,10 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
10
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
11
 
12
12
  require 'i18n'
13
- I18n.load_path += Dir[File.join(File.dirname(__FILE__), "locales", "*.{rb,yml}")]
14
- I18n.default_locale = "pt"
13
+ I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'locales', '*.{rb,yml}')]
14
+ I18n.default_locale = 'pt'
15
15
 
16
- if ENV["CI"]
16
+ if ENV['CI']
17
17
  require 'coveralls'
18
18
  Coveralls.wear!
19
19
  end
@@ -21,13 +21,13 @@ end
21
21
  #
22
22
  # Mongoid
23
23
  #
24
- unless ENV["ONLY_AR"]
24
+ unless ENV['ONLY_AR']
25
25
 
26
26
  require 'mongoid'
27
27
  puts "Using Mongoid v#{Mongoid::VERSION}"
28
28
 
29
29
  Mongoid.configure do |config|
30
- #config.master = Mongo::Connection.new.db("symbolize_test")
30
+ # config.master = Mongo::Connection.new.db("symbolize_test")
31
31
  config.connect_to('symbolize_test')
32
32
  end
33
33
 
@@ -40,11 +40,10 @@ unless ENV["ONLY_AR"]
40
40
  end
41
41
  end
42
42
 
43
-
44
43
  #
45
44
  # ActiveRecord
46
45
  #
47
- unless ENV["ONLY_MONGOID"]
46
+ unless ENV['ONLY_MONGOID']
48
47
 
49
48
  require 'active_record'
50
49
  require 'symbolize/active_record'
@@ -53,24 +52,22 @@ unless ENV["ONLY_MONGOID"]
53
52
 
54
53
  ActiveRecord::Base.send :include, Symbolize::ActiveRecord # this is normally done by the railtie
55
54
 
56
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") #'postgresql', :database => 'symbolize_test', :username => 'postgres')
57
-
55
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:') # 'postgresql', :database => 'symbolize_test', :username => 'postgres')
58
56
 
59
- if ActiveRecord::VERSION::STRING >= "3.1"
60
- ActiveRecord::Migrator.migrate("spec/db")
57
+ if ActiveRecord::VERSION::STRING >= '3.1'
58
+ ActiveRecord::Migrator.migrate('spec/db')
61
59
  else
62
- require "db/001_create_testing_structure"
60
+ require 'db/001_create_testing_structure'
63
61
  CreateTestingStructure.migrate(:up)
64
62
  end
65
63
 
66
-
67
64
  # Spec::Runner.configure do |config|
68
65
  # end
69
66
 
70
67
  RSpec.configure do |config|
71
68
 
72
69
  config.after(:each) do
73
- [User, Permission].each { |klass| klass.delete_all }
70
+ [User, Permission].each(&:delete_all)
74
71
  end
75
72
 
76
73
  end
@@ -7,21 +7,21 @@ class User < ActiveRecord::Base
7
7
  symbolize :other
8
8
  symbolize :language, :in => [:pt, :en]
9
9
  symbolize :sex, :in => [true, false], :scopes => true
10
- symbolize :status , :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => :shallow, :methods => true
10
+ symbolize :status, :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => :shallow, :methods => true
11
11
  symbolize :so, :allow_blank => true, :in => {
12
12
  :linux => 'Linux',
13
- :mac => 'Mac OS X',
14
- :win => 'Videogame'
15
- }, :scopes => true
13
+ :mac => 'Mac OS X',
14
+ :win => 'Videogame',
15
+ }, :scopes => true
16
16
  symbolize :gui, :allow_blank => true, :in => [:cocoa, :qt, :gtk], :i18n => false
17
- symbolize :karma, :in => %w{ good bad ugly}, :methods => true, :i18n => false, :allow_nil => true
17
+ symbolize :karma, :in => %w(good bad ugly), :methods => true, :i18n => false, :allow_nil => true
18
18
  symbolize :cool, :in => [true, false], :scopes => true
19
19
 
20
20
  symbolize :role, :in => [:reader, :writer, :some_existing_attr], :i18n => false, :methods => true, :default => :reader
21
21
  symbolize :country, :in => [:us, :gb, :pt, :ru], :capitalize => true, :i18n => false # note: the default value is provided in db migration
22
22
 
23
- has_many :extras, :dependent => :destroy, :class_name => "UserExtra"
24
- has_many :access, :dependent => :destroy, :class_name => "UserAccess"
23
+ has_many :extras, :dependent => :destroy, :class_name => 'UserExtra'
24
+ has_many :access, :dependent => :destroy, :class_name => 'UserAccess'
25
25
  end
26
26
 
27
27
  class UserSkill < ActiveRecord::Base
@@ -35,48 +35,48 @@ end
35
35
  class Permission < ActiveRecord::Base
36
36
  validates_presence_of :name
37
37
  symbolize :kind, :in => [:temp, :perm], :default => :perm
38
- symbolize :lvl, :in => (1..9).to_a, :i18n => false#, :default => 1
38
+ symbolize :lvl, :in => (1..9).to_a, :i18n => false # , :default => 1
39
39
  end
40
40
 
41
41
  class PermissionSubclass < Permission
42
42
  symbolize :sub_lvl
43
43
  end
44
44
 
45
- describe "Symbolize" do
45
+ describe 'Symbolize' do
46
46
 
47
- it "should respond to symbolize" do
47
+ it 'should respond to symbolize' do
48
48
  expect(ActiveRecord::Base).to respond_to :symbolize
49
49
  end
50
50
 
51
- it "should have a valid blueprint" do
51
+ it 'should have a valid blueprint' do
52
52
  # Test records
53
- u = User.create(:name => 'Bob' , :other => :bar,:status => :inactive, :so => :mac, :gui => :gtk, :language => :en, :sex => false, :cool => false)
53
+ u = User.create(:name => 'Bob', :other => :bar, :status => :inactive, :so => :mac, :gui => :gtk, :language => :en, :sex => false, :cool => false)
54
54
  expect(u.errors.messages).to be_blank
55
55
  end
56
56
 
57
- it "should work nice with default values from active model" do
58
- u = User.create(:name => 'Niu' , :other => :bar, :so => :mac, :gui => :gtk, :language => :en, :sex => false, :cool => false)
57
+ it 'should work nice with default values from active model' do
58
+ u = User.create(:name => 'Niu', :other => :bar, :so => :mac, :gui => :gtk, :language => :en, :sex => false, :cool => false)
59
59
  expect(u.errors.messages).to be_blank
60
60
  expect(u.status).to eql(:active)
61
61
  expect(u).to be_active
62
62
  end
63
63
 
64
- describe ".symbolized_attributes" do
65
- it "returns the symbolized attribute for the class" do
64
+ describe '.symbolized_attributes' do
65
+ it 'returns the symbolized attribute for the class' do
66
66
  expect(UserExtra.symbolized_attributes).to eq ['key']
67
- expect(Permission.symbolized_attributes).to match_array ['kind', 'lvl']
68
- expect(PermissionSubclass.symbolized_attributes).to match_array ['kind', 'lvl', 'sub_lvl']
67
+ expect(Permission.symbolized_attributes).to match_array %w(kind lvl)
68
+ expect(PermissionSubclass.symbolized_attributes).to match_array %w(kind lvl sub_lvl)
69
69
  end
70
70
  end
71
71
 
72
- describe "User Instantiated" do
73
- subject {
72
+ describe 'User Instantiated' do
73
+ subject do
74
74
  User.create(:name => 'Anna', :other => :fo, :status => status, :so => so, :gui => :qt, :language => :pt, :sex => true, :cool => true)
75
- }
75
+ end
76
76
  let(:status) { :active }
77
77
  let(:so) { :linux }
78
78
 
79
- describe "test_symbolize_string" do
79
+ describe 'test_symbolize_string' do
80
80
  let(:status) { 'inactive' }
81
81
 
82
82
  describe '#status' do
@@ -87,7 +87,7 @@ describe "Symbolize" do
87
87
  # @user.read_attribute(:status).should eql('inactive')
88
88
  end
89
89
 
90
- describe "test_symbolize_symbol" do
90
+ describe 'test_symbolize_symbol' do
91
91
  describe '#status' do
92
92
  subject { super().status }
93
93
  it { is_expected.to eq(:active) }
@@ -100,7 +100,7 @@ describe "Symbolize" do
100
100
  # @user.read_attribute(:status).should eql('active')
101
101
  end
102
102
 
103
- describe "should work nice with numbers" do
103
+ describe 'should work nice with numbers' do
104
104
  let(:status) { 43 }
105
105
 
106
106
  describe '#status' do
@@ -111,7 +111,7 @@ describe "Symbolize" do
111
111
  # @user.read_attribute(:status).should be_nil
112
112
  end
113
113
 
114
- describe "should acts nice with nil" do
114
+ describe 'should acts nice with nil' do
115
115
  let(:status) { nil }
116
116
 
117
117
  describe '#status' do
@@ -126,8 +126,8 @@ describe "Symbolize" do
126
126
  it { expect(subject.read_attribute(:status)).to be_nil }
127
127
  end
128
128
 
129
- describe "should acts nice with blank" do
130
- let(:status) { "" }
129
+ describe 'should acts nice with blank' do
130
+ let(:status) { '' }
131
131
 
132
132
  describe '#status' do
133
133
  subject { super().status }
@@ -141,69 +141,69 @@ describe "Symbolize" do
141
141
  it { expect(subject.read_attribute(:status)).to be_nil }
142
142
  end
143
143
 
144
- it "should not validates other" do
144
+ it 'should not validates other' do
145
145
  subject.other = nil
146
146
  expect(subject).to be_valid
147
- subject.other = ""
147
+ subject.other = ''
148
148
  expect(subject).to be_valid
149
149
  end
150
150
 
151
- it "should get the correct values" do
152
- expect(User.get_status_values).to eql([["Active", :active],["Inactive", :inactive]])
153
- expect(User::STATUS_VALUES).to eql({:inactive=>"Inactive", :active=>"Active"})
151
+ it 'should get the correct values' do
152
+ expect(User.get_status_values).to eql([['Active', :active], ['Inactive', :inactive]])
153
+ expect(User::STATUS_VALUES).to eql(:inactive => 'Inactive', :active => 'Active')
154
154
  end
155
155
 
156
- it "should get the values for RailsAdmin" do
157
- expect(User.status_enum).to eql([["Active", :active],["Inactive", :inactive]])
156
+ it 'should get the values for RailsAdmin' do
157
+ expect(User.status_enum).to eql([['Active', :active], ['Inactive', :inactive]])
158
158
  end
159
159
 
160
- describe "test_symbolize_humanize" do
160
+ describe 'test_symbolize_humanize' do
161
161
  describe '#status_text' do
162
162
  subject { super().status_text }
163
- it { is_expected.to eql("Active") }
163
+ it { is_expected.to eql('Active') }
164
164
  end
165
165
  end
166
166
 
167
- it "should get the correct values" do
168
- expect(User.get_gui_values).to match_array([["cocoa", :cocoa], ["qt", :qt], ["gtk", :gtk]])
169
- expect(User::GUI_VALUES).to eql({:cocoa=>"cocoa", :qt=>"qt", :gtk=>"gtk"})
167
+ it 'should get the correct values' do
168
+ expect(User.get_gui_values).to match_array([['cocoa', :cocoa], ['qt', :qt], ['gtk', :gtk]])
169
+ expect(User::GUI_VALUES).to eql(:cocoa => 'cocoa', :qt => 'qt', :gtk => 'gtk')
170
170
  end
171
171
 
172
- describe "test_symbolize_humanize" do
172
+ describe 'test_symbolize_humanize' do
173
173
  describe '#gui_text' do
174
174
  subject { super().gui_text }
175
- it { is_expected.to eql("qt") }
175
+ it { is_expected.to eql('qt') }
176
176
  end
177
177
  end
178
178
 
179
- it "should get the correct values" do
180
- expect(User.get_so_values).to match_array([["Linux", :linux], ["Mac OS X", :mac], ["Videogame", :win]])
181
- expect(User::SO_VALUES).to eql({:linux => "Linux", :mac => "Mac OS X", :win => "Videogame"})
179
+ it 'should get the correct values' do
180
+ expect(User.get_so_values).to match_array([['Linux', :linux], ['Mac OS X', :mac], ['Videogame', :win]])
181
+ expect(User::SO_VALUES).to eql(:linux => 'Linux', :mac => 'Mac OS X', :win => 'Videogame')
182
182
  end
183
183
 
184
- describe "test_symbolize_humanize" do
184
+ describe 'test_symbolize_humanize' do
185
185
  describe '#so_text' do
186
186
  subject { super().so_text }
187
- it { is_expected.to eql("Linux") }
187
+ it { is_expected.to eql('Linux') }
188
188
  end
189
189
  end
190
190
 
191
- describe "test_symbolize_humanize" do
191
+ describe 'test_symbolize_humanize' do
192
192
  let(:so) { :mac }
193
193
 
194
194
  describe '#so_text' do
195
195
  subject { super().so_text }
196
- it { is_expected.to eql("Mac OS X") }
196
+ it { is_expected.to eql('Mac OS X') }
197
197
  end
198
198
  end
199
199
 
200
- it "should stringify" do
201
- expect(subject.other_text).to eql("fo")
200
+ it 'should stringify' do
201
+ expect(subject.other_text).to eql('fo')
202
202
  subject.other = :foo
203
- expect(subject.other_text).to eql("foo")
203
+ expect(subject.other_text).to eql('foo')
204
204
  end
205
205
 
206
- describe "should validate status" do
206
+ describe 'should validate status' do
207
207
  let(:status) { nil }
208
208
  it { is_expected.not_to be_valid }
209
209
  it 'has 1 error' do
@@ -211,62 +211,62 @@ describe "Symbolize" do
211
211
  end
212
212
  end
213
213
 
214
- it "should not validate so" do
214
+ it 'should not validate so' do
215
215
  subject.so = nil
216
216
  expect(subject).to be_valid
217
217
  end
218
218
 
219
- it "test_symbols_with_weird_chars_quoted_id" do
219
+ it 'test_symbols_with_weird_chars_quoted_id' do
220
220
  subject.status = :"weird'; chars"
221
221
  expect(subject.status_before_type_cast).to eql(:"weird'; chars")
222
222
  end
223
223
 
224
- it "should work fine through relations" do
224
+ it 'should work fine through relations' do
225
225
  subject.extras.create(:key => :one)
226
226
  expect(UserExtra.first.key).to eql(:one)
227
227
  end
228
228
 
229
- it "should play fine with null db columns" do
229
+ it 'should play fine with null db columns' do
230
230
  new_extra = subject.extras.build
231
231
  expect(new_extra).not_to be_valid
232
232
  end
233
233
 
234
- it "should play fine with null db columns" do
234
+ it 'should play fine with null db columns' do
235
235
  new_extra = subject.extras.build
236
236
  expect(new_extra).not_to be_valid
237
237
  end
238
238
 
239
- describe "i18n" do
239
+ describe 'i18n' do
240
240
 
241
- it "should test i18n ones" do
242
- expect(subject.language_text).to eql("Português")
241
+ it 'should test i18n ones' do
242
+ expect(subject.language_text).to eql('Português')
243
243
  end
244
244
 
245
- it "should get the correct values" do
246
- expect(User.get_language_values).to match_array([["Português", :pt], ["Inglês", :en]])
245
+ it 'should get the correct values' do
246
+ expect(User.get_language_values).to match_array([['Português', :pt], ['Inglês', :en]])
247
247
  end
248
248
 
249
- it "should get the correct values" do
250
- expect(User::LANGUAGE_VALUES).to eql({:pt=>"pt", :en=>"en"})
249
+ it 'should get the correct values' do
250
+ expect(User::LANGUAGE_VALUES).to eql(:pt => 'pt', :en => 'en')
251
251
  end
252
252
 
253
- it "should test boolean" do
254
- expect(subject.sex_text).to eql("Feminino")
253
+ it 'should test boolean' do
254
+ expect(subject.sex_text).to eql('Feminino')
255
255
  subject.sex = false
256
256
  expect(subject.sex_text).to eql('Masculino')
257
257
  end
258
258
 
259
- it "should get the correct values" do
260
- expect(User.get_sex_values).to eql([["Feminino", true],["Masculino", false]])
259
+ it 'should get the correct values' do
260
+ expect(User.get_sex_values).to eql([['Feminino', true], ['Masculino', false]])
261
261
  end
262
262
 
263
- it "should get the correct values" do
264
- expect(User::SEX_VALUES).to eql({true=>"true", false=>"false"})
263
+ it 'should get the correct values' do
264
+ expect(User::SEX_VALUES).to eql(true => 'true', false => 'false')
265
265
  end
266
266
 
267
- it "should translate a multiword class" do
267
+ it 'should translate a multiword class' do
268
268
  @skill = UserSkill.create(:kind => :magic)
269
- expect(@skill.kind_text).to eql("Mágica")
269
+ expect(@skill.kind_text).to eql('Mágica')
270
270
  end
271
271
 
272
272
  it "should return nil if there's no value" do
@@ -276,30 +276,30 @@ describe "Symbolize" do
276
276
 
277
277
  end
278
278
 
279
- describe "Methods" do
279
+ describe 'Methods' do
280
280
 
281
- it "should play nice with other stuff" do
281
+ it 'should play nice with other stuff' do
282
282
  expect(subject.karma).to be_nil
283
- expect(User::KARMA_VALUES).to eql({:bad => "bad", :ugly => "ugly", :good => "good"})
283
+ expect(User::KARMA_VALUES).to eql(:bad => 'bad', :ugly => 'ugly', :good => 'good')
284
284
  end
285
285
 
286
- it "should provide a boolean method" do
286
+ it 'should provide a boolean method' do
287
287
  expect(subject).not_to be_good
288
288
  subject.karma = :ugly
289
289
  expect(subject).to be_ugly
290
290
  end
291
291
 
292
- it "should work" do
293
- subject.karma = "good"
292
+ it 'should work' do
293
+ subject.karma = 'good'
294
294
  expect(subject).to be_good
295
295
  expect(subject).not_to be_bad
296
296
  end
297
297
 
298
298
  end
299
299
 
300
- describe "Changes" do
300
+ describe 'Changes' do
301
301
 
302
- it "is dirty if you change the attribute value" do
302
+ it 'is dirty if you change the attribute value' do
303
303
  expect(subject.language).to eq(:pt)
304
304
  expect(subject.language_changed?).to be false
305
305
 
@@ -308,7 +308,7 @@ describe "Symbolize" do
308
308
  expect(subject.language_changed?).to be true
309
309
  end
310
310
 
311
- it "is not dirty if you set the attribute value to the same value" do
311
+ it 'is not dirty if you set the attribute value to the same value' do
312
312
  expect(subject.language).to eq(:pt)
313
313
  expect(subject.language_changed?).to be false
314
314
 
@@ -317,15 +317,15 @@ describe "Symbolize" do
317
317
  expect(subject.language_changed?).to be false
318
318
  end
319
319
 
320
- it "is not dirty if you set the attribute value to the same value (string)" do
320
+ it 'is not dirty if you set the attribute value to the same value (string)' do
321
321
  expect(subject.language).to eq(:pt)
322
322
  expect(subject.language_changed?).to be false
323
323
 
324
- return_value = subject.language = 'pt'
324
+ subject.language = 'pt'
325
325
  expect(subject.language_changed?).to be false
326
326
  end
327
327
 
328
- it "is not dirty if you set the default attribute value to the same value" do
328
+ it 'is not dirty if you set the default attribute value to the same value' do
329
329
  user = User.create!(:language => :pt, :sex => true, :cool => true)
330
330
  expect(user.status).to eq(:active)
331
331
  expect(user).not_to be_changed
@@ -334,7 +334,7 @@ describe "Symbolize" do
334
334
  expect(user).not_to be_changed
335
335
  end
336
336
 
337
- it "is not dirty if you set the default attribute value to the same value (string)" do
337
+ it 'is not dirty if you set the default attribute value to the same value (string)' do
338
338
  user = User.create!(:language => :pt, :sex => true, :cool => true)
339
339
  expect(user.status).to eq(:active)
340
340
  expect(user).not_to be_changed
@@ -346,67 +346,67 @@ describe "Symbolize" do
346
346
 
347
347
  end
348
348
 
349
- describe "more tests on Permission" do
349
+ describe 'more tests on Permission' do
350
350
 
351
- it "should use default value on object build" do
351
+ it 'should use default value on object build' do
352
352
  expect(Permission.new.kind).to eql(:perm)
353
353
  end
354
354
 
355
- it "should not interfer on create" do
356
- Permission.create!(:name => "p7", :kind =>:temp, :lvl => 7)
357
- expect(Permission.find_by_name("p7").kind).to eql(:temp)
355
+ it 'should not interfer on create' do
356
+ Permission.create!(:name => 'p7', :kind => :temp, :lvl => 7)
357
+ expect(Permission.find_by_name('p7').kind).to eql(:temp)
358
358
  end
359
359
 
360
- it "should work on create" do
361
- pm = Permission.new(:name => "p7", :lvl => 7)
360
+ it 'should work on create' do
361
+ pm = Permission.new(:name => 'p7', :lvl => 7)
362
362
  expect(pm).to be_valid
363
363
  expect(pm.save).to be true
364
364
  end
365
365
 
366
- it "should work on create" do
367
- Permission.create!(:name => "p8", :lvl => 9)
368
- expect(Permission.find_by_name("p8").kind).to eql(:perm)
366
+ it 'should work on create' do
367
+ Permission.create!(:name => 'p8', :lvl => 9)
368
+ expect(Permission.find_by_name('p8').kind).to eql(:perm)
369
369
  end
370
370
 
371
- it "should work on edit" do
372
- Permission.create!(:name => "p8", :lvl => 9)
373
- pm = Permission.find_by_name("p8")
371
+ it 'should work on edit' do
372
+ Permission.create!(:name => 'p8', :lvl => 9)
373
+ pm = Permission.find_by_name('p8')
374
374
  pm.kind = :temp
375
375
  pm.save
376
- expect(Permission.find_by_name("p8").kind).to eql(:temp)
376
+ expect(Permission.find_by_name('p8').kind).to eql(:temp)
377
377
  end
378
378
 
379
- it "should work with default values" do
380
- pm = Permission.new(:name => "p9")
379
+ it 'should work with default values' do
380
+ pm = Permission.new(:name => 'p9')
381
381
  pm.lvl = 9
382
382
  pm.save
383
- expect(Permission.find_by_name("p9").lvl.to_i).to eql(9)
383
+ expect(Permission.find_by_name('p9').lvl.to_i).to eql(9)
384
384
  end
385
385
 
386
386
  end
387
387
 
388
- describe "Named Scopes" do
388
+ describe 'Named Scopes' do
389
389
 
390
390
  before do
391
- @anna = User.create(:name => 'Anna', :other => :fo, :status => :active , :so => :linux, :gui => :qt, :language => :pt, :sex => true, :cool => true)
391
+ @anna = User.create(:name => 'Anna', :other => :fo, :status => :active, :so => :linux, :gui => :qt, :language => :pt, :sex => true, :cool => true)
392
392
  @mary = User.create(:name => 'Mary', :other => :fo, :status => :inactive, :so => :mac, :language => :pt, :sex => true, :cool => true)
393
393
  end
394
394
 
395
- it "test_symbolized_finder" do
396
- expect(User.where({ :status => :inactive }).all.map(&:name)).to eql(['Mary'])
395
+ it 'test_symbolized_finder' do
396
+ expect(User.where(:status => :inactive).all.map(&:name)).to eql(['Mary'])
397
397
  end
398
398
 
399
- it "test_symbolized_scoping" do
400
- User.where({ :status => :inactive }).scoping do
399
+ it 'test_symbolized_scoping' do
400
+ User.where(:status => :inactive).scoping do
401
401
  expect(User.all.map(&:name)).to eql(['Mary'])
402
402
  end
403
403
  end
404
404
 
405
- it "should have main named scope" do
405
+ it 'should have main named scope' do
406
406
  expect(User.inactive).to eq([@mary])
407
407
  end
408
408
 
409
- it "should have other to test better" do
409
+ it 'should have other to test better' do
410
410
  expect(User.so(:linux)).to eq([@anna])
411
411
  end
412
412
 
@@ -428,25 +428,24 @@ describe "Symbolize" do
428
428
 
429
429
  end
430
430
 
431
-
432
- describe ": Default Value" do
431
+ describe ': Default Value' do
433
432
  before(:each) do
434
- @user = User.new(:name => 'Anna', :other => :fo, :status => :active , :so => :linux, :gui => :qt, :language => :pt, :sex => true, :cool => true)
433
+ @user = User.new(:name => 'Anna', :other => :fo, :status => :active, :so => :linux, :gui => :qt, :language => :pt, :sex => true, :cool => true)
435
434
  end
436
435
 
437
- it "should be considered during validation" do
436
+ it 'should be considered during validation' do
438
437
  @user.valid?
439
438
  expect(@user.errors.full_messages).to eq([])
440
439
  end
441
440
 
442
- it "should be taken from the DB schema definition" do
441
+ it 'should be taken from the DB schema definition' do
443
442
  expect(@user.country).to eq(:pt)
444
- expect(@user.country_text).to eq("Pt")
443
+ expect(@user.country_text).to eq('Pt')
445
444
  end
446
445
 
447
- it "should be applied to new, just saved, and reloaded objects, and also play fine with :methods option" do
446
+ it 'should be applied to new, just saved, and reloaded objects, and also play fine with :methods option' do
448
447
  expect(@user.role).to eq(:reader)
449
- expect(@user.role_text).to eq("reader")
448
+ expect(@user.role_text).to eq('reader')
450
449
  expect(@user).to be_reader
451
450
  @user.save!
452
451
  expect(@user.role).to eq(:reader)
@@ -456,7 +455,7 @@ describe "Symbolize" do
456
455
  expect(@user).to be_reader
457
456
  end
458
457
 
459
- it "should be overridable" do
458
+ it 'should be overridable' do
460
459
  @user.role = :writer
461
460
  expect(@user.role).to eq(:writer)
462
461
  expect(@user).to be_writer
@@ -471,12 +470,12 @@ describe "Symbolize" do
471
470
  # This feature is for the next major version (b/o the compatibility problem)
472
471
  it "should detect name collision caused by ':methods => true' option" do
473
472
  pending 'next major version'
474
- expect {
473
+ expect do
475
474
  User.class_eval do
476
475
  # 'reader?' method is already defined, so the line below should raise an error
477
476
  symbolize :some_attr, :in => [:reader, :guest], :methods => true
478
477
  end
479
- }.to raise_error(ArgumentError)
478
+ end.to raise_error(ArgumentError)
480
479
  end
481
480
 
482
481
  end