spec/spec_helper.rb in authenticate-0.7.1 vs spec/spec_helper.rb in authenticate-0.7.2

- old
+ new

@@ -7,18 +7,18 @@ if ActiveRecord::VERSION::STRING >= '5.0' system('bin/rails dummy:db:environment:set RAILS_ENV=test') end require 'rspec/rails' -# require 'shoulda-matchers' require 'capybara/rails' require 'capybara/rspec' require 'database_cleaner' require 'factory_girl' require 'timecop' -require 'support/mailer' +Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } + Rails.backtrace_cleaner.remove_silencers! DatabaseCleaner.strategy = :truncation # Load factory girl factories. Dir[File.join(File.dirname(__FILE__), 'factories/**/*.rb')].each { |f| require f } @@ -53,53 +53,5 @@ Capybara.reset_sessions! # Forget the (simulated) browser state Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver end end -# -# todo - enhance test helpers, put in main project -# -def mock_request(params: {}, cookies: {}) - req = double('request') - allow(req).to receive(:params).and_return(params) - allow(req).to receive(:remote_ip).and_return('111.111.111.111') - allow(req).to receive(:cookie_jar).and_return(cookies) - req -end - -def session_cookie_for(user) - { Authenticate.configuration.cookie_name.freeze.to_sym => user.session_token } -end - - -# -# Dumb glue method, deal with rails 4 vs rails 5 get/post methods. -# -def do_post(path, *args) - if Rails::VERSION::MAJOR >= 5 - post path, *args - else - post path, *(args.collect{|i| i.values}.flatten) - end -end - -def do_get(path, *args) - if Rails::VERSION::MAJOR >= 5 - get path, *args - else - get path, *(args.collect{|i| i.values}.flatten) - end -end - -def do_put(path, *args) - if Rails::VERSION::MAJOR >= 5 - put path, *args - else - put path, *(args.collect{|i| i.values}.flatten) - end -end - -# class ActionMailer::MessageDelivery -# def deliver_later -# deliver_now -# end -# end