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.call
- #block.yield
- # eval in context of example_group_instance!
- example.example_group_instance.instance_eval(&block)
- end
- end
- end
- end
- end
- RSpec.configure do |c|
- c.extend BenchmarkHelpers
- end
- describe "scopes" do
- it "succeeds" do
- p self.class
- p be
- true.should == true # success
- true.should be # success
- end
- benchmark "throws exception on 'be'" do
- p self.class
- p be
- true.should == true # success
- true.should be # exception
- end
- end
- /home/aaron/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S bundle exec rspec spec/benchmark_spec.rb
- scopes
- RSpec::Core::ExampleGroup::Nested_1
- #<RSpec::Matchers::Be:0x00000002822740 @args=[]>
- succeeds
- user system total real
- throws exception on 'be'RSpec::Core::ExampleGroup::Nested_1
- #<RSpec::Matchers::Be:0x0000000281f068 @args=[]>
- 0.000000 0.000000 0.000000 ( 0.000091)
- throws exception on 'be'
- Finished in 0.0016 seconds
- 2 examples, 0 failures
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement