Sha256: 2668d58043793c9a259e0ef028276f9f1426d89d923e235e002a6e0a92fea3a9
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require "spec_helper" require "boot_polish/nested_benchmark" module BootPolish describe NestedBenchmark do describe "instance" do let(:visitor) { double(:visitor, benchmark: nil, descend: nil, ascend: nil) } let(:nested_benchmark) { NestedBenchmark.new( visitor ) } describe "#visitor" do context "is passed into new" do it "is the same as the initalized value" do nested_benchmark.visitor.should == visitor end it "can be changed" do another_visitor = double(:another_visitor) nested_benchmark.visitor = another_visitor nested_benchmark.visitor.should == another_visitor end end context "it is not passed into new" do it "defaults to a new instance of DefaultRenderer" do renderer = double(:renderer) DefaultRenderer.should_receive(:new).and_return(renderer) nested_benchmark = NestedBenchmark.new nested_benchmark.visitor.should == renderer end end end describe "#nest" do it "returns the blocks evaluated value" do nested_benchmark.nest("holas") do 77 end.should == 77 end end it "visits and yields in the correct order" do block_content = double(:block_content) visitor.should_receive(:descend).ordered block_content.should_receive(:yield!).ordered visitor.should_receive(:benchmark).with("Hi", kind_of(Benchmark::Tms)).ordered visitor.should_receive(:ascend).ordered nested_benchmark.nest("Hi") do block_content.yield! end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
boot_polish-0.0.1 | spec/boot_polish/nested_benchmark_spec.rb |