ruby - Active Record unexpected i18n error -
i building ruby project uses active record not rails. inside 1 of tests trying following:
it "fails no driver name" command = "driver" expect {command_file.process_driver command}.to raise_error(activerecord::recordinvalid) end
and here method trying call
def process_driver command driver_name = command.split[1] driver.create! :name => driver_name end
i expect passing :name => nil
driver.create!
should throw recordinvalid
instead i18n::invalidlocaledata
. here backtrace
expected activerecord::recordinvalid, got #<i18n::invalidlocaledata: can not load translations /users/me/.rbenv/versions/2.3.1/lib/r...ems/activesupport-5.1.3/lib/active_support/locale/en.yml: expects return hash, not> backtrace: # ./command_file.rb:81:in `process_driver' # ./command_file.rb:63:in `block in process' # ./command_file.rb:51:in `each' # ./command_file.rb:51:in `each_with_index' # ./command_file.rb:51:in `process' # ./spec/command_file_spec.rb:60:in `block (5 levels) in <top (required)>' # ./spec/command_file_spec.rb:60:in `block (4 levels) in <top (required)>' # ./spec/spec_helper.rb:75:in `block (3 levels) in <top (required)>' # ./spec/spec_helper.rb:74:in `block (2 levels) in <top (required)>'
and here gemfile
source 'https://rubygems.org' gem 'sqlite3', '~> 1.3', '>= 1.3.13' gem 'activerecord', '~> 5.1', '>= 5.1.3' gem 'pry', '~> 0.10.4' gem 'rspec', '~> 3.6' gem 'factory_girl', '~> 4.5' group :test gem 'database_cleaner' end
i have no locale files of own.
any idea what's going on? not attempting kind of translation in project. don't understand why locale file provided active_support
should fail. i'd happy disable i18n somehow if possible don't know how. ideas problem is?
for ever reason :en
not set default locale. fixed in spec_helper.rb
adding i18n.default_locale = 'en'
:
i18n.default_locale = 'en' # <--- add line rspec.configure |config| # config here... end
i realize doesn't fix larger problem of why locale file active_support
not loading, challenge make error go away, not use i18n
Comments
Post a Comment