spec/lib/fozzie_spec.rb in fozzie-0.0.2 vs spec/lib/fozzie_spec.rb in fozzie-0.0.3

- old
+ new

@@ -21,26 +21,52 @@ Fozzie::Classes::NAMESPACES.each do |k| kl = Kernel.const_get(k) kl.should respond_to(:increment) kl.should respond_to(:decrement) kl.should respond_to(:timing) - kl.should respond_to(:update_counter) + kl.should respond_to(:count) + kl.should respond_to(:time) end end it "acts an a singleton" do Fozzie::Classes::NAMESPACES.each do |k| kl1, kl2 = Kernel.const_get(k), Kernel.const_get(k) kl1.should == kl2 end end - it "assigns prefix when passed" do - Fozzie::AbstractFozzie.new(1,2, 'a').prefix.should == 'a' + it "assigns namespace when passed" do + Fozzie::AbstractFozzie.new(1,2, 'a').namespace.should == 'a' end it "times a given block" do - Stats.expects(:timing).with() {|b, val| b == 'data.bin' && (100..1200).include?(val) } + Stats.expects(:timing).with() {|b, val, timing| b == 'data.bin' && (1000..1200).include?(val) }.twice Stats.time_for('data.bin') { sleep 1 } + Stats.time_to_do('data.bin') { sleep 1 } + end + + it "registers a commit" do + Stats.expects(:timing).with('event.commit', anything).twice + Stats.commit + Stats.committed + end + + it "registers a build" do + Stats.expects(:timing).with('event.build', anything).twice + Stats.build + Stats.built + end + + it "registers a deploy" do + Stats.expects(:timing).with('event.deploy', anything).twice + Stats.deploy + Stats.deployed + end + + it "ignores exception and yields block" do + Stats.stubs(:time).raises(ArgumentError) + proc { Stats.time_for('data.bin') { sleep 1 } }.should_not raise_error + proc { Stats.time_to_do('data.bin') { sleep 1 } }.should_not raise_error end end \ No newline at end of file