Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'benchmark'
- module BenchmarkHelpers
- def benchmark(description, &block)
- # 1. Nope
- #bm_proc = Proc.new do
- # db = Proc.new { |bm| bm.report(description, &block) }
- # Benchmark.bm(description.length, &db)
- #end
- it description do
- Benchmark.bm(description.length) do |bm|
- # 2. Nada
- #bm.report description, &block
- bm.report description do
- # 3. Zilch
- block.yield
- end
- end
- end
- end
- end
- RSpec.configure do |c|
- c.extend BenchmarkHelpers
- end
- describe "scopes" do
- it "succeeds" do
- true.should == true # success
- true.should be # success
- end
- benchmark "throws exception on 'be'" do
- true.should == true # success
- true.should be # exception
- end
- end
- rake spec SPEC=spec/benchmark_spec.rb
- /home/aaron/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S bundle exec rspec spec/benchmark_spec.rb
- scopes
- user system total real
- how do they work how do they work (FAILED - 1)
- Failures:
- 1) scopes how do they work
- Failure/Error: true.should be
- NameError:
- undefined local variable or method `be' for RSpec::Core::ExampleGroup::Nested_1:Class
- # ./spec/benchmark_spec.rb:25:in `block (2 levels) in <top (required)>'
- # ./spec/benchmark_spec.rb:12:in `yield'
- # ./spec/benchmark_spec.rb:12:in `block (3 levels) in benchmark'
- # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
- # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:382:in `item'
- # ./spec/benchmark_spec.rb:11:in `block (2 levels) in benchmark'
- # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:178:in `benchmark'
- # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:208:in `bm'
- # ./spec/benchmark_spec.rb:10:in `block in benchmark'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement