spec/lib/ADB_spec.rb in ADB-0.5.5 vs spec/lib/ADB_spec.rb in ADB-0.5.6
- old
+ new
@@ -9,11 +9,11 @@
it "should know how to stop the adb server" do
should_call_adb_with('kill-server')
ADB.stop_server
end
-
+
it "should stop process if it takes too long" do
ADB.should_receive(:last_stdout).and_return("device")
process = double('process')
process.should_receive(:start)
process.should_receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
@@ -32,10 +32,19 @@
context "when executing a shell command" do
it "should be able to check the device date and time" do
should_call_adb_with('wait-for-device', 'shell', 'date')
ADB.shell('date')
end
+
+ it "can list installed packages" do
+ should_call_adb_with('wait-for-device', 'shell', 'pm', 'list', 'packages')
+ ADB.list_packages
+ end
+ it "can list installed packages with packages" do
+ should_call_adb_with('wait-for-device', 'shell', 'pm', 'list', 'packages', '-f')
+ ADB.list_packages '-f'
+ end
end
it "should be able to build an date formatted for adb shell date command" do
date = DateTime.strptime('04/23/2012 13:24', '%m/%d/%C%y %H:%M')
ADB.format_date_for_adb(date).should eq "20120423.132400"
@@ -65,11 +74,11 @@
it "should be able to pull a file with spaces in the name" do
should_call_adb_with('pull', '/usr/local file with spaces.txt', '/sdcard/remote file with spaces.txt')
ADB.pull('/usr/local file with spaces.txt', '/sdcard/remote file with spaces.txt')
end
-
+
it "should be able to remount the /system drive" do
should_call_adb_with('remount')
ADB.remount
end
@@ -169,11 +178,11 @@
should_call_adb_with('-s', 'sernum', 'wait-for-device', 'install', 'Test.apk')
ADB.install 'Test.apk', nil, :serial => 'sernum'
end
it "should raise an error when the install fails" do
- ADB.should_receive(:last_stdout).and_return("some error")
+ ADB.should_receive(:last_stdout).any_number_of_times.and_return("some error")
should_call_adb_with('wait-for-device', 'install', 'Test.apk')
expect { ADB.install('Test.apk') }.to raise_error(ADBError)
end
it "should accept an optional parameter" do
@@ -232,11 +241,11 @@
should_call_adb_with('uninstall', 'com.example')
expect { ADB.uninstall('com.example') }.to raise_error(ADBError, "Could not uninstall com.example Cause: some stdout message, and Error: some stderr message")
end
end
-
-
+
+
def should_call_adb_with(*args)
- ChildProcess.should_receive(:build).with('adb', *args).and_return(process_mock)
+ ChildProcess.should_receive(:build).with('adb', *args).and_return(process_mock)
end
-end
+ end