ENV["RAILS_ENV"] ||= 'test' ENV['REDIS_URL'] ||= 'redis://localhost:6379/9' require "inst_data_shipper" require File.expand_path("../dummy/config/environment.rb", __FILE__) # Rails::Generators.invoke("canvas_sync:install", ["--models", "all"], destination_root: Rails.root) require "bundler/setup" require 'rspec/rails' require 'spec_helper' require 'factory_girl_rails' require 'timecop' require 'webmock/rspec' require 'support/fake_canvas' require 'shoulda/matchers' require 'pry' require 'pry-nav' require 'with_model' require 'sidekiq/testing' Sidekiq::Testing.fake! Sidekiq::Testing.server_middleware do |chain| chain.add CanvasSync::JobBatches::Sidekiq::ServerMiddleware end Dir[File.dirname(__FILE__) + "/job_batching/support/**/*.rb"].each {|f| require f } ActiveRecord::Migration.maintain_test_schema! RSpec.configure do |config| config.extend WithModel config.include FactoryGirl::Syntax::Methods config.use_transactional_fixtures = true config.infer_spec_type_from_file_location! config.filter_rails_from_backtrace! # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_with :rspec do |c| c.syntax = :expect end config.before(:each) do stub_request(:any, /test.instructure.com/).to_rack(FakeCanvas) end end Shoulda::Matchers.configure do |config| config.integrate do |with| with.test_framework :rspec with.library :rails end end def open_canvas_fixture(name) data = File.open(File.dirname(__FILE__) + '/support/fixtures/canvas_responses/' + name + '.json', 'rb').read JSON.parse(data) end def canvas_sync_client Bearcat::Client.new(token: 'cool-token', prefix: 'http://test.instructure.com') end def set_batch_context(ctx) allow_any_instance_of(ActiveJob::Base).to receive(:batch_context).and_return(ctx.with_indifferent_access) end