SHOW:
|
|
- or go back to the newest paste.
1 | require 'benchmark' | |
2 | ||
3 | module BenchmarkHelpers | |
4 | def benchmark(description, &block) | |
5 | # 1. Nope | |
6 | #bm_proc = Proc.new do | |
7 | # db = Proc.new { |bm| bm.report(description, &block) } | |
8 | # Benchmark.bm(description.length, &db) | |
9 | #end | |
10 | it description do | |
11 | Benchmark.bm(description.length) do |bm| | |
12 | # 2. Nada | |
13 | #bm.report description, &block | |
14 | bm.report description do | |
15 | - | # 3. Zilch |
15 | + | # 3. Zilch. |
16 | - | block.yield |
16 | + | #block.call |
17 | #block.yield | |
18 | # eval in context of example_group_instance! | |
19 | example.example_group_instance.instance_eval(&block) | |
20 | end | |
21 | end | |
22 | end | |
23 | end | |
24 | end | |
25 | ||
26 | RSpec.configure do |c| | |
27 | c.extend BenchmarkHelpers | |
28 | end | |
29 | ||
30 | describe "scopes" do | |
31 | it "succeeds" do | |
32 | p self.class | |
33 | p be | |
34 | true.should == true # success | |
35 | true.should be # success | |
36 | end | |
37 | benchmark "throws exception on 'be'" do | |
38 | p self.class | |
39 | - | rake spec SPEC=spec/benchmark_spec.rb |
39 | + | p be |
40 | true.should == true # success | |
41 | true.should be # exception | |
42 | end | |
43 | - | user system total real |
43 | + | |
44 | - | how do they work how do they work (FAILED - 1) |
44 | + | |
45 | ||
46 | - | Failures: |
46 | + | |
47 | ||
48 | - | 1) scopes how do they work |
48 | + | |
49 | - | Failure/Error: true.should be |
49 | + | RSpec::Core::ExampleGroup::Nested_1 |
50 | - | NameError: |
50 | + | #<RSpec::Matchers::Be:0x00000002822740 @args=[]> |
51 | - | undefined local variable or method `be' for RSpec::Core::ExampleGroup::Nested_1:Class |
51 | + | succeeds |
52 | - | # ./spec/benchmark_spec.rb:25:in `block (2 levels) in <top (required)>' |
52 | + | user system total real |
53 | - | # ./spec/benchmark_spec.rb:12:in `yield' |
53 | + | throws exception on 'be'RSpec::Core::ExampleGroup::Nested_1 |
54 | - | # ./spec/benchmark_spec.rb:12:in `block (3 levels) in benchmark' |
54 | + | #<RSpec::Matchers::Be:0x0000000281f068 @args=[]> |
55 | - | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure' |
55 | + | 0.000000 0.000000 0.000000 ( 0.000091) |
56 | - | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:382:in `item' |
56 | + | throws exception on 'be' |
57 | - | # ./spec/benchmark_spec.rb:11:in `block (2 levels) in benchmark' |
57 | + | |
58 | - | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:178:in `benchmark' |
58 | + | Finished in 0.0016 seconds |
59 | - | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:208:in `bm' |
59 | + | 2 examples, 0 failures |