top_tests 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in top_tests.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ top_tests (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ top_tests!
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2011, Official.fm
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ Neither the name of the Official.fm nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
+
data/README.rdoc ADDED
@@ -0,0 +1,12 @@
1
+ == What is it?
2
+ Top tests displays your 10 slowest tests after execution. The goal is to help you
3
+ keeping your tests fast.
4
+
5
+ == How to setup top tests?
6
+ First of all top tests works only with ActiveSupport::TestCase. Then require top
7
+ tests and just include into your test class:
8
+
9
+ class ActiveSupport::TestCase
10
+ include TopTests
11
+ end
12
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module TopTests
4
+
5
+ VERSION = '0.0.1'.freeze
6
+
7
+ end
8
+
data/lib/top_tests.rb ADDED
@@ -0,0 +1,50 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module TopTests
4
+
5
+ #####################
6
+ ### Class methods ###
7
+ #####################
8
+
9
+ def self.included(klass)
10
+ klass.setup :start_timer
11
+ klass.teardown :stop_timer
12
+ klass.extend(ClassMethods)
13
+ at_exit { at_exit { klass.print_top_tests } }
14
+ end
15
+
16
+ ########################
17
+ ### Instance methods ###
18
+ ########################
19
+
20
+ def start_timer
21
+ @timer_started_at = Time.now
22
+ end
23
+
24
+ def stop_timer
25
+ name = self.class.to_s + '#' + @__name__
26
+ self.class.tests_durations << [name, Time.now - @timer_started_at]
27
+ end
28
+
29
+ #####################
30
+ ### Class methods ###
31
+ #####################
32
+
33
+ module ClassMethods
34
+ def tests_durations
35
+ @@tests_durations ||= []
36
+ end
37
+
38
+ def top_tests
39
+ tests_durations.sort { |a, b| b.last <=> a.last }
40
+ end
41
+
42
+ def print_top_tests
43
+ puts "\nTop tests:"
44
+ puts top_tests.shift(10).map { |t| "#{format("%7.3f", t.last)} #{t.first}" }.join("\n")
45
+ puts
46
+ end
47
+ end
48
+
49
+ end
50
+
data/top_tests.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "top_tests/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'top_tests'
7
+ s.version = TopTests::VERSION.dup
8
+ s.authors = ['Alexis Bernard']
9
+ s.email = ['alexis@official.fm']
10
+ s.homepage = 'https://github.com/officialfm/top_tests'
11
+ s.summary = 'Top tests displays your 10 slowest tests after execution'
12
+ s.description = 'Top tests displays your 10 slowest tests after execution'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ end
20
+
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: top_tests
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexis Bernard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-12 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Top tests displays your 10 slowest tests after execution
15
+ email:
16
+ - alexis@official.fm
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE
25
+ - README.rdoc
26
+ - Rakefile
27
+ - lib/top_tests.rb
28
+ - lib/top_tests/version.rb
29
+ - top_tests.gemspec
30
+ homepage: https://github.com/officialfm/top_tests
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 1.8.10
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Top tests displays your 10 slowest tests after execution
54
+ test_files: []