spec/punchblock/component/output_spec.rb in punchblock-0.4.3 vs spec/punchblock/component/output_spec.rb in punchblock-0.5.0
- old
+ new
@@ -49,16 +49,17 @@
it { should_not == output3 }
end
end
describe "actions" do
+ let(:mock_client) { mock 'Client' }
let(:command) { Output.new :text => 'Once upon a time there was a message...', :voice => 'kate' }
before do
command.component_id = 'abc123'
command.call_id = '123abc'
- command.connection = Connection.new :username => '123', :password => '123'
+ command.client = mock_client
end
describe '#pause_action' do
subject { command.pause_action }
@@ -73,11 +74,11 @@
command.request!
command.execute!
end
it "should send its command properly" do
- Connection.any_instance.expects(:write).with('123abc', command.pause_action, 'abc123').returns true
+ mock_client.expects(:execute_command).with(command.pause_action, :call_id => '123abc', :component_id => 'abc123').returns true
command.expects :paused!
command.pause!
end
end
@@ -117,11 +118,11 @@
command.execute!
command.paused!
end
it "should send its command properly" do
- Connection.any_instance.expects(:write).with('123abc', command.resume_action, 'abc123').returns true
+ mock_client.expects(:execute_command).with(command.resume_action, :call_id => '123abc', :component_id => 'abc123').returns true
command.expects :resumed!
command.resume!
end
end
@@ -161,11 +162,11 @@
command.request!
command.execute!
end
it "should send its command properly" do
- Connection.any_instance.expects(:write).with('123abc', command.stop_action, 'abc123')
+ mock_client.expects(:execute_command).with(command.stop_action, :call_id => '123abc', :component_id => 'abc123')
command.stop!
end
end
describe "when the command is not executing" do
@@ -194,11 +195,11 @@
end
it "should send its command properly" do
seek_action = command.seek_action seek_options
command.stubs(:seek_action).returns seek_action
- Connection.any_instance.expects(:write).with('123abc', seek_action, 'abc123').returns true
+ mock_client.expects(:execute_command).with(seek_action, :call_id => '123abc', :component_id => 'abc123').returns true
command.expects :seeking!
command.expects :stopped_seeking!
command.seek! seek_options
seek_action.request!
seek_action.execute!
@@ -261,11 +262,11 @@
end
it "should send its command properly" do
speed_up_action = command.speed_up_action
command.stubs(:speed_up_action).returns speed_up_action
- Connection.any_instance.expects(:write).with('123abc', speed_up_action, 'abc123').returns true
+ mock_client.expects(:execute_command).with(speed_up_action, :call_id => '123abc', :component_id => 'abc123').returns true
command.expects :speeding_up!
command.expects :stopped_speeding!
command.speed_up!
speed_up_action.request!
speed_up_action.execute!
@@ -319,11 +320,11 @@
end
it "should send its command properly" do
slow_down_action = command.slow_down_action
command.stubs(:slow_down_action).returns slow_down_action
- Connection.any_instance.expects(:write).with('123abc', slow_down_action, 'abc123').returns true
+ mock_client.expects(:execute_command).with(slow_down_action, :call_id => '123abc', :component_id => 'abc123').returns true
command.expects :slowing_down!
command.expects :stopped_speeding!
command.slow_down!
slow_down_action.request!
slow_down_action.execute!
@@ -394,11 +395,11 @@
end
it "should send its command properly" do
volume_up_action = command.volume_up_action
command.stubs(:volume_up_action).returns volume_up_action
- Connection.any_instance.expects(:write).with('123abc', volume_up_action, 'abc123').returns true
+ mock_client.expects(:execute_command).with(volume_up_action, :call_id => '123abc', :component_id => 'abc123').returns true
command.expects :voluming_up!
command.expects :stopped_voluming!
command.volume_up!
volume_up_action.request!
volume_up_action.execute!
@@ -452,10 +453,10 @@
end
it "should send its command properly" do
volume_down_action = command.volume_down_action
command.stubs(:volume_down_action).returns volume_down_action
- Connection.any_instance.expects(:write).with('123abc', volume_down_action, 'abc123').returns true
+ mock_client.expects(:execute_command).with(volume_down_action, :call_id => '123abc', :component_id => 'abc123').returns true
command.expects :voluming_down!
command.expects :stopped_voluming!
command.volume_down!
volume_down_action.request!
volume_down_action.execute!