spec/unit/pretty_format_spec.rb in activeadmin-1.0.0.pre4 vs spec/unit/pretty_format_spec.rb in activeadmin-1.0.0.pre5

- old
+ new

@@ -1,8 +1,9 @@ require 'rails_helper' +require 'active_admin/view_helpers/display_helper' -describe "#pretty_format" do +RSpec.describe "#pretty_format" do include ActiveAdmin::ViewHelpers::DisplayHelper def method_missing(*args, &block) mock_action_view.send *args, &block end @@ -28,28 +29,28 @@ t = Time.utc(1985,"feb",28,20,15,1) expect(pretty_format(t)).to eq "February 28, 1985 20:15" end context "apply custom localize format" do - before do + around do |example| + previous_localize_format = ActiveAdmin.application.localize_format ActiveAdmin.application.localize_format = :short + example.call + ActiveAdmin.application.localize_format = previous_localize_format end - after do - ActiveAdmin.application = nil - end it "should actually do the formatting" do t = Time.utc(1985, "feb", 28, 20, 15, 1) expect(pretty_format(t)).to eq "28 Feb 20:15" end end context "with non-English locale" do - before(:all) do + before do @previous_locale = I18n.locale.to_s I18n.locale = "es" end - after(:all) do + after do I18n.locale = @previous_locale end it "should return a localized Date or Time with long format for non-english locale" do t = Time.utc(1985,"feb",28,20,15,1) expect(pretty_format(t)).to eq "28 de febrero de 1985 20:15"