summaryrefslogtreecommitdiff
path: root/spec/integration/omniauth-oauth2/integration_spec.rb
blob: 3f3df8f70bdae27170420f0c3c2b1715c4162f4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
$LOAD_PATH.unshift File.dirname(__FILE__)

ENV['RACK_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

    config.assets.paths << File.join(__dir__, 'assets/javascripts')
    config.assets.debug = true
  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
  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)
  end
end