hermes 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -0
- data/lib/hermes/perf.rb +2 -0
- data/lib/hermes/perf/scrub.rb +14 -0
- data/lib/hermes/perf/shared_connection.rb +14 -0
- data/lib/hermes/version.rb +1 -1
- metadata +7 -4
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -6,6 +6,10 @@ A few testing facilities built on top of Capybara and ActiveSupport::TestCase
|
|
6
6
|
|
7
7
|
* Improve this README mentioning each module and how to configure it to work with Rspec and/or Rails.
|
8
8
|
|
9
|
+
== Perf
|
10
|
+
|
11
|
+
Require perf optimization for your test suite with "hermes/perf"
|
12
|
+
|
9
13
|
== Bugs and Features
|
10
14
|
|
11
15
|
If you discover any bugs or add any features, please let us know using GitHub's tracker.
|
data/lib/hermes/perf.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Scrub instance variables as in
|
2
|
+
# http://37signals.com/svn/posts/2742-the-road-to-faster-tests
|
3
|
+
|
4
|
+
ActiveSupport::TestCase.class_eval do
|
5
|
+
teardown :scrub_instance_variables
|
6
|
+
|
7
|
+
@@reserved_ivars = %w(@loaded_fixtures @test_passed @fixture_cache @method_name @_assertion_wrapped @_result)
|
8
|
+
|
9
|
+
def scrub_instance_variables
|
10
|
+
(instance_variables - @@reserved_ivars).each do |ivar|
|
11
|
+
instance_variable_set(ivar, nil)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This is a hack that forces AR to share its connection between different
|
2
|
+
# threads. Useful for Capybara when you are not using rack-test.
|
3
|
+
class ActiveRecord::Base
|
4
|
+
mattr_accessor :shared_connection
|
5
|
+
@@shared_connection = nil
|
6
|
+
|
7
|
+
def self.connection
|
8
|
+
@@shared_connection || retrieve_connection
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Forces all threads to share the same connection. This works on
|
13
|
+
# Capybara because it starts the web server in a thread.
|
14
|
+
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
data/lib/hermes/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hermes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jos\xC3\xA9 Valim"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-04-28 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -35,6 +35,9 @@ files:
|
|
35
35
|
- lib/hermes/builders.rb
|
36
36
|
- lib/hermes/context.rb
|
37
37
|
- lib/hermes/integration_case.rb
|
38
|
+
- lib/hermes/perf/scrub.rb
|
39
|
+
- lib/hermes/perf/shared_connection.rb
|
40
|
+
- lib/hermes/perf.rb
|
38
41
|
- lib/hermes/rails.rb
|
39
42
|
- lib/hermes/scopes.rb
|
40
43
|
- lib/hermes/version.rb
|