Class: UISpecRunner::Drivers::OSAScript

Inherits:
Object
  • Object
show all
Defined in:
lib/uispecrunner/drivers/osascript.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ OSAScript



6
7
8
# File 'lib/uispecrunner/drivers/osascript.rb', line 6

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (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 = "  on deactivateEnvironmentVariable(variableName)\n    \n    tell application \"Xcode\"\n      tell active project document      \n        set executableName to name of executable of active target as string      \n        tell executable executableName\n\n          -- Check to see if the fallback path already exists       \n          set hasVariable to false as boolean\n\n          repeat with environmentVariable in environment variables          \n            if name of environmentVariable is equal to variableName then\n              set active of environmentVariable to no\n            end if\n        end repeat\n        \n    end tell -- executable\nend tell -- active project document\n          end tell -- Xcode\n          \n  end deactivateEnvironmentVariable\n  \n  on setEnvironmentVariable(variableName, variableValue)\n\n    tell application \"Xcode\"\n      tell active project document      \n        set executableName to name of executable of active target as string      \n        tell executable executableName\n\n          -- Check to see if the fallback path already exists       \n          set hasVariable to false as boolean\n\n          repeat with environmentVariable in environment variables          \n            if name of environmentVariable is equal to variableName then           \n              -- Overwrite any value            \n              set value of environmentVariable to variableValue           \n              set active of environmentVariable to yes            \n              set hasVariable to true as boolean            \n              exit repeat           \n            end if         \n          end repeat\n\n          -- Since the fallback path doesn't exist yet, create it       \n          if not hasVariable then         \n            make new environment variable with properties {name:variableName, value:variableValue, active:yes}         \n          end if        \n        end tell -- executable     \n      end tell -- active project document   \n    end tell -- Xcode\n\n  end setEnvironmentVariable\n\n  application \"iPhone Simulator\" quit\n--        application \"iPhone Simulator\" activate\n\n  tell application \"Xcode\"\n      set targetProject to project of active project document\n      \#{env_definitions}\n\n      tell targetProject\n          set active build configuration type to build configuration type \"Debug\"\n          set active SDK to \"iphonesimulator4.0\"\n          set the active target to the target named \"UISpec\"\n--                set value of build setting \"SDKROOT\" of build configuration \"Debug\" of active target to \"iphoneos4.0\"\n\n          build targetProject\n          launch targetProject\n          \n          -- Clear out the environment variables\n          my deactivateEnvironmentVariable(\"UISPEC_PROTOCOL\")\n          my deactivateEnvironmentVariable(\"UISPEC_SPEC\")\n          my deactivateEnvironmentVariable(\"UISPEC_EXAMPLE\")\n      end tell\n  end tell\n  SCRIPT\n  # puts \"\#{script}\"\n  # exit\n  `osascript <<SCRIPT\\n\#{script}\\nSCRIPT`\nend\n"