Class: Guard::Runner
- Inherits:
-
Object
- Object
- Guard::Runner
- Defined in:
- lib/guard/calabash-ios/runner.rb
Instance Attribute Summary collapse
-
#bundle_path ⇒ Object
Returns the value of attribute bundle_path.
-
#config ⇒ Object
Returns the value of attribute config.
-
#device ⇒ Object
Returns the value of attribute device.
-
#no_launch ⇒ Object
Returns the value of attribute no_launch.
-
#project ⇒ Object
Returns the value of attribute project.
-
#reset_between_scenarios ⇒ Object
Returns the value of attribute reset_between_scenarios.
-
#sdk ⇒ Object
Returns the value of attribute sdk.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
- #command(features) ⇒ Object
- #init_bundle_path(options) ⇒ Object
- #init_config(options) ⇒ Object
- #init_device(options) ⇒ Object
- #init_no_launch(options) ⇒ Object
- #init_project(options) ⇒ Object
- #init_reset_between_scenarios(options) ⇒ Object
- #init_sdk(options) ⇒ Object
- #init_target(options) ⇒ Object
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #run(features) ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/guard/calabash-ios/runner.rb', line 11 def initialize() self.sdk = init_sdk() self.device = init_device() self.project = init_project() self.target = init_target() self.config = init_config() self.no_launch = init_no_launch() self.reset_between_scenarios = init_reset_between_scenarios() self.bundle_path = init_bundle_path() end |
Instance Attribute Details
#bundle_path ⇒ Object
Returns the value of attribute bundle_path.
3 4 5 |
# File 'lib/guard/calabash-ios/runner.rb', line 3 def bundle_path @bundle_path end |
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/guard/calabash-ios/runner.rb', line 8 def config @config end |
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/guard/calabash-ios/runner.rb', line 5 def device @device end |
#no_launch ⇒ Object
Returns the value of attribute no_launch.
9 10 11 |
# File 'lib/guard/calabash-ios/runner.rb', line 9 def no_launch @no_launch end |
#project ⇒ Object
Returns the value of attribute project.
6 7 8 |
# File 'lib/guard/calabash-ios/runner.rb', line 6 def project @project end |
#reset_between_scenarios ⇒ Object
Returns the value of attribute reset_between_scenarios.
10 11 12 |
# File 'lib/guard/calabash-ios/runner.rb', line 10 def reset_between_scenarios @reset_between_scenarios end |
#sdk ⇒ Object
Returns the value of attribute sdk.
4 5 6 |
# File 'lib/guard/calabash-ios/runner.rb', line 4 def sdk @sdk end |
#target ⇒ Object
Returns the value of attribute target.
7 8 9 |
# File 'lib/guard/calabash-ios/runner.rb', line 7 def target @target end |
Instance Method Details
#command(features) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/guard/calabash-ios/runner.rb', line 103 def command(features) if features.kind_of? Array features = features.join(' ') end cmd = [] cmd << "APP_BUNDLE_PATH='#{self.bundle_path}'" cmd << "OS=#{self.sdk}" cmd << "DEVICE=#{self.device}" cmd << "NO_LAUNCH=#{self.no_launch}" if self.no_launch cmd << "RESET_BETWEEN_SCENARIOS=#{self.reset_between_scenarios}" if self.reset_between_scenarios cmd << "cucumber #{features} --require features" cmd.join ' ' end |
#init_bundle_path(options) ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/guard/calabash-ios/runner.rb', line 117 def init_bundle_path() path = [] path << "#{Dir::pwd}/DerivedData/" path << "#{self.project}/" path << "Build/Products/" path << "#{self.config}-iphonesimulator/" path << "#{self.target}.app" path.join end |
#init_config(options) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/guard/calabash-ios/runner.rb', line 54 def init_config() if [:config].nil? "Debug" else [:config] end end |
#init_device(options) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/guard/calabash-ios/runner.rb', line 31 def init_device() devices = [:iphone, :ipad] if devices.include? [:device] [:device] else :iphone end end |
#init_no_launch(options) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/guard/calabash-ios/runner.rb', line 62 def init_no_launch() case [:no_launch] when true 1 when false 0 end end |
#init_project(options) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/guard/calabash-ios/runner.rb', line 40 def init_project() if [:project].nil? xproject = Dir.glob("*.xcodeproj").first if xproject xproject.gsub(".xcodeproj","") else UI.info "Could not find project" nil end else [:project] end end |
#init_reset_between_scenarios(options) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/guard/calabash-ios/runner.rb', line 71 def init_reset_between_scenarios() case [:reset_between_scenarios] when true 1 when false 0 end end |
#init_sdk(options) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/guard/calabash-ios/runner.rb', line 22 def init_sdk() sdks = [:ios4, :ios5] if sdks.include? [:sdk] [:sdk] else :ios5 end end |
#init_target(options) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/guard/calabash-ios/runner.rb', line 80 def init_target() if [:target].nil? "#{self.project}-cal" else [:target] end end |
#run(features) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/guard/calabash-ios/runner.rb', line 88 def run(features) unless File.exists? self.bundle_path.to_s UI.info "Could not run Calabash. \n'#{self.bundle_path}' not found." return false end if features.eql?("features") or features.empty? = "Run all features" else features = features.join(' ') if features.kind_of? Array = "Run #{features}" end UI.info system(command(features)) end |