rspec-prof 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +25 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +67 -0
- data/README.rdoc +42 -75
- data/Rakefile +13 -72
- data/features/profile_with_env_vars.feature +64 -0
- data/features/step_definitions/environment_variable_steps.rb +3 -0
- data/features/step_definitions/pass_fail_steps.rb +3 -0
- data/features/support/env.rb +5 -0
- data/features/support/reset_env.rb +3 -0
- data/features/support/spec_helper.rb +18 -0
- data/lib/rspec-prof.rb +62 -105
- data/lib/rspec-prof/filename_helpers.rb +38 -0
- data/rspec-prof.gemspec +18 -58
- metadata +134 -128
- data/lib/rspec-prof/profiler.rb +0 -89
- data/lib/rspec.rb +0 -19
- data/spec/rspec-prof_spec.rb +0 -45
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae9933597915662f4f7bca6325721f52cda3cafc
|
4
|
+
data.tar.gz: 45924ff5c34120c71d82aa1be0dbbc08f671714a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88baa3fe89c1ec1aca70dacd78c07db54cef258f8f4e03c1b06df5c8711ad01a288b541d108ed995c83fe77c8c37f73b8dded637ba5dd6c548483cf5dd20227a
|
7
|
+
data.tar.gz: 6a4fc8170ab7ab738e7f1d27efb10a24afa46e140cc54cecfe4d747224f1212f6a9be4fed39fd7657d846b3ac2ef35617414aa67139b9e27e1a9e84e221e60a4
|
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
.idea
|
21
|
+
|
22
|
+
## PROJECT::SPECIFIC
|
23
|
+
profiles
|
24
|
+
coverage
|
25
|
+
tmp
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-prof (0.0.4)
|
5
|
+
rspec
|
6
|
+
ruby-prof
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
aruba (0.5.3)
|
12
|
+
childprocess (>= 0.3.6)
|
13
|
+
cucumber (>= 1.1.1)
|
14
|
+
rspec-expectations (>= 2.7.0)
|
15
|
+
builder (3.2.2)
|
16
|
+
childprocess (0.3.9)
|
17
|
+
ffi (~> 1.0, >= 1.0.11)
|
18
|
+
coveralls (0.7.0)
|
19
|
+
multi_json (~> 1.3)
|
20
|
+
rest-client
|
21
|
+
simplecov (>= 0.7)
|
22
|
+
term-ansicolor
|
23
|
+
thor
|
24
|
+
cucumber (1.3.8)
|
25
|
+
builder (>= 2.1.2)
|
26
|
+
diff-lcs (>= 1.1.3)
|
27
|
+
gherkin (~> 2.12.1)
|
28
|
+
multi_json (>= 1.7.5, < 2.0)
|
29
|
+
multi_test (>= 0.0.2)
|
30
|
+
diff-lcs (1.2.4)
|
31
|
+
ffi (1.9.3)
|
32
|
+
gherkin (2.12.2)
|
33
|
+
multi_json (~> 1.3)
|
34
|
+
mime-types (2.0)
|
35
|
+
multi_json (1.8.2)
|
36
|
+
multi_test (0.0.2)
|
37
|
+
rake (10.1.0)
|
38
|
+
rest-client (1.6.7)
|
39
|
+
mime-types (>= 1.16)
|
40
|
+
rspec (2.14.1)
|
41
|
+
rspec-core (~> 2.14.0)
|
42
|
+
rspec-expectations (~> 2.14.0)
|
43
|
+
rspec-mocks (~> 2.14.0)
|
44
|
+
rspec-core (2.14.7)
|
45
|
+
rspec-expectations (2.14.3)
|
46
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
47
|
+
rspec-mocks (2.14.4)
|
48
|
+
ruby-prof (0.13.0)
|
49
|
+
simplecov (0.7.1)
|
50
|
+
multi_json (~> 1.0)
|
51
|
+
simplecov-html (~> 0.7.1)
|
52
|
+
simplecov-html (0.7.1)
|
53
|
+
term-ansicolor (1.2.2)
|
54
|
+
tins (~> 0.8)
|
55
|
+
thor (0.18.1)
|
56
|
+
tins (0.12.0)
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
aruba
|
63
|
+
coveralls
|
64
|
+
cucumber
|
65
|
+
rake
|
66
|
+
rspec-prof!
|
67
|
+
simplecov
|
data/README.rdoc
CHANGED
@@ -1,96 +1,65 @@
|
|
1
|
-
= rspec-prof
|
1
|
+
= rspec-prof {<img src="https://travis-ci.org/sinisterchipmunk/rspec-prof.png?branch=master" alt="Build Status" />}[https://travis-ci.org/sinisterchipmunk/rspec-prof] {<img src="https://coveralls.io/repos/sinisterchipmunk/rspec-prof/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/sinisterchipmunk/rspec-prof?branch=master]
|
2
2
|
|
3
|
-
Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec
|
3
|
+
Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec
|
4
|
+
examples.
|
4
5
|
|
5
6
|
== Installation
|
6
7
|
|
7
|
-
|
8
|
+
If you need to use rspec-prof in Rails 2.x or RSpec 1.x, use version `0.0.3`.
|
8
9
|
|
9
|
-
|
10
|
+
Gemfile:
|
10
11
|
|
11
|
-
You'd probably ought to enable the gem in your spec_helper.rb file:
|
12
|
-
gem 'rspec-prof'
|
13
|
-
require 'rspec-prof'
|
14
|
-
|
15
|
-
Or, in Rails 2 (config/environment.rb):
|
16
|
-
config.gem 'rspec-prof'
|
17
|
-
|
18
|
-
Or, in Rails 3 (Gemfile):
|
19
12
|
group :test do
|
20
13
|
gem 'rspec-prof'
|
21
14
|
end
|
22
15
|
|
23
16
|
== Usage
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
describe MyAwesomeObject do
|
28
|
-
context "with an awesome string" do
|
29
|
-
subject { MyAwesomeObject.new("an awesome string") }
|
30
|
-
|
31
|
-
profile do # profile these examples!
|
32
|
-
it "should be awesome" do
|
33
|
-
subject.should be_awesome
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should be epic" do
|
37
|
-
subject.should be_epic
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# not profiled:
|
42
|
-
it "should not be fail" do
|
43
|
-
subject.should_not be_fail
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
The usage overviewed above will, by default, profile each spec independently. If you need to profile all of them in a
|
49
|
-
single go, that's easy too:
|
50
|
-
|
51
|
-
describe MyAwesomeObject do
|
52
|
-
# . . .
|
53
|
-
|
54
|
-
profile :all do # run all of these examples in a single profile
|
55
|
-
# . . .
|
56
|
-
end
|
57
|
-
end
|
18
|
+
The easiest way to use rspec-prof is to export the `RSPEC_PROFILE` environment
|
19
|
+
variable:
|
58
20
|
|
59
|
-
|
60
|
-
options that you can pass in the form of a hash, such as min_percent:
|
21
|
+
$ rake spec RSPEC_PROFILE=each
|
61
22
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
For an exhaustive list of options, see the RSpecProf::Profiler class.
|
23
|
+
This will cause every spec to be profiled individually. The output will be
|
24
|
+
placed in `./profiles` by default.
|
25
|
+
|
26
|
+
To execute all specs as parts of a single profile, export `RSPEC_PROFILE=all`
|
27
|
+
instead.
|
28
|
+
|
29
|
+
== Configuration
|
71
30
|
|
72
|
-
|
31
|
+
You can set some configuration options for `rspec-prof`, as long as you do so
|
32
|
+
before `RSpec` begins running specs. Thus, the best place for this
|
33
|
+
configuration is in `spec/support/rspec-prof.rb`.
|
73
34
|
|
74
|
-
|
75
|
-
down your app and, therefore, limit your productivity. To disable profiling without having to change your specs, simply
|
76
|
-
add this to your spec helper:
|
35
|
+
Valid configuration options and their default values are:
|
77
36
|
|
78
|
-
RSpecProf.
|
79
|
-
|
80
|
-
...and you're done. In case you need it (but I doubt you will because it's on by default), you can also enable the
|
81
|
-
profiler similarly:
|
37
|
+
RSpecProf.printer_class = RubyProf::GraphHtmlPrinter
|
38
|
+
# The printer to be used when writing profiles
|
82
39
|
|
83
|
-
RSpecProf.
|
40
|
+
RSpecProf::FilenameHelpers.file_extension = "html"
|
41
|
+
# The file extension for profiles written to disk
|
84
42
|
|
85
|
-
|
43
|
+
RSpecProf::FilenameHelpers.output_dir = "profiles"
|
44
|
+
# The destination directory into which profiles are written
|
86
45
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
46
|
+
== Pausing and Resuming
|
47
|
+
|
48
|
+
It is perfectly OK to do this:
|
49
|
+
|
50
|
+
require 'spec_helper'
|
51
|
+
|
52
|
+
describe "smth" do
|
53
|
+
before do
|
54
|
+
# let's not profile the test set-up
|
55
|
+
RubyProf.pause if RubyProf.running?
|
56
|
+
|
57
|
+
sleep 30 # doing something expensive...
|
58
|
+
|
59
|
+
# don't forget to resume so specs can be measured!
|
60
|
+
RubyProf.resume if RubyProf.running?
|
61
|
+
end
|
62
|
+
end
|
94
63
|
|
95
64
|
== Note on Patches/Pull Requests
|
96
65
|
|
@@ -98,8 +67,6 @@ profiler similarly:
|
|
98
67
|
* Make your feature addition or bug fix.
|
99
68
|
* Add tests for it. This is important so I don't break it in a
|
100
69
|
future version unintentionally.
|
101
|
-
* Commit, do not mess with rakefile, version, or history.
|
102
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
103
70
|
* Send me a pull request. Bonus points for topic branches.
|
104
71
|
|
105
72
|
== Copyright
|
data/Rakefile
CHANGED
@@ -1,77 +1,18 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
1
|
begin
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
8
|
-
gem.summary = %Q{Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec examples.}
|
9
|
-
gem.description = %Q{Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec examples.}
|
10
|
-
gem.email = "sinisterchipmunk@gmail.com"
|
11
|
-
gem.homepage = "http://www.thoughtsincomputation.com/"
|
12
|
-
gem.authors = ["Colin MacKenzie IV"]
|
13
|
-
gem.add_dependency "sc-core-ext", ">= 1.2.1"
|
14
|
-
gem.add_dependency "rspec"
|
15
|
-
gem.add_dependency "ruby-prof"
|
16
|
-
gem.add_development_dependency "jeweler", ">= 1.4.0"
|
17
|
-
gem.add_development_dependency "rspec", ">= 1.3.0"
|
18
|
-
gem.add_development_dependency "builder", ">= 2.1.2"
|
19
|
-
gem.files = FileList['**/*'] - FileList['profiles/**/*'] - FileList['pkg/**/*']
|
20
|
-
gem.test_files = FileList['spec/**/*']
|
21
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
22
|
-
end
|
23
|
-
Jeweler::GemcutterTasks.new
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
Bundler.setup
|
24
5
|
rescue LoadError
|
25
|
-
puts "
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# RSpec 1.3.0
|
31
|
-
require 'spec/rake/spectask'
|
32
|
-
require 'spec/version'
|
33
|
-
|
34
|
-
RSPEC_VERSION = Spec::VERSION::STRING
|
35
|
-
rescue LoadError
|
36
|
-
# RSpec 2.0
|
37
|
-
begin
|
38
|
-
require 'rspec/core/rake_task'
|
39
|
-
require 'rspec/core/version'
|
40
|
-
|
41
|
-
RSPEC_VERSION = RSpec::Core::Version::STRING
|
42
|
-
rescue LoadError
|
43
|
-
raise "RSpec does not seem to be installed. You must gem install rspec to use this gem."
|
44
|
-
end
|
45
|
-
end
|
6
|
+
puts " *** You don't seem to have Bundler installed. ***"
|
7
|
+
puts " Please run the following command:"
|
8
|
+
puts
|
9
|
+
puts " gem install bundler"
|
10
|
+
raise "bundler is not installed"
|
46
11
|
end
|
47
12
|
|
48
|
-
|
49
|
-
|
50
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
51
|
-
end
|
52
|
-
else # Rake task for 1.3.x
|
53
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
54
|
-
spec.libs << 'lib' << 'spec'
|
55
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
56
|
-
end
|
57
|
-
|
58
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
59
|
-
spec.libs << 'lib' << 'spec'
|
60
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
61
|
-
spec.rcov = true
|
62
|
-
end
|
63
|
-
end
|
13
|
+
require 'coveralls/rake/task'
|
14
|
+
Coveralls::RakeTask.new
|
64
15
|
|
65
|
-
task
|
66
|
-
|
67
|
-
task :default => :
|
68
|
-
|
69
|
-
require 'rake/rdoctask'
|
70
|
-
Rake::RDocTask.new do |rdoc|
|
71
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
72
|
-
|
73
|
-
rdoc.rdoc_dir = 'rdoc'
|
74
|
-
rdoc.title = "rspec-prof #{version}"
|
75
|
-
rdoc.rdoc_files.include('README*')
|
76
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
77
|
-
end
|
16
|
+
require 'cucumber/rake/task'
|
17
|
+
Cucumber::Rake::Task.new :cucumber
|
18
|
+
task :default => [:cucumber, 'coveralls:push']
|
@@ -0,0 +1,64 @@
|
|
1
|
+
Feature: Profile with environment variables
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "spec/a_spec.rb" with:
|
5
|
+
"""ruby
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
describe 'a gerbil' do
|
9
|
+
it 'has feet' do
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'has a nose' do
|
13
|
+
RubyProf.pause if RubyProf.running?
|
14
|
+
RubyProf.resume if RubyProf.running?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
|
19
|
+
Scenario: when set to 'each' and running only a specific scenario
|
20
|
+
Given the environment variable "RSPEC_PROFILE" is set to "each"
|
21
|
+
When I run `rspec spec/a_spec.rb:7`
|
22
|
+
Then it should pass
|
23
|
+
And the following files should exist:
|
24
|
+
| profiles/a-gerbil/has-a-nose:7.html |
|
25
|
+
And the following files should not exist:
|
26
|
+
| profiles/all.html |
|
27
|
+
| profiles/a-gerbil/has-feet:4.html |
|
28
|
+
|
29
|
+
Scenario: when set to 'each'
|
30
|
+
Given the environment variable "RSPEC_PROFILE" is set to "each"
|
31
|
+
When I run `rspec`
|
32
|
+
Then it should pass
|
33
|
+
And the following files should exist:
|
34
|
+
| profiles/a-gerbil/has-feet:4.html |
|
35
|
+
| profiles/a-gerbil/has-a-nose:7.html |
|
36
|
+
And the following files should not exist:
|
37
|
+
| profiles/all.html |
|
38
|
+
|
39
|
+
Scenario: when set to 'all'
|
40
|
+
Given the environment variable "RSPEC_PROFILE" is set to "all"
|
41
|
+
When I run `rspec`
|
42
|
+
Then it should pass
|
43
|
+
And the following files should exist:
|
44
|
+
| profiles/all.html |
|
45
|
+
And the following files should not exist:
|
46
|
+
| profiles/a-gerbil/has-feet:4.html |
|
47
|
+
| profiles/a-gerbil/has-a-nose:7.html |
|
48
|
+
|
49
|
+
Scenario: when set to some invalid value
|
50
|
+
Given the environment variable "RSPEC_PROFILE" is set to "invalid value"
|
51
|
+
When I run `rspec`
|
52
|
+
Then it should fail
|
53
|
+
And the output should contain:
|
54
|
+
"""
|
55
|
+
ENV['RSPEC_PROFILE'] should be blank, 'all' or 'each', but was 'invalid value'
|
56
|
+
"""
|
57
|
+
|
58
|
+
Scenario: when not set at all
|
59
|
+
When I run `rspec`
|
60
|
+
Then it should pass
|
61
|
+
And the following files should not exist:
|
62
|
+
| profiles/all.html |
|
63
|
+
| profiles/a-gerbil/has-feet:4.html |
|
64
|
+
| profiles/a-gerbil/has-a-nose:7.html |
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Before do |scenario|
|
2
|
+
|
3
|
+
step 'a file named "spec/spec_helper.rb" with:', <<-end_file
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.start do
|
8
|
+
root "#{File.expand_path('../..', File.dirname(__FILE__))}"
|
9
|
+
coverage_dir 'coverage'
|
10
|
+
SimpleCov.command_name #{scenario.title.inspect}
|
11
|
+
filters.clear
|
12
|
+
add_filter { |f| !f.filename['rspec-prof'] }
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'rspec-prof'
|
16
|
+
end_file
|
17
|
+
|
18
|
+
end
|
data/lib/rspec-prof.rb
CHANGED
@@ -1,120 +1,77 @@
|
|
1
|
-
unless defined?(Gem)
|
2
|
-
require 'rubygems'
|
3
|
-
gem 'sc-core-ext', ">= 1.2.1"
|
4
|
-
gem 'rspec'
|
5
|
-
gem 'ruby-prof'
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'sc-core-ext'
|
9
|
-
require 'ruby-prof'
|
10
1
|
require 'fileutils'
|
2
|
+
require 'ruby-prof'
|
3
|
+
require 'rspec/core'
|
4
|
+
require 'rspec-prof/filename_helpers'
|
5
|
+
|
6
|
+
class RSpecProf
|
7
|
+
extend FilenameHelpers
|
11
8
|
|
12
|
-
|
13
|
-
require 'rspec-prof/profiler'
|
14
|
-
$rspec_prof_filename_id = 0
|
15
|
-
$rspec_prof_thread_id = Thread.current.object_id
|
9
|
+
@printer_class = RubyProf::GraphHtmlPrinter
|
16
10
|
|
17
|
-
# See the README for general usage information.
|
18
|
-
#
|
19
|
-
# See RSpecProf::Profiler for all configuration options.
|
20
|
-
#
|
21
|
-
# You can enable RSpecProf by adding
|
22
|
-
# RSpecProf.enable!
|
23
|
-
# to your spec_helper.rb file. Actually, RSpecProf is enabled by default.
|
24
|
-
#
|
25
|
-
# You can disable RSpecProf by adding
|
26
|
-
# RSpecProf.disable!
|
27
|
-
# to your spec_helper.rb file.
|
28
|
-
#
|
29
|
-
# You can see if RSpecProf is enabled by calling
|
30
|
-
# RSpecProf.enabled?
|
31
|
-
#
|
32
|
-
module RSpecProf
|
33
11
|
class << self
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@enable = false
|
42
|
-
end
|
43
|
-
|
44
|
-
# Returns true if profiling is enabled, false otherwise.
|
45
|
-
def enabled?
|
46
|
-
@enabled ||= true
|
12
|
+
attr_accessor :printer_class
|
13
|
+
|
14
|
+
def profile filename
|
15
|
+
profiler = new.start
|
16
|
+
yield
|
17
|
+
ensure
|
18
|
+
profiler.save_to filename
|
47
19
|
end
|
48
20
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
else
|
62
|
-
(
|
63
|
-
"#{$rspec_prof_filename_id += 1}-" +
|
64
|
-
self.class.description_parts.join(" ") +
|
65
|
-
" #{self.description}"
|
66
|
-
).gsub(/\s+/, '_').gsub(/\(profiling\)/, '')
|
67
|
-
end
|
68
|
-
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
return if @profiling
|
24
|
+
@profiling = true
|
25
|
+
RubyProf.start
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def stop
|
30
|
+
return unless @profiling
|
31
|
+
@profiling = false
|
32
|
+
@result = RubyProf.stop
|
69
33
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
if Thread.current.object_id == $rspec_prof_thread_id
|
86
|
-
@profiler = RSpecProf::Profiler.new(options.reverse_merge(:file => default_filename))
|
87
|
-
@profiler.start
|
88
|
-
else
|
89
|
-
Kernel.warn "Profiling is disabled because you appear to be multi-threading the specs"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
instance_eval &block
|
94
|
-
|
95
|
-
after(scope) do
|
96
|
-
@profiler.stop if @profiler
|
97
|
-
@profiler = nil
|
98
|
-
end
|
99
|
-
end
|
34
|
+
|
35
|
+
def profiling?
|
36
|
+
@profiling
|
37
|
+
end
|
38
|
+
|
39
|
+
def result
|
40
|
+
@result
|
41
|
+
end
|
42
|
+
|
43
|
+
def save_to filename
|
44
|
+
stop
|
45
|
+
FileUtils.mkdir_p File.dirname(filename)
|
46
|
+
File.open(filename, "w") do |f|
|
47
|
+
printer = RSpecProf.printer_class.new(result)
|
48
|
+
printer.print f
|
100
49
|
end
|
101
50
|
end
|
102
51
|
end
|
103
52
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
53
|
+
RSpec.configure do |config|
|
54
|
+
config.before(:all) do
|
55
|
+
unless ['all', 'each', ''].include?(ENV['RSPEC_PROFILE'].to_s)
|
56
|
+
raise "ENV['RSPEC_PROFILE'] should be blank, 'all' or 'each', but was '#{ENV['RSPEC_PROFILE']}'"
|
57
|
+
end
|
58
|
+
|
59
|
+
if ENV['RSPEC_PROFILE'] == 'all'
|
60
|
+
@profiler = RSpecProf.new.start
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
config.after(:all) do
|
65
|
+
if ENV['RSPEC_PROFILE'] == 'all'
|
66
|
+
@profiler.save_to "profiles/all.html"
|
67
|
+
end
|
108
68
|
end
|
109
69
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
70
|
+
config.around(:each) do |example|
|
71
|
+
if ENV['RSPEC_PROFILE'] == 'each'
|
72
|
+
RSpecProf.profile(RSpecProf.filename_for(example)) { example.call }
|
73
|
+
else
|
74
|
+
example.call
|
75
|
+
end
|
116
76
|
end
|
117
|
-
|
118
|
-
Spec::Example::ExampleGroupMethods.send(:include, RSpecProf::ClassMethods)
|
119
|
-
Spec::Example::ExampleMethods.send(:include, RSpecProf::InstanceMethods)
|
120
77
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class RSpecProf
|
2
|
+
module FilenameHelpers
|
3
|
+
@output_dir = "profiles"
|
4
|
+
@file_extension = "html"
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :output_dir
|
8
|
+
attr_accessor :file_extension
|
9
|
+
end
|
10
|
+
|
11
|
+
def output_dir
|
12
|
+
RSpecProf::FilenameHelpers.output_dir
|
13
|
+
end
|
14
|
+
|
15
|
+
def file_extension
|
16
|
+
RSpecProf::FilenameHelpers.file_extension
|
17
|
+
end
|
18
|
+
|
19
|
+
def path_for metadata
|
20
|
+
if metadata[:example_group]
|
21
|
+
File.join(path_for(metadata[:example_group], metadata[:description]))
|
22
|
+
else
|
23
|
+
metadata[:description]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def filename_for example
|
28
|
+
path = path_for(example.metadata[:example_group])
|
29
|
+
line_number = example.metadata[:line_number].to_s
|
30
|
+
description = example.metadata[:description]
|
31
|
+
File.join(
|
32
|
+
output_dir,
|
33
|
+
path,
|
34
|
+
description
|
35
|
+
).gsub(/\s+/, '-') + ":" + line_number + ".#{file_extension}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/rspec-prof.gemspec
CHANGED
@@ -1,71 +1,31 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
2
|
|
6
3
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.0.
|
4
|
+
s.name = "rspec-prof"
|
5
|
+
s.version = "0.0.4"
|
9
6
|
|
10
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
8
|
s.authors = ["Colin MacKenzie IV"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
9
|
+
s.date = "2011-11-04"
|
10
|
+
s.description = "Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec examples."
|
11
|
+
s.email = "sinisterchipmunk@gmail.com"
|
15
12
|
s.extra_rdoc_files = [
|
16
13
|
"LICENSE",
|
17
|
-
|
14
|
+
"README.rdoc"
|
18
15
|
]
|
19
|
-
s.files =
|
20
|
-
|
21
|
-
"README.rdoc",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION",
|
24
|
-
"lib/rspec-prof.rb",
|
25
|
-
"lib/rspec-prof/profiler.rb",
|
26
|
-
"lib/rspec.rb",
|
27
|
-
"rspec-prof.gemspec",
|
28
|
-
"spec/rspec-prof_spec.rb",
|
29
|
-
"spec/spec.opts",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://www.thoughtsincomputation.com/}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.homepage = "http://www.thoughtsincomputation.com/"
|
34
18
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version =
|
36
|
-
s.summary =
|
37
|
-
s.test_files =
|
38
|
-
"spec/rspec-prof_spec.rb",
|
39
|
-
"spec/spec.opts",
|
40
|
-
"spec/spec_helper.rb"
|
41
|
-
]
|
42
|
-
|
43
|
-
if s.respond_to? :specification_version then
|
44
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
-
s.specification_version = 3
|
19
|
+
s.rubygems_version = "1.8.10"
|
20
|
+
s.summary = "Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec examples."
|
21
|
+
s.test_files = `git ls-files -- features/`.split("\n")
|
46
22
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<sc-core-ext>, [">= 1.2.1"])
|
56
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
57
|
-
s.add_dependency(%q<ruby-prof>, [">= 0"])
|
58
|
-
s.add_dependency(%q<jeweler>, [">= 1.4.0"])
|
59
|
-
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
60
|
-
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
61
|
-
end
|
62
|
-
else
|
63
|
-
s.add_dependency(%q<sc-core-ext>, [">= 1.2.1"])
|
64
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
65
|
-
s.add_dependency(%q<ruby-prof>, [">= 0"])
|
66
|
-
s.add_dependency(%q<jeweler>, [">= 1.4.0"])
|
67
|
-
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
68
|
-
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
69
|
-
end
|
23
|
+
s.add_runtime_dependency 'rspec'
|
24
|
+
s.add_runtime_dependency 'ruby-prof'
|
25
|
+
s.add_development_dependency 'cucumber'
|
26
|
+
s.add_development_dependency 'aruba'
|
27
|
+
s.add_development_dependency 'simplecov'
|
28
|
+
s.add_development_dependency 'coveralls'
|
29
|
+
s.add_development_dependency 'rake'
|
70
30
|
end
|
71
31
|
|
metadata
CHANGED
@@ -1,162 +1,168 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-prof
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 0.0.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Colin MacKenzie IV
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: sc-core-ext
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 2
|
31
|
-
- 1
|
32
|
-
version: 1.2.1
|
33
|
-
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2011-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
36
14
|
name: rspec
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
46
20
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: ruby-prof
|
50
21
|
prerelease: false
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-prof
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
59
34
|
type: :runtime
|
60
|
-
version_requirements: *id003
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: jeweler
|
63
35
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cucumber
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aruba
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
74
62
|
type: :development
|
75
|
-
version_requirements: *id004
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: rspec
|
78
63
|
prerelease: false
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
89
76
|
type: :development
|
90
|
-
version_requirements: *id005
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: builder
|
93
77
|
prerelease: false
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
|
-
|
106
|
-
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Integrates ruby-prof with RSpec, allowing you to easily profile your
|
112
|
+
RSpec examples.
|
107
113
|
email: sinisterchipmunk@gmail.com
|
108
114
|
executables: []
|
109
|
-
|
110
115
|
extensions: []
|
111
|
-
|
112
|
-
extra_rdoc_files:
|
116
|
+
extra_rdoc_files:
|
113
117
|
- LICENSE
|
114
118
|
- README.rdoc
|
115
|
-
files:
|
119
|
+
files:
|
120
|
+
- .document
|
121
|
+
- .gitignore
|
122
|
+
- .travis.yml
|
123
|
+
- Gemfile
|
124
|
+
- Gemfile.lock
|
116
125
|
- LICENSE
|
117
126
|
- README.rdoc
|
118
127
|
- Rakefile
|
119
128
|
- VERSION
|
129
|
+
- features/profile_with_env_vars.feature
|
130
|
+
- features/step_definitions/environment_variable_steps.rb
|
131
|
+
- features/step_definitions/pass_fail_steps.rb
|
132
|
+
- features/support/env.rb
|
133
|
+
- features/support/reset_env.rb
|
134
|
+
- features/support/spec_helper.rb
|
120
135
|
- lib/rspec-prof.rb
|
121
|
-
- lib/rspec-prof/
|
122
|
-
- lib/rspec.rb
|
136
|
+
- lib/rspec-prof/filename_helpers.rb
|
123
137
|
- rspec-prof.gemspec
|
124
|
-
- spec/rspec-prof_spec.rb
|
125
|
-
- spec/spec.opts
|
126
|
-
- spec/spec_helper.rb
|
127
|
-
has_rdoc: true
|
128
138
|
homepage: http://www.thoughtsincomputation.com/
|
129
139
|
licenses: []
|
130
|
-
|
140
|
+
metadata: {}
|
131
141
|
post_install_message:
|
132
|
-
rdoc_options:
|
133
|
-
|
134
|
-
require_paths:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
135
144
|
- lib
|
136
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
requirements:
|
147
|
-
- - ">="
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
segments:
|
150
|
-
- 0
|
151
|
-
version: "0"
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
152
155
|
requirements: []
|
153
|
-
|
154
156
|
rubyforge_project:
|
155
|
-
rubygems_version:
|
157
|
+
rubygems_version: 2.0.3
|
156
158
|
signing_key:
|
157
|
-
specification_version:
|
158
|
-
summary: Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec
|
159
|
-
|
160
|
-
|
161
|
-
-
|
162
|
-
-
|
159
|
+
specification_version: 4
|
160
|
+
summary: Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec
|
161
|
+
examples.
|
162
|
+
test_files:
|
163
|
+
- features/profile_with_env_vars.feature
|
164
|
+
- features/step_definitions/environment_variable_steps.rb
|
165
|
+
- features/step_definitions/pass_fail_steps.rb
|
166
|
+
- features/support/env.rb
|
167
|
+
- features/support/reset_env.rb
|
168
|
+
- features/support/spec_helper.rb
|
data/lib/rspec-prof/profiler.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
module RSpecProf
|
2
|
-
class Profiler
|
3
|
-
attr_reader :options
|
4
|
-
|
5
|
-
# Possible options:
|
6
|
-
# :min_percent - Number 0 to 100 that specifes the minimum
|
7
|
-
# %self (the methods self time divided by the
|
8
|
-
# overall total time) that a method must take
|
9
|
-
# for it to be printed out in the report.
|
10
|
-
# Default value is 0.
|
11
|
-
#
|
12
|
-
# :print_file - True or false. Specifies if a method's source
|
13
|
-
# file should be printed. Default value is false.
|
14
|
-
#
|
15
|
-
# :printer - Specifies the output printer. Valid values include
|
16
|
-
# :flat, :graph, :graph_html and :call_tree. Defaults
|
17
|
-
# to :graph_html.
|
18
|
-
#
|
19
|
-
# :file - filename or IO stream to send data to. By default this
|
20
|
-
# is generated from your spec description and prepended
|
21
|
-
# with a unique ID. Extension is added automatically if
|
22
|
-
# one is not already present.
|
23
|
-
#
|
24
|
-
# :measure_mode - possible choices are 'wall_time', 'cpu_time',
|
25
|
-
# 'allocations', 'memory', 'process_time'. Defaults
|
26
|
-
# to 'process_time'
|
27
|
-
#
|
28
|
-
# :directory - the directory in which to place :file. If :file is not
|
29
|
-
# a String, this is ignored. Defaults to "./profiler"
|
30
|
-
#
|
31
|
-
def initialize(options)
|
32
|
-
@options = default_options.merge(options)
|
33
|
-
|
34
|
-
if @options[:file].kind_of?(String)
|
35
|
-
case @options[:printer]
|
36
|
-
when :graph_html
|
37
|
-
ext = "html"
|
38
|
-
else
|
39
|
-
ext = "txt"
|
40
|
-
end
|
41
|
-
|
42
|
-
@options[:file] = "#{@options[:file]}.#{ext}" unless @options[:file] =~ /\./
|
43
|
-
end
|
44
|
-
|
45
|
-
ENV["RUBY_PROF_MEASURE_MODE"] = options[:measure_mode]
|
46
|
-
RubyProf.figure_measure_mode
|
47
|
-
end
|
48
|
-
|
49
|
-
def start
|
50
|
-
RubyProf.start
|
51
|
-
end
|
52
|
-
|
53
|
-
def stop
|
54
|
-
file = options[:file]
|
55
|
-
result = RubyProf.stop
|
56
|
-
|
57
|
-
printer_class = options[:printer].kind_of?(Class) ? options[:printer] :
|
58
|
-
"RubyProf::#{options[:printer].to_s.camelize}Printer".constantize
|
59
|
-
with_io(file) do |out|
|
60
|
-
printer = printer_class.new(result)
|
61
|
-
printer.print(out, :print_file => options[:print_file], :min_percent => options[:min_percent])
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
def default_options
|
67
|
-
{
|
68
|
-
:min_percent => 0,
|
69
|
-
:print_file => false,
|
70
|
-
:printer => :graph_html,
|
71
|
-
:file => "./profile",
|
72
|
-
:measure_mode => 'process_time',
|
73
|
-
:directory => "./profiles"
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
def with_io(file)
|
78
|
-
if file.respond_to?(:write) && file.respond_to?(:puts)
|
79
|
-
yield file
|
80
|
-
else
|
81
|
-
file = File.expand_path(File.join(options[:directory], file))
|
82
|
-
FileUtils.makedirs(File.dirname(file))
|
83
|
-
File.open(file, "w") do |out|
|
84
|
-
yield out
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
data/lib/rspec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
unless defined?(RSPEC_VERSION)
|
2
|
-
begin
|
3
|
-
# RSpec 1.3.0
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/version'
|
6
|
-
|
7
|
-
RSPEC_VERSION = Spec::VERSION::STRING
|
8
|
-
rescue LoadError
|
9
|
-
# RSpec 2.0
|
10
|
-
begin
|
11
|
-
require 'rspec/core'
|
12
|
-
require 'rspec/core/version'
|
13
|
-
|
14
|
-
RSPEC_VERSION = RSpec::Core::Version::STRING
|
15
|
-
rescue LoadError
|
16
|
-
raise "RSpec does not seem to be installed. You must gem install rspec to use this gem."
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/spec/rspec-prof_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe RSpecProf do
|
4
|
-
# I'm still at a loss as to how to spec extensions to rspec short of just using the extension.
|
5
|
-
|
6
|
-
shared_examples_for "profiling rspec" do
|
7
|
-
it "should profile rspec" do
|
8
|
-
# uhh, how to measure success?
|
9
|
-
sleep(1)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "a context" do
|
14
|
-
profile do
|
15
|
-
it_should_behave_like "profiling rspec"
|
16
|
-
end
|
17
|
-
|
18
|
-
profile :printer => :graph do
|
19
|
-
it_should_behave_like "profiling rspec"
|
20
|
-
end
|
21
|
-
|
22
|
-
profile :measure_mode => "wall_time", :printer => :graph do
|
23
|
-
it_should_behave_like "profiling rspec"
|
24
|
-
end
|
25
|
-
|
26
|
-
profile :file => StringIO.new("") do
|
27
|
-
it_should_behave_like "profiling rspec"
|
28
|
-
end
|
29
|
-
|
30
|
-
profile :min_percent => 0.01 do
|
31
|
-
it_should_behave_like "profiling rspec"
|
32
|
-
end
|
33
|
-
|
34
|
-
profile :each do
|
35
|
-
it_should_behave_like "profiling rspec"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "profile multiple" do
|
40
|
-
profile :all do
|
41
|
-
it "should profile 1" do sleep(1); end
|
42
|
-
it "should profile 2" do 100000.times { }; end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
-c
|
data/spec/spec_helper.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require File.join(File.dirname(__FILE__), "../lib/rspec-prof")
|
4
|
-
|
5
|
-
if RSPEC_VERSION >= "2.0.0"
|
6
|
-
require 'rspec/autorun'
|
7
|
-
else
|
8
|
-
require 'spec/autorun'
|
9
|
-
end
|