spec/lib/fozzie_spec.rb in fozzie-0.0.8 vs spec/lib/fozzie_spec.rb in fozzie-0.0.9

- old
+ new

@@ -91,13 +91,63 @@ it "registers failure" do Stats.expects(:increment).with("event.increment.fail", 1) Stats.increment_on('event.increment', false).should == false end - it "raises error on invalid value" do - [:monkey, "monkey", 1, 1.1, [], {}].each do |val| - proc { Stats.increment_on('event.increment', val) }.should raise_error(ArgumentError) + it "simply questions the passed val with if" do + a = mock() + a.expects(:save).returns({}) + Stats.expects(:increment).with("event.increment.success", 1) + Stats.increment_on('event.increment', a.save).should == {} + end + + it "registers fail on nil return" do + a = mock() + a.expects(:save).returns(nil) + Stats.expects(:increment).with("event.increment.fail", 1) + Stats.increment_on('event.increment', a.save).should == nil + end + + describe "performing actions" do + + it "registers success" do + a = mock() + a.expects(:save).returns(true) + Stats.expects(:increment).with("event.increment.success", 1) + Stats.increment_on('event.increment', a.save).should == true end + + it "registers failure" do + a = mock() + a.expects(:save).returns(false) + Stats.expects(:increment).with("event.increment.fail", 1) + Stats.increment_on('event.increment', a.save).should == false + end + + it "registers positive even when nested" do + a = mock() + a.expects(:save).returns(true) + Stats.expects(:timing).with('event.run', any_parameters) + Stats.expects(:increment).with("event.increment.success", 1) + + res = Stats.time_to_do "event.run" do + Stats.increment_on('event.increment', a.save) + end + res.should == true + end + + it "registers negative even when nested" do + a = mock() + a.expects(:save).returns(false) + Stats.expects(:timing).with('event.run', any_parameters) + Stats.expects(:increment).with("event.increment.fail", 1) + + res = Stats.time_to_do "event.run" do + Stats.increment_on('event.increment', a.save) + end + res.should == false + end + end end end \ No newline at end of file