rspectacular 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rspectacular/plugins/email.rb +0 -1
- data/lib/rspectacular/plugins/factory_girl.rb +2 -0
- data/lib/rspectacular/plugins/paypal.rb +2 -2
- data/lib/rspectacular/plugins/timecop.rb +8 -2
- data/lib/rspectacular/support.rb +1 -0
- data/lib/rspectacular/support/garbage_collection.rb +59 -0
- data/lib/rspectacular/support/rails.rb +5 -0
- data/lib/rspectacular/support/random.rb +0 -1
- data/lib/rspectacular/version.rb +1 -1
- metadata +4 -2
@@ -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 =
|
8
|
-
|
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
|
|
data/lib/rspectacular/support.rb
CHANGED
@@ -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
|
data/lib/rspectacular/version.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: rspectacular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
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-
|
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
|