From 90c97a799a2a235c6a6e85a16523a13db7891b3d Mon Sep 17 00:00:00 2001 From: Klaus Hartl Date: Fri, 1 Apr 2011 20:33:05 +0200 Subject: [PATCH] les specs --- spec/guard/phantomjs_spec.rb | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/spec/guard/phantomjs_spec.rb b/spec/guard/phantomjs_spec.rb index bd3c5fc..2ceaef3 100644 --- a/spec/guard/phantomjs_spec.rb +++ b/spec/guard/phantomjs_spec.rb @@ -4,11 +4,35 @@ module Guard describe PhantomJS do describe "#run_on_change" do - it "executes phantomjs" do - pending - subject.run_on_change(['foo']) + context "with modifications" do + it "executes phantomjs" do + Notifier.stub(:notify) + guard = PhantomJS.new([], :runner => 'driver.js') + guard.should_receive(:`).with('phantomjs driver.js http://127.0.0.1:8888/') + guard.run_on_change(['foo']) + end + + it "notifies" do + subject.stub(:`).and_return('0 failures') + Notifier.should_receive(:notify).with('0 failures', + :title => 'Jasmine results', :image => :success) + subject.run_on_change(['foo']) + + subject.stub(:`).and_return('1 failure') + Notifier.should_receive(:notify).with('1 failure', + :title => 'Jasmine results', :image => :failed) + subject.run_on_change(['foo']) + end end + + context "without modifications" do + it "skips executing phantomjs" do + subject.should_not_receive(:`) + subject.run_on_change([]) + end + end + end end