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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
ENV["RAILS_ENV"] ||= "test"
require 'coveralls'
Coveralls.wear!('rails')
require File.join(File.dirname(__FILE__), "..", "config", "environment")
require Rails.root.join("spec", "helper_methods")
require Rails.root.join("spec", "spec-doc")
require "rspec/rails"
require "webmock/rspec"
require "factory_girl"
require "sidekiq/testing"
require "shoulda/matchers"
require "diaspora_federation/schemas"
include HelperMethods
Dir["#{File.dirname(__FILE__)}/shared_behaviors/**/*.rb"].each do |f|
require f
end
ProcessedImage.enable_processing = false
UnprocessedImage.enable_processing = false
def alice
@alice ||= User.find_by(username: "alice")
end
def bob
@bob ||= User.find_by(username: "bob")
end
def eve
@eve ||= User.find_by(username: "eve")
end
def local_luke
@local_luke ||= User.find_by(username: "luke")
end
def local_leia
@local_leia ||= User.find_by(username: "leia")
end
def remote_raphael
@remote_raphael ||= Person.find_by(diaspora_handle: "raphael@remote.net")
end
def peter
@peter ||= User.find_by(username: "peter")
end
def photo_fixture_name
@photo_fixture_name = File.join(File.dirname(__FILE__), "fixtures", "button.png")
end
def jwks_file_path
@jwks_file = File.join(File.dirname(__FILE__), "fixtures", "jwks.json")
end
def valid_client_assertion_path
@valid_client_assertion = File.join(File.dirname(__FILE__), "fixtures", "valid_client_assertion.txt")
end
def client_assertion_with_tampered_sig_path
@client_assertion_with_tampered_sig = File.join(File.dirname(__FILE__), "fixtures",
"client_assertion_with_tampered_sig.txt")
end
def client_assertion_with_nonexistent_kid_path
@client_assertion_with_nonexistent_kid = File.join(File.dirname(__FILE__), "fixtures",
"client_assertion_with_nonexistent_kid.txt")
end
def client_assertion_with_nonexistent_client_id_path
@client_assertion_with_nonexistent_client_id = File.join(File.dirname(__FILE__), "fixtures",
"client_assertion_with_nonexistent_client_id.txt")
end
# Force fixture rebuild
FileUtils.rm_f(Rails.root.join("tmp", "fixture_builder.yml"))
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
fixture_builder_file = "#{File.dirname(__FILE__)}/support/fixture_builder.rb"
support_files = Dir["#{File.dirname(__FILE__)}/support/**/*.rb"] - [fixture_builder_file]
support_files.each {|f| require f }
require fixture_builder_file
RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::IntegrationHelpers, type: :request
config.mock_with :rspec
config.example_status_persistence_file_path = "tmp/rspec-persistance.txt"
config.render_views
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.before(:each) do
I18n.locale = :en
stub_request(:post, "https://pubsubhubbub.appspot.com/")
$process_queue = false
end
config.expect_with :rspec do |expect_config|
expect_config.syntax = :expect
end
config.after(:all) do
`rm -rf #{Rails.root}/tmp/uploads/*`
end
# Reset overridden settings
config.after(:each) do
AppConfig.reset_dynamic!
end
# Reset test mails
config.after(:each) do
ActionMailer::Base.deliveries.clear
end
# Reset gon
config.after(:each) do
RequestStore.store[:gon].gon.clear unless RequestStore.store[:gon].nil?
end
config.include FactoryGirl::Syntax::Methods
config.include JSON::SchemaMatchers
config.json_schemas[:archive_schema] = "lib/schemas/archive-format.json"
JSON::Validator.add_schema(
JSON::Schema.new(
DiasporaFederation::Schemas.federation_entities,
Addressable::URI.parse(DiasporaFederation::Schemas::FEDERATION_ENTITIES_URI)
)
)
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
shared_context suppress_csrf_verification: :none do
before do
ActionController::Base.allow_forgery_protection = true
end
end
|