diff --git a/spec/features/officing/residence_spec.rb b/spec/features/officing/residence_spec.rb index e5f060366..034d47420 100644 --- a/spec/features/officing/residence_spec.rb +++ b/spec/features/officing/residence_spec.rb @@ -1,16 +1,8 @@ require 'rails_helper' -feature 'Residence' do +feature 'Residence', :with_frozen_time do let(:officer) { create(:poll_officer) } - background do - travel_to Time.now # TODO: use `freeze_time` after migrating to Rails 5. - end - - after do - travel_back - end - feature "Officers without assignments" do scenario "Can not access residence verification" do diff --git a/spec/features/officing/results_spec.rb b/spec/features/officing/results_spec.rb index 821e4b001..376629314 100644 --- a/spec/features/officing/results_spec.rb +++ b/spec/features/officing/results_spec.rb @@ -1,9 +1,8 @@ require 'rails_helper' -feature 'Officing Results' do +feature 'Officing Results', :with_frozen_time do background do - travel_to Time.now # TODO: use `freeze_time` after migrating to Rails 5. @poll_officer = create(:poll_officer) @officer_assignment = create(:poll_officer_assignment, :final, officer: @poll_officer) @poll = @officer_assignment.booth_assignment.poll @@ -18,10 +17,6 @@ feature 'Officing Results' do login_as(@poll_officer.user) end - after do - travel_back - end - scenario 'Only polls where user is officer for results are accessible' do regular_officer_assignment_1 = create(:poll_officer_assignment, officer: @poll_officer) regular_officer_assignment_2 = create(:poll_officer_assignment, officer: @poll_officer) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 044697bef..f14ee4041 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -82,6 +82,14 @@ RSpec.configure do |config| Bullet.end_request end + config.before(:each, :with_frozen_time) do + travel_to Time.now # TODO: use `freeze_time` after migrating to Rails 5. + end + + config.after(:each, :with_frozen_time) do + travel_back + end + # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. config.example_status_persistence_file_path = "spec/examples.txt"