Class: UISpecRunner::Drivers::OSAScript
- Inherits:
-
Object
- Object
- UISpecRunner::Drivers::OSAScript
- Defined in:
- lib/uispecrunner/drivers/osascript.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ OSAScript
constructor
A new instance of OSAScript.
- #run_specs(env) ⇒ Object
Constructor Details
#initialize(config) ⇒ OSAScript
Returns a new instance of OSAScript.
6 7 8 |
# File 'lib/uispecrunner/drivers/osascript.rb', line 6 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/uispecrunner/drivers/osascript.rb', line 4 def config @config end |
Instance Method Details
#run_specs(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/uispecrunner/drivers/osascript.rb', line 10 def run_specs(env) # Set the environment variables requested by the runner... env_definitions = env.map do |key, value| "my setEnvironmentVariable(\"#{key}\", \"#{value}\")" end.join("\n") script = <<-SCRIPT on deactivateEnvironmentVariable(variableName) tell application "Xcode" tell active project document set executableName to name of executable of active target as string tell executable executableName -- Check to see if the fallback path already exists set hasVariable to false as boolean repeat with environmentVariable in environment variables if name of environmentVariable is equal to variableName then set active of environmentVariable to no end if end repeat end tell -- executable end tell -- active project document end tell -- Xcode end deactivateEnvironmentVariable on setEnvironmentVariable(variableName, variableValue) tell application "Xcode" tell active project document set executableName to name of executable of active target as string tell executable executableName -- Check to see if the fallback path already exists set hasVariable to false as boolean repeat with environmentVariable in environment variables if name of environmentVariable is equal to variableName then -- Overwrite any value set value of environmentVariable to variableValue set active of environmentVariable to yes set hasVariable to true as boolean exit repeat end if end repeat -- Since the fallback path doesn't exist yet, create it if not hasVariable then make new environment variable with properties {name:variableName, value:variableValue, active:yes} end if end tell -- executable end tell -- active project document end tell -- Xcode end setEnvironmentVariable application "iPhone Simulator" quit -- application "iPhone Simulator" activate tell application "Xcode" set targetProject to project of active project document #{env_definitions} tell targetProject set active build configuration type to build configuration type "Debug" set active SDK to "iphonesimulator4.0" set the active target to the target named "UISpec" -- set value of build setting "SDKROOT" of build configuration "Debug" of active target to "iphoneos4.0" build targetProject launch targetProject -- Clear out the environment variables my deactivateEnvironmentVariable("UISPEC_PROTOCOL") my deactivateEnvironmentVariable("UISPEC_SPEC") my deactivateEnvironmentVariable("UISPEC_EXAMPLE") end tell end tell SCRIPT # puts "#{script}" # exit `osascript <<SCRIPT\n#{script}\nSCRIPT` end |