spec/rackamole/alert/twitt_spec.rb in rackamole-0.0.9 vs spec/rackamole/alert/twitt_spec.rb in rackamole-0.1.0

- old
+ new

@@ -1,6 +1,7 @@ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper]) +require 'chronic' describe Rackamole::Alert::Twitt do before( :each ) do @alert = Rackamole::Alert::Twitt.new( 'fernand', "blee" ) end @@ -20,25 +21,37 @@ end describe '#send_alert' do before( :each ) do @args = OrderedHash.new - @args[:type] = Rackamole.feature - @args[:app_name] = 'Test' - @args[:host] = 'Fred' - @args[:user_name] = 'Fernand' - @args[:path] = '/blee/fred' + @args[:type] = Rackamole.feature + @args[:app_name] = 'Test' + @args[:host] = 'Fred' + @args[:user_name] = 'Fernand' + @args[:path] = '/blee/fred' + @args[:created_at] = Chronic.parse( "2009/11/19" ) end + + it "should twitt a feature alert using class method correctly" do + twitt = mock( Rackamole::Alert::Twitt ) + client = Twitter::Client.stub!( :new ) + + Rackamole::Alert::Twitt.should_receive( :new ).with( 'blee', 'duh').once.and_return( twitt ) + # client.should_receive( :new ).once.and_return( client ) + twitt.should_receive( :send_alert ).with( @args ).once.and_return( "yeah" ) + + Rackamole::Alert::Twitt.deliver_alert( "blee", "duh", @args ) + end it "should twitt a feature alert correctly" do client = stub( Twitter::Client ) @alert.should_receive( :twitt ).once.and_return( client ) # client.should_receive( :new ).exactly(1).with( 'fernand', 'blee' ) client.should_receive( :status ).once - @alert.send_alert( @args ).should == "[Feature] Test on Fred - Fernand\n/blee/fred" + @alert.send_alert( @args ).should == "[Feature] Test on Fred - Fernand\n/blee/fred - 12:00:00" end it "should twitt a perf alert correctly" do @args[:type] = Rackamole.perf @args[:request_time] = 10.0 @@ -46,11 +59,11 @@ client = stub( Twitter::Client ) @alert.should_receive( :twitt ).once.and_return( client ) client.should_receive( :status ).once - @alert.send_alert( @args ).should == "[Perf] Test on Fred - Fernand\n/blee/fred\n10.0 secs" + @alert.send_alert( @args ).should == "[Perf] Test on Fred - Fernand\n/blee/fred\n10.0 secs - 12:00:00" end it "should twitt a perf alert correctly" do @args[:type] = Rackamole.fault @args[:fault] = 'Oh snap!' @@ -58,10 +71,10 @@ client = stub( Twitter::Client ) @alert.should_receive( :twitt ).once.and_return( client ) client.should_receive( :status ).once - @alert.send_alert( @args ).should == "[Fault] Test on Fred - Fernand\n/blee/fred\nOh snap!" + @alert.send_alert( @args ).should == "[Fault] Test on Fred - Fernand\n/blee/fred\nOh snap! - 12:00:00" end end describe "#format_time" do it "should format a request time correctly" do \ No newline at end of file