spec/models/user_spec.rb in ar-translatable-0.1.0 vs spec/models/user_spec.rb in ar-translatable-0.2.0

- old
+ new

@@ -1,43 +1,43 @@ # -*- coding: utf-8 -*- require 'rails_helper' describe User do - describe "factory" do + describe 'factory' do it { expect(build(:user)).to be_valid } end - describe "nested_attributes_for" do - let(:user) { + describe 'nested_attributes_for' do + let(:user) do User.create( - first_names_attributes: [{locale: 'ja', value: 'ジョン'}, {locale: 'en', value: 'John'}], - last_names_attributes: [{locale: 'ja', value: 'レノン'}, {locale: 'en', value: 'Lennon'}] + first_names_attributes: [{ locale: 'ja', value: 'ジョン' }, { locale: 'en', value: 'John' }], + last_names_attributes: [{ locale: 'ja', value: 'レノン' }, { locale: 'en', value: 'Lennon' }] ) - } + end it { expect(user.first_names.count).to eq 2 } it { expect(user.last_names.count).to eq 2 } end - describe "translatable" do + describe 'translatable' do before { I18n.available_locales = [:en, :ja] } let(:user) { create :user } before do create :translated_word, :en, translatable: user create :translated_word, :ja, translatable: user end - it { expect(user.first_name(:en)).to eq "John" } - it { expect(user.first_name(:ja)).to eq "ジョン" } - it { expect(user.first_name(:fr)).to eq "John" } + it { expect(user.first_name(:en)).to eq 'John' } + it { expect(user.first_name(:ja)).to eq 'ジョン' } + it { expect(user.first_name(:fr)).to eq 'John' } - context "default locale = :en" do + context 'default locale = :en' do before { I18n.default_locale = :en } after { I18n.default_locale = :en } - it { expect(user.first_name).to eq "John" } + it { expect(user.first_name).to eq 'John' } end - context "default locale = :ja" do + context 'default locale = :ja' do before { I18n.default_locale = :ja } after { I18n.default_locale = :en } - it { expect(user.first_name).to eq "ジョン" } + it { expect(user.first_name).to eq 'ジョン' } end end end