Skip to content

Instantly share code, notes, and snippets.

@Sohair63
Created March 5, 2019 13:39
Show Gist options
  • Save Sohair63/d5fd65c42f7aafc93863e87b1b916f6d to your computer and use it in GitHub Desktop.
Save Sohair63/d5fd65c42f7aafc93863e87b1b916f6d to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
module ControllerMacros
def login_user
before(:each) do
@request.env['devise.mapping'] = Devise.mappings[:user]
current_collaborator = FactoryBot.create(:account_collaborator, :admin)
current_account = current_collaborator.account
@request.host = "#{current_collaborator.account.url}.example.com"
user = FactoryBot.create(:user)
current_collaborator.user = user
current_collaborator.save
sign_in user
end
end
end
# frozen_string_literal: true
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
# frozen_string_literal: true
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/vcr'
c.hook_into :webmock
c.configure_rspec_metadata!
end
# frozen_string_literal: true
require 'webmock/rspec'
RSpec.configure do |config|
config.before(:each) do
WebMock.reset!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment