spec/i18n_spec.rb in lookout-rack-utils-3.8.0.39 vs spec/i18n_spec.rb in lookout-rack-utils-4.0.0.44

- old
+ new

@@ -17,11 +17,11 @@ describe '.t' do let(:args) { double('mock arguments') } before :each do - ::I18n.should_receive(:t).with(args) + expect(::I18n).to receive(:t).with(args) end it 'should call out to ::I18n.t' do helper.t(args) end @@ -30,44 +30,34 @@ describe 'accepted_languages' do subject { helper.accepted_languages } before :each do helper.request = Object.new - helper.request.stub(:env).and_return({'HTTP_ACCEPT_LANGUAGE' => accepted_langs}) + expect(helper.request).to receive(:env).and_return({'HTTP_ACCEPT_LANGUAGE' => accepted_langs}) end context 'if HTTP_ACCEPT_LANGUAGE is not set' do let(:accepted_langs) { nil } - before :each do - helper.configatron = Object.new - helper.configatron.stub(:locales).and_return([]) - end - it { should be_empty } end context 'if HTTP_ACCEPT_LANGUAGE is set' do # Example borrowed from http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html let(:accepted_langs) { 'da, en-gb;q=0.8, en;q=0.7' } - before :each do - helper.configatron = Object.new - helper.configatron.stub(:locales).and_return(['en']) - end it { should_not be_empty } end end describe '.current_locale' do - let(:target_locale) { 'target locale' } let(:default_locale) { 'default locale' } let(:accepted_langs) { [target_locale] } before :each do - helper.stub(:accepted_languages).and_return(accepted_langs) + allow(helper).to receive(:accepted_languages).and_return(accepted_langs) end subject (:current_locale) { helper.current_locale } context 'if locale is not nil' do @@ -80,20 +70,20 @@ context 'if locale is nil' do context 'if configatron does not contain any of the accepted langs' do before :each do helper.configatron = Object.new - helper.configatron.stub(:locales).and_return([]) - helper.configatron.stub(:default_locale).and_return(default_locale) + expect(helper.configatron).to receive(:locales).and_return([]) + expect(helper.configatron).to receive(:default_locale).and_return(default_locale) end it { should eql default_locale } end context 'if configatron.locales contains one of the accepted languages' do before :each do helper.configatron = Object.new - helper.configatron.stub(:locales).and_return([target_locale]) + expect(helper.configatron).to receive(:locales).and_return([target_locale]) end it { should eql target_locale } end end