From 8f73a18500fb16619e25cf80bb9d86cd3a8608cf Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sat, 25 Apr 2015 23:15:10 +0100 Subject: [PATCH] Stub Google Calendar's JSON response globally for each spec --- spec/features/calendar/google_calendar_widget_spec.rb | 6 ------ spec/spec_helper.rb | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spec/features/calendar/google_calendar_widget_spec.rb b/spec/features/calendar/google_calendar_widget_spec.rb index 0c605a7..c9082fb 100644 --- a/spec/features/calendar/google_calendar_widget_spec.rb +++ b/spec/features/calendar/google_calendar_widget_spec.rb @@ -1,13 +1,7 @@ require 'spec_helper' feature 'Google Calendar widget', js: :true do - let(:events_list_json) { JSON.parse(File.read(Rails.root.join('spec/fixtures/google_calendar.json'))) } - before do - GoogleCalendar::Request.stub(:events_list) do - GoogleCalendar::EventList.new(events_list_json, Time.zone.name) - end - visit root_path end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e13b83b..e31306e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,4 +31,12 @@ RSpec.configure do |config| config.fixture_path = "#{::Rails.root}/spec/fixtures" config.order = 'random' config.use_transactional_fixtures = false + + config.before(:each) do + events_list_json = JSON.parse(File.read(Rails.root.join('spec/fixtures/google_calendar.json'))) + + GoogleCalendar::Request.stub(:events_list) do + GoogleCalendar::EventList.new(events_list_json, Time.zone.name) + end + end end