spec/honeydew/device_spec.rb in honeydew-0.1.4 vs spec/honeydew/device_spec.rb in honeydew-0.10.0
- old
+ new
@@ -1,66 +1,68 @@
require 'spec_helper'
describe Honeydew::Device, :silence_puts do
- let(:response) { "{ \"success\": true }" }
- let(:command) { {"action" => '', "arguments" => {}} }
- let(:serial) { "ABC123DEF" }
+ let(:response) { '{"success": true }' }
+ let(:device) { Honeydew::Device.new('ABC123DEF') }
+ let(:device_end_point) do
+ "http://127.0.0.1:#{device.port}"
+ end
before do
- @device = Honeydew::Device.new serial
- @device_end_point = "http://127.0.0.1:#{@device.port}"
- RestClient.stub(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
+ RestClient.stub(:get).and_return(response)
end
- describe "contains_textview_text?" do
- let(:text) { "Ok" }
- let(:command) { {"action" => 'is_text_present', "arguments" => {"text" => text, "type" => 'TextView'}} }
+ describe '#contains_textview_text?' do
+ let(:text) { 'Ok' }
+ let(:command) do
+ {'action' => 'is_text_present',
+ 'arguments' => {'text' => text, 'type' => 'TextView'}}
+ end
- it "should make the call with command is_text_present" do
- RestClient.should_receive(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
- @device.contains_textview_text?(text)
+ it 'should make the call with command is_text_present' do
+ RestClient.should_receive(:get).with(device_end_point, params: {'command' => command})
+ device.contains_textview_text?(text)
end
- context "on successful response" do
- let(:response) { "{ \"success\": true }" }
+ context 'on successful response' do
+ let(:response) { '{ "success": true }' }
- it "should return true" do
- @device.contains_textview_text?(text).should be_true
+ it 'should return true' do
+ device.contains_textview_text?(text).should be_true
end
end
- context "on failure response" do
- let(:response) { "{ \"success\": false }" }
+ context 'on failure response' do
+ let(:response) { '{ "success": false }' }
- it "should return false" do
- @device.contains_textview_text?(text).should be_false
+ it 'should return false' do
+ device.contains_textview_text?(text).should be_false
end
end
end
- describe "contains_button?" do
- let(:text) { "Ok" }
- let(:command) { {"action" => 'is_button_present', "arguments" => {"text" => text}} }
+ describe '#contains_button?' do
+ let(:text) { 'Ok' }
+ let(:command) { {'action' => 'is_button_present', 'arguments' => {'text' => text}} }
- it "should make the call with command is_button_present" do
- RestClient.should_receive(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
- @device.contains_button?(text)
+ it 'should make the call with command is_button_present' do
+ RestClient.should_receive(:get).with(device_end_point, params: {'command' => command})
+ device.contains_button?(text)
end
- context "on successful response" do
- let(:response) { "{ \"success\": true }" }
+ context 'on successful response' do
+ let(:response) { '{ "success": true }' }
- it "should return true" do
- @device.contains_button?(text).should be_true
+ it 'should return true' do
+ device.contains_button?(text).should be_true
end
end
- context "on failure response" do
- let(:response) { "{ \"success\": false }" }
+ context 'on failure response' do
+ let(:response) { '{ "success": false }' }
- it "should return false" do
- @device.contains_button?(text).should be_false
+ it 'should return false' do
+ device.contains_button?(text).should be_false
end
end
end
-
end