Class: UISpecRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/uispecrunner.rb,
lib/uispecrunner/options.rb,
lib/uispecrunner/application.rb,
lib/uispecrunner/drivers/shell.rb,
lib/uispecrunner/xcode_builder.rb,
lib/uispecrunner/drivers/waxsim.rb,
lib/uispecrunner/drivers/osascript.rb

Defined Under Namespace

Classes: Application, Drivers, Options, XcodeBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ UISpecRunner

Returns a new instance of UISpecRunner.



23
24
25
26
27
28
29
30
31
# File 'lib/uispecrunner.rb', line 23

def initialize(options = {})
  options.each { |k,v| self.send("#{k}=", v) }
  self.configuration ||= 'Debug'
  self.build_dir ||= './build'
  self.run_mode ||= :all
  self.driver ||= :waxsim
  self.exit_on_finish ||= true
  self.env ||= {}
end

Instance Attribute Details

#app_pathObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def app_path
  @app_path
end

#build_dirObject

Build Options



15
16
17
# File 'lib/uispecrunner.rb', line 15

def build_dir
  @build_dir
end

#configurationObject

Build Options



15
16
17
# File 'lib/uispecrunner.rb', line 15

def configuration
  @configuration
end

#driverObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def driver
  @driver
end

#envObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def env
  @env
end

#exampleObject

private



21
22
23
# File 'lib/uispecrunner.rb', line 21

def example
  @example
end

#exit_on_finishObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def exit_on_finish
  @exit_on_finish
end

#familyObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def family
  @family
end

#projectObject

Build Options



15
16
17
# File 'lib/uispecrunner.rb', line 15

def project
  @project
end

#protocolObject

private



21
22
23
# File 'lib/uispecrunner.rb', line 21

def protocol
  @protocol
end

#run_modeObject

private



21
22
23
# File 'lib/uispecrunner.rb', line 21

def run_mode
  @run_mode
end

#schemeObject

Build Options



15
16
17
# File 'lib/uispecrunner.rb', line 15

def scheme
  @scheme
end

#sdk_versionObject

Build Options



15
16
17
# File 'lib/uispecrunner.rb', line 15

def sdk_version
  @sdk_version
end

#securitydObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def securityd
  @securityd
end

#skip_buildObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def skip_build
  @skip_build
end

#specObject

private



21
22
23
# File 'lib/uispecrunner.rb', line 21

def spec
  @spec
end

#targetObject

Build Options



15
16
17
# File 'lib/uispecrunner.rb', line 15

def target
  @target
end

#verboseObject

Run Options



18
19
20
# File 'lib/uispecrunner.rb', line 18

def verbose
  @verbose
end

#workspaceObject

Build Options



15
16
17
# File 'lib/uispecrunner.rb', line 15

def workspace
  @workspace
end

Instance Method Details

#app_executable_nameObject



101
102
103
# File 'lib/uispecrunner.rb', line 101

def app_executable_name
  File.basename(app_path).gsub(/.app$/, '')
end

#app_executable_pathObject



105
106
107
# File 'lib/uispecrunner.rb', line 105

def app_executable_path
  File.join(app_path, app_executable_name)
end

#cached_app_filenameObject



82
83
84
# File 'lib/uispecrunner.rb', line 82

def cached_app_filename
  '.uispec.app'
end

#exit_on_finish?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/uispecrunner.rb', line 70

def exit_on_finish?
  self.exit_on_finish
end

#read_cached_app_pathObject



86
87
88
# File 'lib/uispecrunner.rb', line 86

def read_cached_app_path
  File.read(cached_app_filename).chomp if File.exists?(cached_app_filename)
end

#run!Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/uispecrunner.rb', line 33

def run!
  case self.run_mode
  when :all
    run_all!
  when :spec
    run_spec!(self.spec)
  when :example
    run_spec_example!(self.spec, self.example)
  when :protocol
    run_protocol!(self.protocol)
  else
    raise ArgumentError, "Unknown run mode: #{config.run_mode}"
  end    
end

#run_all!Object



48
49
50
# File 'lib/uispecrunner.rb', line 48

def run_all!
  run_specs
end

#run_protocol!(protocol_name) ⇒ Object



52
53
54
# File 'lib/uispecrunner.rb', line 52

def run_protocol!(protocol_name)
  run_specs('UISPEC_PROTOCOL' => protocol_name)
end

#run_spec!(spec_name) ⇒ Object



56
57
58
# File 'lib/uispecrunner.rb', line 56

def run_spec!(spec_name)
  run_specs('UISPEC_SPEC' => spec_name)
end

#run_spec_example!(spec_name, example_name) ⇒ Object



60
61
62
# File 'lib/uispecrunner.rb', line 60

def run_spec_example!(spec_name, example_name)
  run_specs('UISPEC_SPEC' => spec_name, 'UISPEC_EXAMPLE' => example_name)
end

#sdk_dirObject



78
79
80
# File 'lib/uispecrunner.rb', line 78

def sdk_dir
  "#{xcode_root}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator#{self.sdk_version}.sdk"
end

#verbose?Boolean

Configuration Methods

Returns:

  • (Boolean)


66
67
68
# File 'lib/uispecrunner.rb', line 66

def verbose?
  self.verbose
end

#write_cached_app_pathObject



90
91
92
93
94
95
# File 'lib/uispecrunner.rb', line 90

def write_cached_app_path
  if @app_path
    puts "Cached app path '#{app_path}'" unless File.exists?(cached_app_filename)
    File.open(cached_app_filename, 'w') { |f| f << @app_path }
  end
end

#xcode_rootObject



74
75
76
# File 'lib/uispecrunner.rb', line 74

def xcode_root
  @xcode_root ||= "#{`xcode-select -print-path`.chomp}"
end