rspeckled 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/LICENSE.txt +19 -0
- data/README.md +2 -0
- data/Rakefile +1 -0
- data/lib/rspeckled/helpers/factories.rb +3 -0
- data/lib/rspeckled/helpers/null_objects.rb +3 -0
- data/lib/rspeckled/helpers/session_helpers.rb +5 -0
- data/lib/rspeckled/helpers.rb +3 -0
- data/lib/rspeckled/mock_authentications/omniauth/ebay.rb +24 -0
- data/lib/rspeckled/mock_authentications/omniauth/facebook.rb +43 -0
- data/lib/rspeckled/mock_authentications/omniauth/twitter.rb +43 -0
- data/lib/rspeckled/mock_authentications/omniauth.rb +1 -0
- data/lib/rspeckled/plugins/authentication.rb +111 -0
- data/lib/rspeckled/plugins/bullet.rb +25 -0
- data/lib/rspeckled/plugins/carrier_wave.rb +34 -0
- data/lib/rspeckled/plugins/code_climate.rb +8 -0
- data/lib/rspeckled/plugins/database_cleaner.rb +49 -0
- data/lib/rspeckled/plugins/devise.rb +23 -0
- data/lib/rspeckled/plugins/elasticsearch.rb +32 -0
- data/lib/rspeckled/plugins/email.rb +27 -0
- data/lib/rspeckled/plugins/factory_girl.rb +20 -0
- data/lib/rspeckled/plugins/fakeredis.rb +4 -0
- data/lib/rspeckled/plugins/features.rb +38 -0
- data/lib/rspeckled/plugins/mocks.rb +14 -0
- data/lib/rspeckled/plugins/omniauth.rb +45 -0
- data/lib/rspeckled/plugins/rails/engine.rb +10 -0
- data/lib/rspeckled/plugins/rails/strong_parameters.rb +13 -0
- data/lib/rspeckled/plugins/recaptcha.rb +12 -0
- data/lib/rspeckled/plugins/referehencible.rb +21 -0
- data/lib/rspeckled/plugins/shoulda.rb +40 -0
- data/lib/rspeckled/plugins/sidekiq.rb +29 -0
- data/lib/rspeckled/plugins/simple_cov.rb +13 -0
- data/lib/rspeckled/plugins/singleton.rb +23 -0
- data/lib/rspeckled/plugins/stripe.rb +33 -0
- data/lib/rspeckled/plugins/test_after_commit.rb +4 -0
- data/lib/rspeckled/plugins/timecop.rb +35 -0
- data/lib/rspeckled/plugins/vcr.rb +38 -0
- data/lib/rspeckled/plugins/webmock.rb +25 -0
- data/lib/rspeckled/plugins/wisper.rb +14 -0
- data/lib/rspeckled/plugins.rb +25 -0
- data/lib/rspeckled/spec_helpers/active_record_basic.rb +4 -0
- data/lib/rspeckled/spec_helpers/active_record_connection_setup.rb +25 -0
- data/lib/rspeckled/spec_helpers/rails_engine.rb +16 -0
- data/lib/rspeckled/support/expectations.rb +6 -0
- data/lib/rspeckled/support/failures.rb +5 -0
- data/lib/rspeckled/support/focused.rb +6 -0
- data/lib/rspeckled/support/formatters.rb +6 -0
- data/lib/rspeckled/support/garbage_collection.rb +59 -0
- data/lib/rspeckled/support/heroku.rb +1 -0
- data/lib/rspeckled/support/i18n.rb +5 -0
- data/lib/rspeckled/support/misc.rb +1 -0
- data/lib/rspeckled/support/mocks.rb +7 -0
- data/lib/rspeckled/support/output.rb +1 -0
- data/lib/rspeckled/support/pending.rb +3 -0
- data/lib/rspeckled/support/rails.rb +13 -0
- data/lib/rspeckled/support/random.rb +3 -0
- data/lib/rspeckled/support/selenium.rb +4 -0
- data/lib/rspeckled/support.rb +1 -0
- data/lib/rspeckled/vcr_matchers/uri_without_trailing_id.rb +37 -0
- data/lib/rspeckled/version.rb +3 -0
- data/lib/rspeckled.rb +8 -0
- data.tar.gz.sig +4 -0
- metadata +169 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b32936e000261bcdf6c953a314ccadba88a3f5a5
|
4
|
+
data.tar.gz: db33df77c97bce23e4400d7dd8b9f83e45fa5d81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 340aa33af1023306564fff4634e69fd6950aa2d25f980df3af8c840a2137a7292f62ced15bd75fd80b3ee539a18472f3fa4fdb66b4b9f1b556a75ceccf1d0993
|
7
|
+
data.tar.gz: 3d23727d2681262209055b1e81efc2ce070857231ef3ab84e8af15bb9bd51f2e85b80174a8ce70689d71e668863d8080f9c7ec35c619794e5ca13b8de4e675bd
|
checksums.yaml.gz.sig
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2016 The Grand Design
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module MockAuthentications
|
3
|
+
module Ebay
|
4
|
+
def self.authentication
|
5
|
+
OmniAuth::AuthHash.new(
|
6
|
+
'provider' => 'ebay',
|
7
|
+
'uid' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
8
|
+
'info' =>
|
9
|
+
{
|
10
|
+
'ebay_id' => 'my_username',
|
11
|
+
'ebay_token' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
12
|
+
'email' => 'username@example.com',
|
13
|
+
'full_name' => 'Gorby Thunderhorse',
|
14
|
+
'country' => 'US',
|
15
|
+
},
|
16
|
+
'credentials' => {},
|
17
|
+
'extra' => {
|
18
|
+
'internal_return_to' => nil,
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module MockAuthentications
|
3
|
+
module Facebook
|
4
|
+
def self.authentication
|
5
|
+
OmniAuth::AuthHash.new(
|
6
|
+
'provider' => 'facebook',
|
7
|
+
'uid' => '100002971692646',
|
8
|
+
'credentials' => {
|
9
|
+
'token' => 'my_facebook_token',
|
10
|
+
},
|
11
|
+
'info' => {
|
12
|
+
'name' => 'Sharon Letuchysky',
|
13
|
+
'email' => nil,
|
14
|
+
'nickname' => nil,
|
15
|
+
'first_name' => 'Sharon',
|
16
|
+
'last_name' => 'Letuchysky',
|
17
|
+
'location' => nil,
|
18
|
+
'description' => nil,
|
19
|
+
'image' => 'http://graph.facebook.com/100002971692646/picture?type=square',
|
20
|
+
'phone' => nil,
|
21
|
+
'urls' => {
|
22
|
+
'Facebook' => 'http://www.facebook.com/profile.php?id=100002971692646',
|
23
|
+
'Website' => nil,
|
24
|
+
},
|
25
|
+
},
|
26
|
+
'extra' => {
|
27
|
+
'user_hash' => {
|
28
|
+
'id' => '100002971692646',
|
29
|
+
'name' => 'Sharon Ambiggjcaccg Letuchysky',
|
30
|
+
'first_name' => 'Sharon',
|
31
|
+
'middle_name' => 'Ambiggjcaccg',
|
32
|
+
'last_name' => 'Letuchysky',
|
33
|
+
'link' => 'http://www.facebook.com/profile.php?id=100002971692646',
|
34
|
+
'gender' => 'female',
|
35
|
+
'locale' => 'en_US',
|
36
|
+
'updated_time' => '2011-09-11T17:00:51+0000',
|
37
|
+
},
|
38
|
+
}
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module MockAuthentications
|
3
|
+
module Twitter
|
4
|
+
def self.authentication
|
5
|
+
OmniAuth::AuthHash.new(
|
6
|
+
'provider' => 'twitter',
|
7
|
+
'uid' => '100002971692646',
|
8
|
+
'credentials' => {
|
9
|
+
'token' => 'my_twitter_token',
|
10
|
+
},
|
11
|
+
'info' => {
|
12
|
+
'name' => 'Sharon Letuchysky',
|
13
|
+
'email' => nil,
|
14
|
+
'nickname' => nil,
|
15
|
+
'first_name' => 'Sharon',
|
16
|
+
'last_name' => 'Letuchysky',
|
17
|
+
'location' => nil,
|
18
|
+
'description' => nil,
|
19
|
+
'image' => 'http://graph.facebook.com/100002971692646/picture?type=square',
|
20
|
+
'phone' => nil,
|
21
|
+
'urls' => {
|
22
|
+
'Facebook' => 'http://www.facebook.com/profile.php?id=100002971692646',
|
23
|
+
'Website' => nil,
|
24
|
+
},
|
25
|
+
},
|
26
|
+
'extra' => {
|
27
|
+
'user_hash' => {
|
28
|
+
'id' => '100002971692646',
|
29
|
+
'name' => 'Sharon Ambiggjcaccg Letuchysky',
|
30
|
+
'first_name' => 'Sharon',
|
31
|
+
'middle_name' => 'Ambiggjcaccg',
|
32
|
+
'last_name' => 'Letuchysky',
|
33
|
+
'link' => 'http://www.facebook.com/profile.php?id=100002971692646',
|
34
|
+
'gender' => 'female',
|
35
|
+
'locale' => 'en_US',
|
36
|
+
'updated_time' => '2011-09-11T17:00:51+0000',
|
37
|
+
},
|
38
|
+
}
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.expand_path('../omniauth/*.rb', __FILE__)].each { |f| require f }
|
@@ -0,0 +1,111 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.around(:each, :mock_auth => lambda { |v| !!v }) do |example|
|
3
|
+
options = example.metadata[:mock_auth]
|
4
|
+
|
5
|
+
authentication_type = if options.is_a?(Hash) && options[:type]
|
6
|
+
options[:type]
|
7
|
+
else
|
8
|
+
:standard
|
9
|
+
end
|
10
|
+
|
11
|
+
klass = case options
|
12
|
+
when TrueClass
|
13
|
+
User
|
14
|
+
when Hash
|
15
|
+
options[:class] || User
|
16
|
+
else
|
17
|
+
options
|
18
|
+
end
|
19
|
+
|
20
|
+
underscored_class_name = klass.
|
21
|
+
name[/(?:.*::)?(\w+)\z/, 1].
|
22
|
+
gsub(/([a-z])([A-Z])/, '\1_\2').
|
23
|
+
downcase
|
24
|
+
|
25
|
+
current_class_method = if options.is_a?(Hash) && options[:method]
|
26
|
+
options[:method]
|
27
|
+
else
|
28
|
+
:"current_#{underscored_class_name}"
|
29
|
+
end
|
30
|
+
|
31
|
+
instance = if options.is_a?(Hash) && options[:strategy] == :instance
|
32
|
+
klass.new
|
33
|
+
else
|
34
|
+
FactoryGirl.create(underscored_class_name.to_sym)
|
35
|
+
end
|
36
|
+
|
37
|
+
inferred_auth_method = if options.is_a?(Hash) && options[:authentication_method]
|
38
|
+
options[:authentication_method]
|
39
|
+
else
|
40
|
+
:"authenticate_#{underscored_class_name}!"
|
41
|
+
end
|
42
|
+
|
43
|
+
authentication_controller_class = if example.metadata[:type] == :controller
|
44
|
+
described_class
|
45
|
+
else
|
46
|
+
ApplicationController
|
47
|
+
end
|
48
|
+
|
49
|
+
authentication_controller_instance = authentication_controller_class.new
|
50
|
+
|
51
|
+
authentication_successful = if options.is_a?(Hash) && options.key?(:status)
|
52
|
+
options[:status] == :authorized
|
53
|
+
else
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
authentication_result = authentication_successful ? instance : nil
|
58
|
+
|
59
|
+
if authentication_type == :standard
|
60
|
+
authentication_method = if authentication_controller_instance.respond_to?(inferred_auth_method, true)
|
61
|
+
inferred_auth_method
|
62
|
+
elsif authentication_controller_instance.respond_to?(:authenticate, true)
|
63
|
+
:authenticate
|
64
|
+
end
|
65
|
+
|
66
|
+
authentication_controller_class.__send__(:define_method, authentication_method) { authentication_successful }
|
67
|
+
authentication_controller_class.__send__(:define_method, current_class_method) { authentication_result }
|
68
|
+
authentication_controller_class.__send__(:helper_method, current_class_method)
|
69
|
+
example.example_group_instance.class.let(current_class_method) { authentication_result }
|
70
|
+
|
71
|
+
example.run
|
72
|
+
|
73
|
+
authentication_controller_class.__send__(:remove_method, current_class_method)
|
74
|
+
elsif authentication_type == :json_web_token
|
75
|
+
@token_data = if options.is_a?(Hash) && options[:data]
|
76
|
+
options[:data]
|
77
|
+
else
|
78
|
+
[
|
79
|
+
{
|
80
|
+
'iss' => 'rspeckled',
|
81
|
+
'own' => instance['account_id'] || instance['id'],
|
82
|
+
'sub' => example.file_path,
|
83
|
+
'aud' => 'rspec',
|
84
|
+
'exp' => 1.day.from_now.utc.to_i,
|
85
|
+
'nbf' => 1.day.ago.utc.to_i,
|
86
|
+
'iat' => Time.now.utc.to_i,
|
87
|
+
'jti' => SecureRandom.uuid,
|
88
|
+
'sid' => instance['account_id'] || instance['id'],
|
89
|
+
'rol' => options[:role] || 'basic',
|
90
|
+
},
|
91
|
+
{
|
92
|
+
'typ' => 'JWT',
|
93
|
+
'cty' => 'application/json-web-token',
|
94
|
+
},
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
example.example_group_instance.class.let(current_class_method) { authentication_result }
|
99
|
+
|
100
|
+
example.run
|
101
|
+
else
|
102
|
+
fail 'You must specify a valid type for the :mock_auth metadata'
|
103
|
+
end
|
104
|
+
|
105
|
+
instance.delete unless options.is_a?(Hash) && options[:strategy] == :instance
|
106
|
+
end
|
107
|
+
|
108
|
+
config.before(:each, :mock_auth => lambda { |v| !!v }) do |_example|
|
109
|
+
request.env['X_DECRYPTED_JSON_WEB_TOKEN'] = @token_data
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Bullet Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bullet'
|
7
|
+
|
8
|
+
Bullet.enable = true
|
9
|
+
Bullet.bullet_logger = true
|
10
|
+
Bullet.raise = true
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.before(:each) do
|
14
|
+
Bullet.start_request if Bullet.enable?
|
15
|
+
end
|
16
|
+
|
17
|
+
config.after(:each) do
|
18
|
+
if Bullet.enable?
|
19
|
+
Bullet.perform_out_of_channel_notifications if Bullet.notification?
|
20
|
+
Bullet.end_request
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# CarrierWave Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'carrierwave'
|
7
|
+
require 'carrierwave/test/matchers'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.include CarrierWave::Test::Matchers, :file_attachment => true
|
11
|
+
end
|
12
|
+
|
13
|
+
CarrierWave.configure do |config|
|
14
|
+
config.storage = :file
|
15
|
+
config.root = File.expand_path('./tmp')
|
16
|
+
config.enable_processing = false
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.around(:each, :file_attachment => true) do |example|
|
21
|
+
previous_carrierwave_processing_mode = subject.class.enable_processing
|
22
|
+
previous_carrierwave_storage_mode = subject.class.storage
|
23
|
+
|
24
|
+
subject.class.enable_processing = true
|
25
|
+
subject.class.storage = :file
|
26
|
+
|
27
|
+
example.run
|
28
|
+
|
29
|
+
subject.class.storage = previous_carrierwave_storage_mode
|
30
|
+
subject.class.enable_processing = previous_carrierwave_processing_mode
|
31
|
+
end
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Database Cleaner Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'database_cleaner'
|
7
|
+
|
8
|
+
begin
|
9
|
+
autodetected = DatabaseCleaner::Base.new.__send__(:autodetect)
|
10
|
+
rescue DatabaseCleaner::NoORMDetected
|
11
|
+
autodetected = false
|
12
|
+
end
|
13
|
+
|
14
|
+
if autodetected
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.before(:suite) do
|
17
|
+
DatabaseCleaner.clean_with(:truncation)
|
18
|
+
end
|
19
|
+
|
20
|
+
config.before(:each) do
|
21
|
+
DatabaseCleaner.strategy = :transaction
|
22
|
+
end
|
23
|
+
|
24
|
+
config.before(:each, :js => true) do
|
25
|
+
DatabaseCleaner.strategy = :truncation
|
26
|
+
end
|
27
|
+
|
28
|
+
config.before(:each) do
|
29
|
+
DatabaseCleaner.start
|
30
|
+
end
|
31
|
+
|
32
|
+
config.after(:each) do
|
33
|
+
DatabaseCleaner.clean
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if defined? RSpec::Rails
|
38
|
+
RSpec.configure do |config|
|
39
|
+
config.use_transactional_fixtures = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
rescue LoadError
|
44
|
+
if defined? RSpec::Rails
|
45
|
+
RSpec.configure do |config|
|
46
|
+
config.use_transactional_fixtures = true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Devise Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'devise'
|
7
|
+
|
8
|
+
Devise.stretches = 1
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include Devise::TestHelpers, :type => :controller
|
12
|
+
config.include Warden::Test::Helpers, :type => :feature
|
13
|
+
|
14
|
+
config.before(:all, :type => :feature) do |_example|
|
15
|
+
Warden.test_mode!
|
16
|
+
end
|
17
|
+
|
18
|
+
config.before(:each, :type => :controller) do |_example|
|
19
|
+
@request.env['devise.mapping'] = Devise.mappings[:user]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
rescue LoadError
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Elasticsearch Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'elasticsearch-extensions'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.before(:suite, :elasticsearch => lambda { |v| !!v }) do
|
10
|
+
Elasticsearch::Extensions::Test::Cluster.start(:port => 9200) unless Elasticsearch::Extensions::Test::Cluster.running?
|
11
|
+
end
|
12
|
+
|
13
|
+
config.around(:each, :elasticsearch => lambda { |v| !!v }) do |example|
|
14
|
+
model = case example.metadata[:elasticsearch]
|
15
|
+
when String
|
16
|
+
example.metadata[:elasticsearch].constantize
|
17
|
+
end
|
18
|
+
|
19
|
+
model.__elasticsearch__.client.indices.delete :index => '_all'
|
20
|
+
model.__elasticsearch__.create_index! :index => model.index_name
|
21
|
+
|
22
|
+
example.run
|
23
|
+
|
24
|
+
model.__elasticsearch__.client.indices.delete :index => '_all'
|
25
|
+
end
|
26
|
+
|
27
|
+
config.after(:suite, :elasticsearch => lambda { |v| !!v }) do
|
28
|
+
Elasticsearch::Extensions::Test::Cluster.stop(:port => 9200) if Elasticsearch::Extensions::Test::Cluster.running?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
rescue LoadError
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Email Plugin
|
3
|
+
##############################################################################
|
4
|
+
#
|
5
|
+
# The approach to this plugin is twofold. First it uses the excellent email_spec
|
6
|
+
# gem to add helpers and matchers to any spec file with :email => true set.
|
7
|
+
# Secondly, it will also clear all deliveries from ActionMailer if it is loaded.
|
8
|
+
#
|
9
|
+
# https://github.com/bmabey/email-spec/
|
10
|
+
#
|
11
|
+
begin
|
12
|
+
require 'email_spec'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.include EmailSpec::Helpers, :email => true
|
16
|
+
config.include EmailSpec::Matchers, :email => true
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
end
|
20
|
+
|
21
|
+
if defined? ActionMailer
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.after(:each, :email => true) do
|
24
|
+
ActionMailer::Base.deliveries.clear
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Factory Girl Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'factory_girl'
|
7
|
+
|
8
|
+
FactoryGirl.definition_file_paths << './spec/factories'
|
9
|
+
|
10
|
+
if FactoryGirl.configuration.factories.count.zero? &&
|
11
|
+
Rails.application.class.name.match(/Dummy/)
|
12
|
+
|
13
|
+
FactoryGirl.find_definitions
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.include FactoryGirl::Syntax::Methods
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Features Plugin
|
3
|
+
##############################################################################
|
4
|
+
#
|
5
|
+
# This plugin enables the feature/scenario/background/given syntax in RSpec
|
6
|
+
# without requiring Capybara as a dependency (and may also be used outside of
|
7
|
+
# Rails). The contents of this file are taken verbatim from
|
8
|
+
#
|
9
|
+
# https://github.com/jnicklas/capybara/blob/cd4327857bd3bafa8614b7bffb2886a8ab401953/lib/capybara/rspec/features.rb
|
10
|
+
#
|
11
|
+
# and should be updated whenever that file is updated.
|
12
|
+
#
|
13
|
+
module Capybara
|
14
|
+
module Features
|
15
|
+
def self.included(base)
|
16
|
+
base.instance_eval do
|
17
|
+
alias_method :background, :before
|
18
|
+
alias_method :scenario, :it
|
19
|
+
alias_method :xscenario, :xit
|
20
|
+
alias_method :given, :let
|
21
|
+
alias_method :given!, :let!
|
22
|
+
alias_method :feature, :describe
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.feature(*args, &block)
|
29
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
30
|
+
options[:capybara_feature] = true
|
31
|
+
options[:type] = :feature
|
32
|
+
options[:caller] ||= caller
|
33
|
+
args.push(options)
|
34
|
+
|
35
|
+
describe(*args, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec.configuration.include Capybara::Features, :capybara_feature => true
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.around(:each, :verify => false) do |example|
|
3
|
+
verify_partial = RSpec::Mocks.configuration.instance_variable_get(:@verify_partial_doubles)
|
4
|
+
verify_constant = RSpec::Mocks.configuration.instance_variable_get(:@verify_doubled_constant_names)
|
5
|
+
|
6
|
+
RSpec::Mocks.configuration.verify_partial_doubles = example.metadata[:verify]
|
7
|
+
RSpec::Mocks.configuration.verify_doubled_constant_names = example.metadata[:verify]
|
8
|
+
|
9
|
+
example.run
|
10
|
+
|
11
|
+
RSpec::Mocks.configuration.verify_partial_doubles = verify_partial
|
12
|
+
RSpec::Mocks.configuration.verify_doubled_constant_names = verify_constant
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# OmniAuth Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'omniauth'
|
7
|
+
require 'rspeckled/mock_authentications/omniauth'
|
8
|
+
|
9
|
+
###
|
10
|
+
# Tell OmniAuth to just return whatever hash we want for each auth type
|
11
|
+
#
|
12
|
+
OmniAuth.configure do |config|
|
13
|
+
config.test_mode = true
|
14
|
+
config.mock_auth[:facebook] = OmniAuth::MockAuthentications::Facebook.authentication
|
15
|
+
config.mock_auth[:twitter] = OmniAuth::MockAuthentications::Twitter.authentication
|
16
|
+
config.mock_auth[:ebay] = OmniAuth::MockAuthentications::Ebay.authentication
|
17
|
+
end
|
18
|
+
|
19
|
+
###
|
20
|
+
# Except we don't want OmniAuth to fake anything when doing live tests
|
21
|
+
#
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.around(:each, :js => true) do |example|
|
24
|
+
previous_omniauth_test_mode = OmniAuth.config.test_mode
|
25
|
+
OmniAuth.config.test_mode = false
|
26
|
+
|
27
|
+
example.metadata.fetch(:mock_oauth, {}).each do |auth_type, auth_hash|
|
28
|
+
OmniAuth.config.add_mock(auth_type, auth_hash)
|
29
|
+
end
|
30
|
+
|
31
|
+
example.run
|
32
|
+
|
33
|
+
OmniAuth.config.test_mode = previous_omniauth_test_mode
|
34
|
+
end
|
35
|
+
|
36
|
+
config.before(:each, :type => :controller, :mock_oauth => lambda { |v| !!v }) do |example|
|
37
|
+
request.env['omniauth.auth'] = if example.metadata[:mock_oauth].is_a? Symbol
|
38
|
+
OmniAuth.config.mock_auth[example.metadata[:mock_oauth]]
|
39
|
+
else
|
40
|
+
OmniAuth::AuthHash.new(example.metadata[:mock_oauth])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rescue LoadError
|
45
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
if defined?(ActionController::Parameters)
|
2
|
+
always_permitted_parameters = %w{id}
|
3
|
+
|
4
|
+
if ActionController::Parameters.respond_to?(:always_permitted_parameters)
|
5
|
+
ActionController::Parameters.always_permitted_parameters += always_permitted_parameters
|
6
|
+
else
|
7
|
+
always_permitted_parameters.each do |always_permitted_parameter|
|
8
|
+
ActionController::Parameters::NEVER_UNPERMITTED_PARAMS << always_permitted_parameter
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ActionController::Parameters.action_on_unpermitted_parameters = :raise
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# Recaptcha Plugin
|
3
|
+
##############################################################################
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'recaptcha'
|
7
|
+
|
8
|
+
Recaptcha.configure do |config|
|
9
|
+
config.skip_verify_env = ['test']
|
10
|
+
end
|
11
|
+
rescue LoadError
|
12
|
+
end
|