rspeckled 0.0.54 → 0.0.55

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rspeckled/helpers/responses.rb +1 -3
  4. data/lib/rspeckled/plugins/authentication.rb +5 -5
  5. data/lib/rspeckled/plugins/awesome_print.rb +67 -75
  6. data/lib/rspeckled/plugins/bullet.rb +11 -20
  7. data/lib/rspeckled/plugins/capybara.rb +109 -120
  8. data/lib/rspeckled/plugins/carrier_wave.rb +18 -26
  9. data/lib/rspeckled/plugins/database_cleaner.rb +23 -37
  10. data/lib/rspeckled/plugins/devise.rb +9 -18
  11. data/lib/rspeckled/plugins/dox.rb +35 -43
  12. data/lib/rspeckled/plugins/elasticsearch.rb +17 -24
  13. data/lib/rspeckled/plugins/email.rb +4 -13
  14. data/lib/rspeckled/plugins/factory_bot.rb +13 -22
  15. data/lib/rspeckled/plugins/fakeredis.rb +1 -4
  16. data/lib/rspeckled/plugins/faraday.rb +49 -55
  17. data/lib/rspeckled/plugins/foreign_keys.rb +0 -4
  18. data/lib/rspeckled/plugins/garbage_collection.rb +31 -32
  19. data/lib/rspeckled/plugins/mongoid.rb +3 -10
  20. data/lib/rspeckled/plugins/omniauth.rb +30 -38
  21. data/lib/rspeckled/plugins/rails/strong_parameters.rb +8 -10
  22. data/lib/rspeckled/plugins/recaptcha.rb +2 -11
  23. data/lib/rspeckled/plugins/referehencible.rb +10 -19
  24. data/lib/rspeckled/plugins/request.rb +0 -4
  25. data/lib/rspeckled/plugins/shoulda.rb +20 -29
  26. data/lib/rspeckled/plugins/sidekiq.rb +21 -24
  27. data/lib/rspeckled/plugins/singleton.rb +0 -4
  28. data/lib/rspeckled/plugins/stripe.rb +17 -26
  29. data/lib/rspeckled/plugins/test_after_commit.rb +1 -6
  30. data/lib/rspeckled/plugins/timecop.rb +21 -28
  31. data/lib/rspeckled/plugins/vcr.rb +23 -37
  32. data/lib/rspeckled/plugins/webmock.rb +11 -18
  33. data/lib/rspeckled/plugins/wisper.rb +4 -12
  34. data/lib/rspeckled/plugins.rb +77 -31
  35. data/lib/rspeckled/spec_helpers/rspeckled.rb +0 -1
  36. data/lib/rspeckled/support.rb +13 -5
  37. data/lib/rspeckled/version.rb +1 -1
  38. data.tar.gz.sig +0 -0
  39. metadata +26 -24
  40. metadata.gz.sig +0 -0
  41. data/lib/rspeckled/plugins/code_climate.rb +0 -10
  42. data/lib/rspeckled/plugins/pretty_print.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deb27e150c71a733678d5073ca9f1aad8b61b712379509eb92512da04a7805a4
4
- data.tar.gz: dc5ba57bbabd8c0c5007f72651baecbe6db2fbfe1301bb16f959507d003bd81f
3
+ metadata.gz: 5a78f20ed3fca9b9c5e466fd191083a8c45b546b0d3289f4256bcf3cbe095d3b
4
+ data.tar.gz: c773560ea881311ceb87697dc9502dde2ac36d1c1c2215092b26a5ceddc61739
5
5
  SHA512:
6
- metadata.gz: 8014ea0cc30520f3a37e068f9d756b949f5ade0c90865318aa34e140c0623c551f7cad51b144d7aabfacc0ec68b600c4062d100ec4860193dddf69613f50d859
7
- data.tar.gz: 78ca8907fd5b187fd95167e55691d5cd87bfa3dc135c845bda32af4c1c58a7d5883516eed23543d137a455da8b091c07d3f108574963a100727d4cd5e3acdc7f
6
+ metadata.gz: 0effdfdc52e9f76b2824fa76ca41aae39c45dcc6c7bb0ab3c9db7d98ea52418a3f2613be9b33ae930ca2b7883fa062891168d0f82d4ed75dfd49a88d4c86a4c3
7
+ data.tar.gz: 751ba0cd3837e2ced58e55321fe5e1245349de4fde51624c6f058a69fb7a269d848639f404077c2d3b379a3df95825b3bf6ab9cf66bb38190af0607aea79136f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Security/JSONLoad
4
3
  def json_response
5
- JSON.load(response.body)
4
+ JSON.load(response.body) # rubocop:disable Security/JSONLoad
6
5
  end
7
- # rubocop:enable Security/JSONLoad
@@ -2,13 +2,13 @@
2
2
 
3
3
  # rubocop:disable Layout/IndentHash
4
4
  RSpec.configure do |config|
5
- config.around(:each, :mock_auth => lambda { |v| !!v }) do |example|
6
- options = if example.metadata[:mock_auth].is_a?(Hash)
7
- example.metadata[:mock_auth]
5
+ config.around(:each, :auth => lambda { |v| !!v }) do |example|
6
+ options = if example.metadata[:auth].is_a?(Hash)
7
+ example.metadata[:auth]
8
8
  else
9
9
  {
10
10
  :token => {
11
- :roles => example.metadata[:mock_auth],
11
+ :roles => example.metadata[:auth],
12
12
  },
13
13
  }
14
14
  end
@@ -93,7 +93,7 @@ RSpec.configure do |config|
93
93
  instance.delete unless options[:strategy] == :instance
94
94
  end
95
95
 
96
- config.before(:each, :mock_auth => lambda { |v| !!v }) do |_example|
96
+ config.before(:each, :auth => lambda { |v| !!v }) do |_example|
97
97
  request.env['X_JSON_WEB_TOKEN'] = @token_data
98
98
  end
99
99
  end
@@ -1,101 +1,93 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##############################################################################
4
- # Awesome Print Plugin
5
- ##############################################################################
6
-
7
3
  # rubocop:disable Metrics/AbcSize
8
4
  # rubocop:disable Metrics/PerceivedComplexity
9
5
  # rubocop:disable Metrics/CyclomaticComplexity
10
- begin
11
- require 'awesome_print'
12
- require 'io/console'
13
-
14
- module Kernel
15
- def sap(*messages)
16
- columns = if IO.console
17
- IO.console.winsize[1]
18
- else
19
- 80
20
- end
21
-
22
- puts
23
- print "\e[1;35m"
24
- print " #{Time.now} ".center(columns, '*')
25
- print "\e[0m\n"
26
- puts
27
- root_path = if defined?(Rails)
28
- Rails.root.to_s
29
- else
30
- `git rev-parse --show-toplevel`
31
- end
32
-
33
- caller[0...5].each do |line|
34
- relative_line = line.gsub!(root_path.strip, '.')
35
-
36
- color = if relative_line == line
37
- '34'
6
+ require 'io/console'
7
+
8
+ module Kernel
9
+ def sap(*messages)
10
+ columns = if IO.console
11
+ IO.console.winsize[1]
12
+ else
13
+ 80
14
+ end
15
+
16
+ puts
17
+ print "\e[1;35m"
18
+ print " #{Time.now} ".center(columns, '*')
19
+ print "\e[0m\n"
20
+ puts
21
+ root_path = if defined?(Rails)
22
+ Rails.root.to_s
38
23
  else
39
- '38;5;239'
24
+ `git rev-parse --show-toplevel`
40
25
  end
41
26
 
42
- print "\e[#{color}m"
43
- print line
44
- print "\e[0m\n"
45
- end
27
+ caller[0...5].each do |line|
28
+ relative_line = line.gsub!(root_path.strip, '.')
46
29
 
47
- puts
30
+ color = if relative_line == line
31
+ '34'
32
+ else
33
+ '38;5;239'
34
+ end
48
35
 
49
- Array(messages).each.with_index do |message, index|
50
- if message.respond_to?(:class)
51
- print "\e[32m"
36
+ print "\e[#{color}m"
37
+ print line
38
+ print "\e[0m\n"
39
+ end
52
40
 
53
- if defined?(::ActiveRecord::Base) && message.class.ancestors.include?(::ActiveRecord::Base)
54
- ap message.class
55
- else
56
- puts "Class: #{message.class}"
57
- print "Class Name: #{message.class.name}"
58
- end
41
+ puts
59
42
 
60
- print "\e[0m\n"
61
- puts
62
- end
43
+ Array(messages).each.with_index do |message, index|
44
+ if message.respond_to?(:class)
45
+ print "\e[32m"
63
46
 
64
- if defined?(::ActiveRecord::Base) && message.is_a?(::ActiveRecord::Base)
65
- ap(message.attributes, :raw => true)
47
+ if defined?(::ActiveRecord::Base) && message.class.ancestors.include?(::ActiveRecord::Base)
48
+ ap(message.class)
66
49
  else
67
- ap(message, :raw => true)
50
+ puts "Class: #{message.class}"
51
+ print "Class Name: #{message.class.name}"
68
52
  end
69
53
 
54
+ print "\e[0m\n"
70
55
  puts
56
+ end
71
57
 
72
- if %w{String ActionView::OutputBuffer ActiveSupport::SafeBuffer}.include?(message.class.name)
73
- print "\e[1;35m"
74
- print ' RAW STRING '.center(columns, '-')
75
- print "\e[0m\n"
76
- puts
77
- print "\e[1;30m"
78
- print message.to_str
79
- print "\e[0m\n"
80
- puts
81
- elsif message.respond_to?(:read)
82
- print "\e[1;35m"
83
- print ' RAW STRING '.center(columns, '-')
84
- print "\e[0m\n"
85
- puts
86
- print "\e[1;30m"
87
- print message.read
88
- print "\e[0m\n"
89
- puts
58
+ if defined?(::ActiveRecord::Base) && message.is_a?(::ActiveRecord::Base)
59
+ ap(message.attributes, :raw => true)
60
+ else
61
+ ap(message, :raw => true)
62
+ end
90
63
 
91
- message.rewind
92
- end
64
+ puts
93
65
 
94
- puts unless index + 1 == Array(messages).length
66
+ if %w{String ActionView::OutputBuffer ActiveSupport::SafeBuffer}.include?(message.class.name)
67
+ print "\e[1;35m"
68
+ print ' RAW STRING '.center(columns, '-')
69
+ print "\e[0m\n"
70
+ puts
71
+ print "\e[1;30m"
72
+ print message.to_str
73
+ print "\e[0m\n"
74
+ puts
75
+ elsif message.respond_to?(:read)
76
+ print "\e[1;35m"
77
+ print ' RAW STRING '.center(columns, '-')
78
+ print "\e[0m\n"
79
+ puts
80
+ print "\e[1;30m"
81
+ print message.read
82
+ print "\e[0m\n"
83
+ puts
84
+
85
+ message.rewind
95
86
  end
87
+
88
+ puts unless index + 1 == Array(messages).length
96
89
  end
97
90
  end
98
- rescue LoadError
99
91
  end
100
92
  # rubocop:enable Metrics/CyclomaticComplexity
101
93
  # rubocop:enable Metrics/PerceivedComplexity
@@ -1,27 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##############################################################################
4
- # Bullet Plugin
5
- ##############################################################################
3
+ Bullet.enable = true
4
+ Bullet.bullet_logger = true
5
+ Bullet.raise = true
6
6
 
7
- begin
8
- require 'bullet'
9
-
10
- Bullet.enable = true
11
- Bullet.bullet_logger = true
12
- Bullet.raise = true
13
-
14
- RSpec.configure do |config|
15
- config.before(:each) do
16
- Bullet.start_request if Bullet.enable?
17
- end
7
+ RSpec.configure do |config|
8
+ config.before(:each) do
9
+ Bullet.start_request if Bullet.enable?
10
+ end
18
11
 
19
- config.after(:each) do
20
- if Bullet.enable?
21
- Bullet.perform_out_of_channel_notifications if Bullet.notification?
22
- Bullet.end_request
23
- end
12
+ config.after(:each) do
13
+ if Bullet.enable?
14
+ Bullet.perform_out_of_channel_notifications if Bullet.notification?
15
+ Bullet.end_request
24
16
  end
25
17
  end
26
- rescue LoadError
27
18
  end
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##############################################################################
4
- # Capybara Plugin
5
- ##############################################################################
6
- #
7
3
  # This plugin does not attempt to require capybara. It assumes that if you're
8
4
  # using capybara, you're probably using something like Bundler which has already
9
5
  # required it for you.
@@ -12,134 +8,127 @@
12
8
  # rspeckled.
13
9
  #
14
10
  # The same goes for capybara-webkit. It must be required before rspeckled.
15
- #
16
- begin
17
- require 'capybara/rspec'
18
- require 'capybara/rails'
19
-
20
- if defined?(Capybara::Driver::Base)
21
- downloads_directory = "#{Dir.pwd}/tmp/downloads/"
22
- Dir.mkdir(downloads_directory) unless Dir.exist?(downloads_directory)
23
-
24
- chrome_options = {
25
- 'chromeOptions' => {
26
- 'prefs' => {
27
- 'profile.default_content_settings.popups' => 0,
28
- 'download.default_directory' => downloads_directory,
29
- },
30
- 'args' => %w{
31
- window-size=1920,1200
32
- },
33
- },
34
- }
35
-
36
- Capybara.register_driver :chrome do |app|
37
- Capybara::Selenium::Driver.new(
38
- app,
39
- :browser => :chrome,
40
- :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chrome_options)
41
- )
42
- end
43
11
 
44
- headless_chrome_options = chrome_options.dup
45
- headless_chrome_options['chromeOptions']['binary'] = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
46
- headless_chrome_options['chromeOptions']['args'] << 'headless'
47
- headless_chrome_options['chromeOptions']['args'] << 'disable-gpu'
48
-
49
- Capybara.register_driver :headless_chrome do |app|
50
- Capybara::Selenium::Driver.new(
51
- app,
52
- :browser => :chrome,
53
- :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(headless_chrome_options)
54
- )
55
- end
12
+ require 'capybara/rspec'
13
+ require 'capybara/rails'
14
+
15
+ downloads_directory = "#{Dir.pwd}/tmp/downloads/"
16
+ Dir.mkdir(downloads_directory) unless Dir.exist?(downloads_directory)
17
+
18
+ chrome_options = {
19
+ 'chromeOptions' => {
20
+ 'prefs' => {
21
+ 'profile.default_content_settings.popups' => 0,
22
+ 'download.default_directory' => downloads_directory,
23
+ },
24
+ 'args' => %w{
25
+ window-size=1920,1200
26
+ },
27
+ },
28
+ }
29
+
30
+ Capybara.register_driver :chrome do |app|
31
+ Capybara::Selenium::Driver.new(
32
+ app,
33
+ :browser => :chrome,
34
+ :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chrome_options)
35
+ )
36
+ end
56
37
 
57
- firefox_profile = Selenium::WebDriver::Firefox::Profile.new
58
- firefox_profile['browser.download.dir'] = downloads_directory
59
- firefox_profile['browser.download.folderList'] = 2
60
- firefox_profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream'
61
- firefox_profile['pdfjs.disabled'] = true
38
+ headless_chrome_options = chrome_options.dup
39
+ headless_chrome_options['chromeOptions']['binary'] = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
40
+ headless_chrome_options['chromeOptions']['args'] << 'headless'
41
+ headless_chrome_options['chromeOptions']['args'] << 'disable-gpu'
42
+
43
+ Capybara.register_driver :headless_chrome do |app|
44
+ Capybara::Selenium::Driver.new(
45
+ app,
46
+ :browser => :chrome,
47
+ :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(headless_chrome_options)
48
+ )
49
+ end
62
50
 
63
- Capybara.register_driver :firefox do |app|
64
- Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => firefox_profile)
65
- end
51
+ firefox_profile = Selenium::WebDriver::Firefox::Profile.new
52
+ firefox_profile['browser.download.dir'] = downloads_directory
53
+ firefox_profile['browser.download.folderList'] = 2
54
+ firefox_profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream'
55
+ firefox_profile['pdfjs.disabled'] = true
66
56
 
67
- if defined?(Selenium::WebDriver)
68
- Selenium::WebDriver.logger.output = 'log/selenium.log'
69
- end
57
+ Capybara.register_driver :firefox do |app|
58
+ Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => firefox_profile)
59
+ end
70
60
 
71
- if defined?(Capybara::Webkit)
72
- Capybara.javascript_driver = :webkit
61
+ Selenium::WebDriver.logger.output = 'log/selenium.log' if defined?(Selenium::WebDriver)
73
62
 
74
- Capybara::Webkit.configure do |config|
75
- config.block_unknown_urls
76
- config.skip_image_loading
63
+ if defined?(Capybara::Webkit)
64
+ Capybara.javascript_driver = :webkit
77
65
 
78
- config.allow_url('*.lvh.me')
79
- config.allow_url('*.cloudfront.net')
80
- config.allow_url('*.s3.amazonaws.com')
66
+ Capybara::Webkit.configure do |config|
67
+ config.block_unknown_urls
68
+ config.skip_image_loading
81
69
 
82
- if defined?(Chamber)
83
- config.allow_url("*.#{Chamber.env.http.host}")
84
- config.allow_url("*.#{Chamber.env.http.web_client_domain}")
85
- end
86
- end
87
- else
88
- Capybara.javascript_driver = :selenium
89
- end
70
+ config.allow_url('*.lvh.me')
71
+ config.allow_url('*.cloudfront.net')
72
+ config.allow_url('*.s3.amazonaws.com')
90
73
 
91
- RSpec.configure do |config|
92
- config.before(:each, :js => true) do
93
- page.driver.reset!
94
- end
95
-
96
- config.before(:each, :js => true, :autofocus => true) do
97
- Thread.new do
98
- sleep 1.5
99
-
100
- `
101
- osascript -e '
102
- tell the application named "Firefox"
103
- activate
104
-
105
- set theWindow to the first item of windows
106
-
107
- if index of theWindow is not 1 then
108
- set index to 1
109
- set visible to false
110
- set visible to true
111
- end if
112
- end tell
113
- ' > /dev/null
114
- `
115
- end
116
- end
117
-
118
- config.after(:each, :js => true, :autofocus => true) do
119
- sleep 10
120
- end
121
-
122
- config.before(:each, :js => true, :feature => true, :debug => true) do
123
- Selenium::WebDriver.logger.level = :debug if defined?(Selenium::WebDriver)
124
- end
125
-
126
- config.after(:each, :js => true, :feature => true, :debug => true) do
127
- Selenium::WebDriver.logger.level = :warn if defined?(Selenium::WebDriver)
128
- end
74
+ if defined?(Chamber)
75
+ config.allow_url("*.#{Chamber.env.http.host}")
76
+ config.allow_url("*.#{Chamber.env.http.web_client_domain}")
129
77
  end
78
+ end
79
+ else
80
+ Capybara.javascript_driver = :selenium
81
+ end
130
82
 
131
- Capybara.configure do |config|
132
- config.exact = true
133
- config.match = :one
134
- config.ignore_hidden_elements = true
135
- config.visible_text_only = true
136
- end
83
+ Capybara.configure do |config|
84
+ config.exact = true
85
+ config.match = :one
86
+ config.ignore_hidden_elements = true
87
+ config.visible_text_only = true
88
+ end
137
89
 
138
- if defined?(Chamber)
139
- Capybara.default_host = Chamber.env.http.host_with_port
140
- Capybara.app_host = Chamber.env.http.base_url
141
- Capybara.server_port = Chamber.env.http.port
90
+ if defined?(Chamber)
91
+ Capybara.default_host = Chamber.env.http.host_with_port
92
+ Capybara.app_host = Chamber.env.http.base_url
93
+ Capybara.server_port = Chamber.env.http.port
94
+ end
95
+
96
+ RSpec.configure do |config|
97
+ config.before(:each, :js => true) do
98
+ page.driver.reset!
99
+ end
100
+
101
+ config.before(:each, :js => true, :autofocus => true) do
102
+ Thread.new do
103
+ sleep 1.5
104
+
105
+ `
106
+ osascript -e '
107
+ tell the application named "Firefox"
108
+ activate
109
+
110
+ set theWindow to the first item of windows
111
+
112
+ if index of theWindow is not 1 then
113
+ set index to 1
114
+ set visible to false
115
+ set visible to true
116
+ end if
117
+ end tell
118
+ ' > /dev/null
119
+ `
142
120
  end
143
121
  end
144
- rescue LoadError
122
+
123
+ config.after(:each, :js => true, :autofocus => true) do
124
+ sleep 10
125
+ end
126
+
127
+ config.before(:each, :js => true, :feature => true, :debug => true) do
128
+ Selenium::WebDriver.logger.level = :debug if defined?(Selenium::WebDriver)
129
+ end
130
+
131
+ config.after(:each, :js => true, :feature => true, :debug => true) do
132
+ Selenium::WebDriver.logger.level = :warn if defined?(Selenium::WebDriver)
133
+ end
145
134
  end
@@ -1,36 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##############################################################################
4
- # CarrierWave Plugin
5
- ##############################################################################
3
+ require 'carrierwave/test/matchers'
6
4
 
7
- begin
8
- require 'carrierwave'
9
- require 'carrierwave/test/matchers'
10
-
11
- RSpec.configure do |config|
12
- config.include CarrierWave::Test::Matchers, :file_attachment => true
13
- end
5
+ RSpec.configure do |config|
6
+ config.include CarrierWave::Test::Matchers, :file_attachment => true
7
+ end
14
8
 
15
- CarrierWave.configure do |config|
16
- config.storage = :file
17
- config.root = File.expand_path('./tmp')
18
- config.enable_processing = false
19
- end
9
+ CarrierWave.configure do |config|
10
+ config.storage = :file
11
+ config.root = File.expand_path('./tmp')
12
+ config.enable_processing = false
13
+ end
20
14
 
21
- RSpec.configure do |config|
22
- config.around(:each, :file_attachment => true) do |example|
23
- previous_carrierwave_processing_mode = subject.class.enable_processing
24
- previous_carrierwave_storage_mode = subject.class.storage
15
+ RSpec.configure do |config|
16
+ config.around(:each, :file_attachment => true) do |example|
17
+ previous_carrierwave_processing_mode = subject.class.enable_processing
18
+ previous_carrierwave_storage_mode = subject.class.storage
25
19
 
26
- subject.class.enable_processing = true
27
- subject.class.storage = :file
20
+ subject.class.enable_processing = true
21
+ subject.class.storage = :file
28
22
 
29
- example.run
23
+ example.run
30
24
 
31
- subject.class.storage = previous_carrierwave_storage_mode
32
- subject.class.enable_processing = previous_carrierwave_processing_mode
33
- end
25
+ subject.class.storage = previous_carrierwave_storage_mode
26
+ subject.class.enable_processing = previous_carrierwave_processing_mode
34
27
  end
35
- rescue LoadError
36
28
  end
@@ -1,49 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##############################################################################
4
- # Database Cleaner Plugin
5
- ##############################################################################
6
-
7
3
  begin
8
- require 'database_cleaner'
4
+ autodetected = DatabaseCleaner::Base.new.__send__(:autodetect)
5
+ rescue DatabaseCleaner::NoORMDetected
6
+ autodetected = false
7
+ end
9
8
 
10
- begin
11
- autodetected = DatabaseCleaner::Base.new.__send__(:autodetect)
12
- rescue DatabaseCleaner::NoORMDetected
13
- autodetected = false
9
+ return unless autodetected
10
+
11
+ RSpec.configure do |config|
12
+ config.before(:suite) do
13
+ DatabaseCleaner.clean_with(:truncation, :except => %w{ar_internal_metadata})
14
14
  end
15
15
 
16
- if autodetected
17
- RSpec.configure do |config|
18
- config.before(:suite) do
19
- DatabaseCleaner.clean_with(:truncation, :except => %w{ar_internal_metadata})
20
- end
16
+ config.around(:each) do |example|
17
+ DatabaseCleaner.strategy = if example.metadata[:js] || %i{mongoid}.include?(autodetected)
18
+ [:truncation, :except => %w{ar_internal_metadata}]
19
+ else
20
+ :transaction
21
+ end
21
22
 
22
- config.around(:each) do |example|
23
- DatabaseCleaner.strategy = if example.metadata[:js] || %i{mongoid}.include?(autodetected)
24
- [:truncation, :except => %w{ar_internal_metadata}]
25
- else
26
- :transaction
27
- end
23
+ DatabaseCleaner.start
28
24
 
29
- DatabaseCleaner.start
25
+ example.run
30
26
 
31
- example.run
27
+ DatabaseCleaner.clean
28
+ end
29
+ end
32
30
 
33
- DatabaseCleaner.clean
34
- end
35
- end
31
+ return unless defined?(RSpec::Rails)
36
32
 
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
33
+ RSpec.configure do |config|
34
+ config.use_transactional_fixtures = false
49
35
  end