lib/calabash-android/operations.rb in calabash-android-0.3.2.pre4 vs lib/calabash-android/operations.rb in calabash-android-0.3.2.pre5
- old
+ new
@@ -28,11 +28,14 @@
else
Then(txt)
end
end
def default_device
- Device.default_device
+ unless @default_device
+ @default_device = Device.new(self, ENV["ADB_DEVICE_ARG"], ENV["TEST_SERVER_PORT"], ENV["APP_PATH"], ENV["TEST_APP_PATH"])
+ end
+ @default_device
end
def performAction(action, *arguments)
default_device.perform_action(action, *arguments)
end
@@ -118,24 +121,17 @@
puts "Please take a look in your hooks file for calls to this methods."
puts "(Hooks are stored in features/support)"
end
class Device
- @@default_device = nil
- def self.default_device
- unless @@default_device
- @@default_device = Device.new(ENV["ADB_DEVICE_ARG"], ENV["TEST_SERVER_PORT"], ENV["APP_PATH"], ENV["TEST_APP_PATH"])
- end
- @@default_device
- end
-
def make_default_device
- @@default_device = self
+ @cucumber_world.default_device = self
end
- def initialize(serial, server_port, app_path, test_server_path)
+ def initialize(cucumber_world, serial, server_port, app_path, test_server_path)
+ @cucumber_world = cucumber_world
@serial = serial
@server_port = server_port
@app_path = app_path
@test_server_path = test_server_path
@@ -184,10 +180,10 @@
end
log "Result:'" + result.strip + "'"
raise "Empty result from TestServer" if result.chomp.empty?
result = JSON.parse(result)
if not result["success"] then
- screenshot_embed
+ @cucumber_world.screenshot_embed
if result["bonusInformation"] && result["bonusInformation"].size > 0 && result["bonusInformation"][0].include?("Exception")
log result["bonusInformation"][0]
end
raise "Step unsuccessful: #{result["message"]}"
end