summaryrefslogtreecommitdiff
path: root/spec/integration/omniauth-oauth2/integration_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/integration/omniauth-oauth2/integration_spec.rb')
-rw-r--r--spec/integration/omniauth-oauth2/integration_spec.rb80
1 files changed, 16 insertions, 64 deletions
diff --git a/spec/integration/omniauth-oauth2/integration_spec.rb b/spec/integration/omniauth-oauth2/integration_spec.rb
index 3f3df8f..a7c912e 100644
--- a/spec/integration/omniauth-oauth2/integration_spec.rb
+++ b/spec/integration/omniauth-oauth2/integration_spec.rb
@@ -1,74 +1,26 @@
-$LOAD_PATH.unshift File.dirname(__FILE__)
-
-ENV['RACK_ENV'] = 'test'
+ENV['RAILS_ENV'] = 'test'
require 'rspec/core'
-require 'rails'
-require 'rails/all'
-require 'action_view/testing/resolvers'
-require 'some_site'
-
-module RailsApp
- class Application < ::Rails::Application
- config.action_dispatch.show_exceptions = false
- config.active_support.deprecation = :stderr
- config.eager_load = false
- config.root = __dir__
- config.secret_key_base = 'hashieintegrationtest'
- routes.append do
- get '/' => 'application#index'
- end
+RSpec.describe 'omniauth-oauth2 inside of rails', type: :request do
+ let(:stdout) { StringIO.new }
- config.assets.paths << File.join(__dir__, 'assets/javascripts')
- config.assets.debug = true
+ around(:each) do |example|
+ original_stdout = $stdout
+ $stdout = stdout
+ require_relative 'app'
+ require 'rspec/rails'
+ example.run
+ $stdout = original_stdout
end
-end
-
-LAYOUT = <<-HTML
-<!DOCTYPE html>
-<html>
-<head>
- <title>TestApp</title>
- <%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
- <%= csrf_meta_tags %>
-</head>
-<body>
-<%= yield %>
-</body>
-</html>
-HTML
-
-INDEX = <<-HTML
-<h1>Hello, world!</h1>
-HTML
-
-class ApplicationController < ActionController::Base
- include Rails.application.routes.url_helpers
-
- layout 'application'
- self.view_paths = [ActionView::FixtureResolver.new(
- 'layouts/application.html.erb' => LAYOUT,
- 'application/index.html.erb' => INDEX
- )]
-
- def index
+ it 'does not log anything to STDOUT when initializing a Rails app and is set to Rails logger' do
+ expect(stdout.string).to eq('')
+ expect(Hashie.logger).to eq(Rails.logger)
end
-end
-Rails.application.config.middleware.use OmniAuth::Builder do
- provider :some_site
-end
-
-# the order is important
-# hashie must be loaded first to register the railtie
-require 'hashie'
-RailsApp::Application.initialize!
-
-RSpec.describe 'the Hashie logger' do
- it 'is set to the Rails logger' do
- expect(Hashie.logger).to eq(Rails.logger)
+ it 'works' do
+ get '/'
+ assert_select 'h1', 'Hello, world!'
end
end