Stub Google Calendar's JSON response globally for each spec

This commit is contained in:
Luke Barratt 2015-04-25 23:15:10 +01:00
parent ee0f92262d
commit 8f73a18500
2 changed files with 8 additions and 6 deletions

View file

@ -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

View file

@ -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