rspectacular 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,6 @@ end
8
8
  if defined? ActionMailer
9
9
  RSpec.configure do |config|
10
10
  config.after(:each, :email => true) do
11
- # Clear all ActionMailer test emails after email specs
12
11
  ActionMailer::Base.deliveries.clear
13
12
  end
14
13
  end
@@ -1,6 +1,8 @@
1
1
  begin
2
2
  require 'factory_girl'
3
3
 
4
+ FactoryGirl.definition_file_paths << './spec/factories'
5
+
4
6
  if FactoryGirl.configuration.factories.count.zero?
5
7
  FactoryGirl.find_definitions
6
8
  end
@@ -3,11 +3,11 @@
3
3
  # to test users.
4
4
  #
5
5
  RSpec.configure do |config|
6
- config.before(:each, :paypal => true) do
6
+ config.before(:each, :js => true, :paypal => true) do
7
7
  log_in_to_paypal_sandbox
8
8
  end
9
9
 
10
- config.after(:each, :paypal => true) do
10
+ config.after(:each, :js => true, :paypal => true) do
11
11
  log_out_of_paypal
12
12
  log_out_of_paypal_sandbox
13
13
  end
@@ -4,9 +4,15 @@ begin
4
4
  RSpec.configure do |config|
5
5
  config.around(:each, :time_mock => lambda { |v| !!v }) do |example|
6
6
  options = example.metadata[:time_mock]
7
- options = options.is_a?(Hash) ? options : {}
8
- time = options.is_a?(Time) ? options : (options[:time] || Time.utc(2012, 7, 26, 18, 0, 0))
7
+ options = case options
8
+ when Time
9
+ { :time => options }
10
+ when TrueClass
11
+ {}
12
+ end
13
+
9
14
  mock_type = options.fetch(:type, :freeze)
15
+ time = options.fetch(:time, Time.utc(2012, 7, 26, 18, 0, 0))
10
16
 
11
17
  Timecop.send(mock_type, time)
12
18
 
@@ -1,4 +1,5 @@
1
1
  require 'rspectacular/support/general'
2
+ require 'rspectacular/support/garbage_collection'
2
3
  require 'rspectacular/support/random'
3
4
  require 'rspectacular/support/focused'
4
5
  require 'rspectacular/support/pending'
@@ -0,0 +1,59 @@
1
+ ###
2
+ #
3
+ # Shamelessly stolen from http://ariejan.net/2011/09/24/rspec-speed-up-by-tweaking-ruby-garbage-collection/
4
+ #
5
+ module RSpectacular
6
+ class DeferredGarbageCollection
7
+ THRESHOLD = (ENV['DEFER_GC'] || 20.0).to_f
8
+
9
+ def self.start
10
+ cycle_garbage_collector if enabled?
11
+ end
12
+
13
+ def self.reconsider
14
+ if enabled? && over_deferrment_threshold?
15
+ cycle_garbage_collector
16
+
17
+ garbage_last_collected_at = Time.now
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def self.cycle_garbage_collector
24
+ GC.enable
25
+ GC.start
26
+ GC.disable
27
+ end
28
+
29
+ def self.over_deferrment_threshold?
30
+ time_since_garbage_last_collected >= THRESHOLD
31
+ end
32
+
33
+ def self.enabled?
34
+ THRESHOLD > 0
35
+ end
36
+
37
+ def self.time_since_garbage_last_collected
38
+ Time.now - garbage_last_collected_at
39
+ end
40
+
41
+ def self.garbage_last_collected_at
42
+ @garbage_last_collected_at || Time.now
43
+ end
44
+
45
+ def self.garbage_last_collected_at=(value)
46
+ @garbage_last_collected_at = value
47
+ end
48
+ end
49
+ end
50
+
51
+ RSpec.configure do |config|
52
+ config.before(:all) do
53
+ RSpectacular::DeferredGarbageCollection.start
54
+ end
55
+
56
+ config.after(:all) do
57
+ RSpectacular::DeferredGarbageCollection.reconsider
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ if defined? RSpec::Rails
2
+ RSpec.configure do |config|
3
+ config.infer_base_class_for_anonymous_controllers = true
4
+ end
5
+ end
@@ -1,4 +1,3 @@
1
-
2
1
  RSpec.configure do |config|
3
2
  config.order = 'random'
4
3
  end
@@ -1,3 +1,3 @@
1
1
  module RSpectacular
2
- VERSION = '0.11.1'
2
+ VERSION = '0.12.0'
3
3
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: rspectacular
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.11.1
5
+ version: 0.12.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - jfelchner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-16 00:00:00.000000000 Z
12
+ date: 2013-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false
@@ -87,8 +87,10 @@ files:
87
87
  - lib/rspectacular/spec_helpers/active_record_spec_helper.rb
88
88
  - lib/rspectacular/support/focused.rb
89
89
  - lib/rspectacular/support/formatters.rb
90
+ - lib/rspectacular/support/garbage_collection.rb
90
91
  - lib/rspectacular/support/general.rb
91
92
  - lib/rspectacular/support/pending.rb
93
+ - lib/rspectacular/support/rails.rb
92
94
  - lib/rspectacular/support/random.rb
93
95
  - lib/rspectacular/support/selenium.rb
94
96
  - lib/rspectacular/support.rb