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.
-
#device ⇒ Object
Returns the value of attribute device.
-
#sdk ⇒ Object
Returns the value of attribute sdk.
Instance Method Summary collapse
- #bundle(options) ⇒ Object
- #command(features) ⇒ Object
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #run(features) ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/guard/calabash-ios/runner.rb', line 6 def initialize() devices = [:iphone, :ipad] sdks = [:ios4, :ios5] if [:project].nil? project = Dir.glob("*.xcodeproj").first if project [:project] = project.gsub(".xcodeproj","") else UI.info "You must specify project name at your Guardfile." end end self.bundle_path = bundle() self.sdk =:ios5 if sdks.include? [:sdk] self.sdk = [:sdk] end self.device = :iphone if devices.include? [:device] self.device = [:device] end 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 |
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/guard/calabash-ios/runner.rb', line 5 def device @device 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 |
Instance Method Details
#bundle(options) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/guard/calabash-ios/runner.rb', line 50 def bundle() pwd = Dir::pwd project = [:project] target = [:target] || "frankified" config = [:config] || "Debug" bundle_path = "#{pwd}/DerivedData/#{project}/Build/Products/#{config}-iphonesimulator/#{project}-cal.app" end |
#command(features) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/guard/calabash-ios/runner.rb', line 43 def command(features) if features.kind_of? Array features = features.join(' ') end "APP_BUNDLE_PATH='#{self.bundle_path}' OS=#{self.sdk} DEVICE=#{self.device} cucumber #{features} --require features" end |
#run(features) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/guard/calabash-ios/runner.rb', line 28 def run(features) unless File.exists? self.bundle_path UI.info "Could not run Calabash. \n'#{self.bundle_path}' not found." return false end if features.eql?("features") = "Run all features" else features = features.join(' ') if features.kind_of? Array = "Run #{features}" end UI.info system(command(features)) end |