honeydew 0.12.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.rspec +1 -1
  2. data/LICENSE.txt +1 -1
  3. data/README.md +79 -8
  4. data/Rakefile +2 -2
  5. data/examples/cucumber/Gemfile +5 -0
  6. data/{example → examples/cucumber}/Rakefile +0 -0
  7. data/{example → examples/cucumber}/features/example.feature +0 -0
  8. data/{example → examples/cucumber}/features/step_definitions/honeydew_steps.rb +0 -0
  9. data/examples/rspec/spec/browse_spec.rb +16 -0
  10. data/examples/rspec/spec/spec_helper.rb +6 -0
  11. data/honeydew.gemspec +17 -17
  12. data/honeydew.iml +12 -18
  13. data/lib/honeydew.rb +1 -72
  14. data/lib/honeydew/device.rb +79 -44
  15. data/lib/honeydew/device_actions.rb +32 -100
  16. data/lib/honeydew/device_commands.rb +36 -23
  17. data/lib/honeydew/device_matchers.rb +29 -22
  18. data/lib/honeydew/dsl.rb +1 -1
  19. data/lib/honeydew/honeydew.rb +82 -0
  20. data/lib/honeydew/version.rb +1 -1
  21. data/{android-server → server}/.gitignore +0 -0
  22. data/{android-server → server}/pom.xml +16 -6
  23. data/{android-server → server}/repo/com/google/android/uiautomator/4.1.1.4/_maven.repositories +0 -0
  24. data/{android-server → server}/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.jar +0 -0
  25. data/{android-server → server}/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.pom +0 -0
  26. data/{android-server → server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.jar +0 -0
  27. data/{android-server → server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.pom +0 -0
  28. data/{android-server → server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/maven-metadata-local.xml +0 -0
  29. data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/_maven.repositories +0 -0
  30. data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.jar +0 -0
  31. data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.pom +0 -0
  32. data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/maven-metadata-local.xml +0 -0
  33. data/{android-server → server}/repo/commons-jxpath/commons-jxpath/maven-metadata-local.xml +0 -0
  34. data/server/repo/fi/iki/elonen/nanohttpd-webserver/2.0.3/nanohttpd-webserver-2.0.3.jar +0 -0
  35. data/server/repo/fi/iki/elonen/nanohttpd-webserver/2.0.3/nanohttpd-webserver-2.0.3.pom +9 -0
  36. data/server/repo/fi/iki/elonen/nanohttpd-webserver/maven-metadata-local.xml +12 -0
  37. data/server/repo/fi/iki/elonen/nanohttpd/2.0.3/nanohttpd-2.0.3.jar +0 -0
  38. data/server/repo/fi/iki/elonen/nanohttpd/2.0.3/nanohttpd-2.0.3.pom +9 -0
  39. data/server/repo/fi/iki/elonen/nanohttpd/maven-metadata-local.xml +12 -0
  40. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/Action.java +13 -6
  41. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/ActionsExecutor.java +3 -2
  42. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/Command.java +6 -1
  43. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/Result.java +7 -7
  44. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/TestRunner.java +14 -6
  45. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/Click.java +3 -3
  46. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/ClickAndWaitForNewWindow.java +3 -3
  47. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/DumpWindowHierarchy.java +5 -5
  48. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/HasSettingsMenuItem.java +4 -5
  49. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/InspectOptionInSettingsMenu.java +3 -3
  50. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsButtonPresent.java +3 -3
  51. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsChildCountEqualTo.java +4 -4
  52. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsElementWithNestedTextPresent.java +3 -3
  53. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsOptionInSettingsMenuDisabled.java +1 -1
  54. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsOptionInSettingsMenuEnabled.java +1 -1
  55. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsTextPresent.java +3 -3
  56. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/LaunchApp.java +3 -3
  57. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/LaunchHome.java +3 -3
  58. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/LongClick.java +3 -3
  59. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/PressBack.java +3 -3
  60. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/PressEnter.java +4 -4
  61. data/server/src/main/java/com/amplify/honeydew_server/actions/ScrollToTextByIndex.java +27 -0
  62. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SelectFromAppsList.java +4 -4
  63. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SelectMenuInSettings.java +3 -3
  64. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SetText.java +3 -3
  65. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SetTextByIndex.java +2 -2
  66. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SetTextByLabel.java +3 -3
  67. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/Unlock.java +3 -3
  68. data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/WakeUp.java +4 -4
  69. data/server/src/main/java/com/amplify/honeydew_server/httpd/RemoteCommandReceiver.java +66 -0
  70. data/spec/honeydew/device_matchers_spec.rb +21 -42
  71. data/spec/honeydew/device_spec.rb +38 -36
  72. data/spec/spec_helper.rb +2 -25
  73. metadata +93 -92
  74. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/NanoHTTPD.java +0 -1100
  75. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/RemoteCommandReceiver.java +0 -64
  76. data/example/Gemfile +0 -5
  77. data/example/features/support/hooks.rb +0 -4
  78. data/lib/honeydew/hooks.rb +0 -0
  79. data/lib/honeydew/step_definitions.rb +0 -75
  80. data/lib/tasks/honeydew.rake +0 -7
  81. data/todo.md +0 -9
@@ -1,4 +1,4 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
4
 
@@ -1,9 +1,9 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
4
  import com.android.uiautomator.core.UiObjectNotFoundException;
5
- import com.uiautomator_cucumber.android_server.Action;
6
- import com.uiautomator_cucumber.android_server.Result;
5
+ import com.amplify.honeydew_server.Action;
6
+ import com.amplify.honeydew_server.Result;
7
7
 
8
8
  import java.util.Map;
9
9
 
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.*;
4
- import com.uiautomator_cucumber.android_server.Action;
5
- import com.uiautomator_cucumber.android_server.Result;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
6
 
7
7
  import java.util.Map;
8
8
 
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.*;
4
- import com.uiautomator_cucumber.android_server.Action;
5
- import com.uiautomator_cucumber.android_server.Result;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
6
 
7
7
  import java.util.Map;
8
8
 
@@ -1,9 +1,9 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
4
  import com.android.uiautomator.core.UiObjectNotFoundException;
5
- import com.uiautomator_cucumber.android_server.Action;
6
- import com.uiautomator_cucumber.android_server.Result;
5
+ import com.amplify.honeydew_server.Action;
6
+ import com.amplify.honeydew_server.Result;
7
7
 
8
8
  import java.util.Map;
9
9
 
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.*;
4
- import com.uiautomator_cucumber.android_server.Action;
5
- import com.uiautomator_cucumber.android_server.Result;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
6
 
7
7
  import java.util.Map;
8
8
 
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.*;
4
- import com.uiautomator_cucumber.android_server.Action;
5
- import com.uiautomator_cucumber.android_server.Result;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
6
 
7
7
  import java.util.Map;
8
8
 
@@ -16,4 +16,4 @@ public class PressEnter extends Action {
16
16
  getUiDevice().pressEnter();
17
17
  return Result.OK;
18
18
  }
19
- }
19
+ }
@@ -0,0 +1,27 @@
1
+ package com.amplify.honeydew_server.actions;
2
+
3
+ import android.util.Log;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
+ import com.android.uiautomator.core.*;
7
+
8
+ import java.util.Map;
9
+
10
+ public class ScrollToTextByIndex extends Action {
11
+ public ScrollToTextByIndex(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ Log.i("ScrollToTextByIndex", "Found index field: " + arguments.get("index"));
18
+
19
+ String text = (String) arguments.get("text");
20
+ int index = Integer.parseInt((String) arguments.get("index"));
21
+
22
+ UiSelector scrollSelector = new UiSelector().scrollable(true).index(index);
23
+ UiScrollable uiScrollable = new UiScrollable(scrollSelector);
24
+
25
+ return uiScrollable.scrollTextIntoView(text) ? Result.OK : Result.FAILURE;
26
+ }
27
+ }
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.*;
4
- import com.uiautomator_cucumber.android_server.Action;
5
- import com.uiautomator_cucumber.android_server.Result;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
6
 
7
7
  import java.util.Map;
8
8
 
@@ -13,7 +13,7 @@ public class SelectFromAppsList extends Action {
13
13
 
14
14
  @Override
15
15
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
- String appName = (String) arguments.get("appName");
16
+ String appName = (String)arguments.get("appName");
17
17
  //TODO: Using a better selector
18
18
  UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(false));
19
19
  settingsMenu.setAsVerticalList();
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.*;
4
- import com.uiautomator_cucumber.android_server.Action;
5
- import com.uiautomator_cucumber.android_server.Result;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
6
 
7
7
  import java.util.Map;
8
8
 
@@ -1,11 +1,11 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
4
  import com.android.uiautomator.core.UiObject;
5
5
  import com.android.uiautomator.core.UiObjectNotFoundException;
6
6
  import com.android.uiautomator.core.UiSelector;
7
- import com.uiautomator_cucumber.android_server.Action;
8
- import com.uiautomator_cucumber.android_server.Result;
7
+ import com.amplify.honeydew_server.Action;
8
+ import com.amplify.honeydew_server.Result;
9
9
 
10
10
  import java.util.Map;
11
11
 
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import android.util.*;
4
4
  import com.android.uiautomator.core.*;
5
- import com.uiautomator_cucumber.android_server.*;
5
+ import com.amplify.honeydew_server.*;
6
6
 
7
7
  import java.util.*;
8
8
 
@@ -1,11 +1,11 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
4
  import com.android.uiautomator.core.UiObject;
5
5
  import com.android.uiautomator.core.UiObjectNotFoundException;
6
6
  import com.android.uiautomator.core.UiSelector;
7
- import com.uiautomator_cucumber.android_server.Action;
8
- import com.uiautomator_cucumber.android_server.Result;
7
+ import com.amplify.honeydew_server.Action;
8
+ import com.amplify.honeydew_server.Result;
9
9
 
10
10
  import java.util.Map;
11
11
 
@@ -1,11 +1,11 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
4
  import com.android.uiautomator.core.UiObject;
5
5
  import com.android.uiautomator.core.UiObjectNotFoundException;
6
6
  import com.android.uiautomator.core.UiSelector;
7
- import com.uiautomator_cucumber.android_server.Action;
8
- import com.uiautomator_cucumber.android_server.Result;
7
+ import com.amplify.honeydew_server.Action;
8
+ import com.amplify.honeydew_server.Result;
9
9
 
10
10
  import java.util.Map;
11
11
 
@@ -1,8 +1,8 @@
1
- package com.uiautomator_cucumber.android_server.actions;
1
+ package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.*;
4
- import com.uiautomator_cucumber.android_server.Action;
5
- import com.uiautomator_cucumber.android_server.Result;
4
+ import com.amplify.honeydew_server.Action;
5
+ import com.amplify.honeydew_server.Result;
6
6
  import android.os.RemoteException;
7
7
 
8
8
  import java.util.Map;
@@ -21,4 +21,4 @@ public class WakeUp extends Action {
21
21
  }
22
22
  return Result.OK;
23
23
  }
24
- }
24
+ }
@@ -0,0 +1,66 @@
1
+ package com.amplify.honeydew_server.httpd;
2
+
3
+ import android.util.Log;
4
+ import com.amplify.honeydew_server.ActionsExecutor;
5
+ import com.amplify.honeydew_server.Command;
6
+ import com.amplify.honeydew_server.Result;
7
+ import com.google.gson.Gson;
8
+ import com.google.gson.reflect.TypeToken;
9
+ import fi.iki.elonen.NanoHTTPD;
10
+
11
+ import java.io.IOException;
12
+ import java.lang.reflect.Type;
13
+ import java.util.HashMap;
14
+ import java.util.Map;
15
+
16
+ public class RemoteCommandReceiver extends NanoHTTPD {
17
+
18
+ private static final String PLAIN_TEXT = "plain/text";
19
+ private final ActionsExecutor actionsExecutor;
20
+
21
+ private final Response statusOkResponse = new Response("honeydew-server is awaiting commands");
22
+ private final Response terminateOkResponse = new Response("honeydew-server is stopping");
23
+ private final Response badRequestResponse = new Response(Response.Status.BAD_REQUEST, PLAIN_TEXT, "Unsupported command");
24
+
25
+ private final Gson jsonParser = new Gson();
26
+
27
+ public RemoteCommandReceiver(ActionsExecutor actionsExecutor) throws IOException, InterruptedException {
28
+ super(7120);
29
+ this.actionsExecutor = actionsExecutor;
30
+ }
31
+
32
+ @Override
33
+ public Response serve(String uri, Method method, Map<String, String> headers, Map<String, String> params, Map<String, String> files) {
34
+ if (method == Method.POST && uri.equalsIgnoreCase("/terminate")) {
35
+ stop();
36
+ return terminateOkResponse;
37
+ } else if (method == Method.POST && uri.equalsIgnoreCase("/command")) {
38
+ return performCommand(params);
39
+ } else if (method == Method.GET && uri.equalsIgnoreCase("/status")) {
40
+ return statusOkResponse;
41
+ }
42
+
43
+ return badRequestResponse;
44
+ }
45
+
46
+ private Response performCommand(Map<String, String> params) {
47
+ String action = params.get("action");
48
+ String argumentJson = params.get("arguments");
49
+ Type argumentCollectionType = new TypeToken<Map<String, Object>>(){}.getType();
50
+ Map<String, Object> arguments = jsonParser.fromJson(argumentJson, argumentCollectionType);
51
+
52
+ Log.i(getClass().getName(), String.format("Performing action %s: %s for %s", action, argumentJson, params.toString()));
53
+ try {
54
+ Result result = actionsExecutor.execute(new Command(action, arguments));
55
+ if (result.success == true) {
56
+ return new Response(result.description);
57
+ } else {
58
+ // TODO: NanoHTTPD does not provide a particularly complete set of status codes, so use 416 for now
59
+ return new Response(Response.Status.RANGE_NOT_SATISFIABLE, PLAIN_TEXT, result.errorMessage);
60
+ }
61
+ } catch(Exception exception) {
62
+ Log.e(getClass().getName(), String.format("Server error while processing command %s: %s", action, exception.toString()));
63
+ return new Response(Response.Status.INTERNAL_ERROR, PLAIN_TEXT, exception.toString());
64
+ }
65
+ }
66
+ }
@@ -1,58 +1,37 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Honeydew::DeviceMatchers do
4
-
5
- class DeviceTest
6
- include Honeydew::DeviceMatchers
7
- def perform_action; end
4
+ let(:device) do
5
+ Class.new do
6
+ include Honeydew::DeviceMatchers
7
+ def perform_assertion; end
8
+ end.new
8
9
  end
9
10
 
10
- let (:device) { DeviceTest.new }
11
-
12
- describe "#has_textview_text" do
13
- let (:text) { "some text" }
14
-
15
- it "should perform action for is_text_present" do
16
- device.should_receive(:perform_action).with(hash_including({action: "is_text_present"}))
17
-
18
- device.has_textview_text? text
19
- end
20
-
21
- it "should retry for a default timeout" do
22
- device.should_receive(:perform_action).with(hash_including({retry_until: Honeydew.config.timeout}))
23
-
24
- device.has_textview_text? text
25
- end
11
+ describe '#has_textview_text' do
12
+ let(:text) { 'some text' }
26
13
 
27
- it "should pass the arguments for the text view" do
28
- device.should_receive(:perform_action).with(hash_including({arguments: { text: text, type: 'TextView'}}))
14
+ it 'should perform action for is_text_present' do
15
+ device.should_receive(:perform_assertion)
16
+ .with(:is_text_present,
17
+ hash_including(text: text, type: 'TextView'),
18
+ timeout: nil)
29
19
 
30
20
  device.has_textview_text? text
31
21
  end
32
-
33
22
  end
34
23
 
35
- describe "#has_textview_with_text_and_description" do
36
- let (:text) { "some text" }
37
- let (:description) { "some description" }
38
-
39
- it "should perform action for is_text_present" do
40
- device.should_receive(:perform_action).with(hash_including({action: "is_text_present"}))
41
-
42
- device.has_textview_with_text_and_description? text, description
43
- end
44
-
45
- it "should retry for a default timeout" do
46
- device.should_receive(:perform_action).with(hash_including({retry_until: Honeydew.config.timeout}))
24
+ describe '#has_textview_with_text_and_description' do
25
+ let(:text) { 'some text' }
26
+ let(:description) { 'some description' }
47
27
 
48
- device.has_textview_with_text_and_description? text, description
49
- end
50
-
51
- it "should pass the arguments for the text view" do
52
- device.should_receive(:perform_action).with(hash_including({arguments: { text: text, description: description, type: 'TextView'}}))
28
+ it 'performs the is_text_present action' do
29
+ device.should_receive(:perform_assertion)
30
+ .with(:is_text_present,
31
+ hash_including(text: text, type: 'TextView'),
32
+ timeout: nil)
53
33
 
54
34
  device.has_textview_with_text_and_description? text, description
55
35
  end
56
-
57
36
  end
58
- end
37
+ end
@@ -1,66 +1,68 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Honeydew::Device, :silence_puts do
4
- let(:response) { "{ \"success\": true }" }
5
- let(:command) { {"action" => '', "arguments" => {}} }
6
- let(:serial) { "ABC123DEF" }
3
+ describe Honeydew::Device do
4
+ let(:response) { '{"success": true }' }
5
+ let(:device) { Honeydew::Device.new('ABC123DEF') }
6
+ let(:device_end_point) do
7
+ "http://127.0.0.1:#{device.port}"
8
+ end
7
9
 
8
10
  before do
9
- @device = Honeydew::Device.new serial
10
- @device_end_point = "http://127.0.0.1:#{@device.port}"
11
- RestClient.stub(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
11
+ Net::HTTP.stub(:post_form).and_return(response)
12
12
  end
13
13
 
14
- describe "contains_textview_text?" do
15
- let(:text) { "Ok" }
16
- let(:command) { {"action" => 'is_text_present', "arguments" => {"text" => text, "type" => 'TextView'}} }
14
+ describe '#contains_textview_text?' do
15
+ let(:text) { 'Ok' }
16
+ let(:command) do
17
+ {'action' => 'is_text_present',
18
+ 'arguments' => {'text' => text, 'type' => 'TextView'}}
19
+ end
17
20
 
18
- it "should make the call with command is_text_present" do
19
- RestClient.should_receive(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
20
- @device.contains_textview_text?(text)
21
+ it 'should make the call with command is_text_present' do
22
+ Net::HTTP.should_receive(:post_form).with(device_end_point, params: {'command' => command})
23
+ device.contains_textview_text?(text)
21
24
  end
22
25
 
23
- context "on successful response" do
24
- let(:response) { "{ \"success\": true }" }
26
+ context 'on successful response' do
27
+ let(:response) { '{ "success": true }' }
25
28
 
26
- it "should return true" do
27
- @device.contains_textview_text?(text).should be_true
29
+ it 'should return true' do
30
+ device.contains_textview_text?(text).should be_true
28
31
  end
29
32
  end
30
33
 
31
- context "on failure response" do
32
- let(:response) { "{ \"success\": false }" }
34
+ context 'on failure response' do
35
+ let(:response) { '{ "success": false }' }
33
36
 
34
- it "should return false" do
35
- @device.contains_textview_text?(text).should be_false
37
+ it 'should return false' do
38
+ device.contains_textview_text?(text).should be_false
36
39
  end
37
40
  end
38
41
  end
39
42
 
40
- describe "contains_button?" do
41
- let(:text) { "Ok" }
42
- let(:command) { {"action" => 'is_button_present', "arguments" => {"text" => text}} }
43
+ describe '#contains_button?' do
44
+ let(:text) { 'Ok' }
45
+ let(:command) { {'action' => 'is_button_present', 'arguments' => {'text' => text}} }
43
46
 
44
- it "should make the call with command is_button_present" do
45
- RestClient.should_receive(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
46
- @device.contains_button?(text)
47
+ it 'should make the call with command is_button_present' do
48
+ Net::HTTP.should_receive(:post_form).with(device_end_point, params: {'command' => command})
49
+ device.contains_button?(text)
47
50
  end
48
51
 
49
- context "on successful response" do
50
- let(:response) { "{ \"success\": true }" }
52
+ context 'on successful response' do
53
+ let(:response) { '{ "success": true }' }
51
54
 
52
- it "should return true" do
53
- @device.contains_button?(text).should be_true
55
+ it 'should return true' do
56
+ device.contains_button?(text).should be_true
54
57
  end
55
58
  end
56
59
 
57
- context "on failure response" do
58
- let(:response) { "{ \"success\": false }" }
60
+ context 'on failure response' do
61
+ let(:response) { '{ "success": false }' }
59
62
 
60
- it "should return false" do
61
- @device.contains_button?(text).should be_false
63
+ it 'should return false' do
64
+ device.contains_button?(text).should be_false
62
65
  end
63
66
  end
64
67
  end
65
-
66
68
  end