guard-calabash-ios 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alex Denisov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Guard::CalabashiOS
2
+
3
+ Guard gem for [Calabash-ios](https://github.com/calabash/calabash-ios).
4
+ Guard::CalabashiOS automatically run your cucumber features for iOS.
5
+
6
+ ## Installation
7
+
8
+ $ gem install guard-calabash-ios
9
+
10
+ ## Usage
11
+
12
+ Add support of the calabash to your project
13
+ as [described](https://github.com/calabash/calabash-ios/wiki/01-Getting-started-guide).
14
+ Then go to the Xcode settings and setup Derived Data as Relative.
15
+
16
+ ![Xcode locations](https://github.com/AlexDenisov/guard-frank/blob/master/locations.png?raw=true).
17
+
18
+ When you're done, run following commands from project directory
19
+
20
+ $ guard init calabash-ios
21
+ $ guard
22
+
23
+ ## Guard options
24
+
25
+ all_on_start - run all specs at first start, by default *true*
26
+ device - iphone or ipad, by default *:iphone*
27
+
@@ -0,0 +1,87 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'guard/notifier'
4
+
5
+ module Guard
6
+ class CalabashiOS < Guard
7
+
8
+ autoload :Runner, 'guard/calabash-ios/runner'
9
+
10
+ # Initialize a Guard.
11
+ # @param [Array<Guard::Watcher>] watchers the Guard file watchers
12
+ # @param [Hash] options the custom Guard options
13
+ def initialize(watchers = [], options = {})
14
+ super
15
+ @options = {
16
+ :all_on_start => true,
17
+ }.update(options)
18
+ end
19
+
20
+ # Call once when Guard starts. Please override initialize method to init stuff.
21
+ # @raise [:task_has_failed] when start has failed
22
+ def start
23
+ @runner = Runner.new @options
24
+ if @runner.nil?
25
+ @raise [:task_has_failed]
26
+ end
27
+ notify_start
28
+ run_all if @options[:all_on_start]
29
+ end
30
+
31
+ # Called when `stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).
32
+ # @raise [:task_has_failed] when stop has failed
33
+ def stop
34
+ end
35
+
36
+ # Called when `reload|r|z + enter` is pressed.
37
+ # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
38
+ # @raise [:task_has_failed] when reload has failed
39
+ def reload
40
+ end
41
+
42
+ # Called when just `enter` is pressed
43
+ # This method should be principally used for long action like running all specs/tests/...
44
+ # @raise [:task_has_failed] when run_all has failed
45
+ def run_all
46
+ run("features")
47
+ end
48
+
49
+ # Called on file(s) modifications that the Guard watches.
50
+ # @param [Array<String>] paths the changes files or paths
51
+ # @raise [:task_has_failed] when run_on_change has failed
52
+ def run_on_change(paths)
53
+ run(paths)
54
+ end
55
+
56
+ # Called on file(s) deletions that the Guard watches.
57
+ # @param [Array<String>] paths the deleted files or paths
58
+ # @raise [:task_has_failed] when run_on_change has failed
59
+ def run_on_deletion(paths)
60
+ end
61
+
62
+
63
+ private
64
+
65
+ def run(features)
66
+ if @runner.run(features)
67
+ notify_success
68
+ else
69
+ notify_failure
70
+ end
71
+ end
72
+
73
+ def notify_start
74
+ ::Guard::Notifier.notify 'Started successfully', :title => "Calabash-iOS", :image => :success
75
+ end
76
+
77
+ def notify_success
78
+ ::Guard::Notifier.notify 'Success', :title => "Calabash-iOS", :image => :success
79
+ end
80
+
81
+ def notify_failure
82
+ ::Guard::Notifier.notify 'Failed', :title => "Calabash-iOS", :image => :failed
83
+ end
84
+
85
+ end
86
+ end
87
+
@@ -0,0 +1,58 @@
1
+ module Guard
2
+ class Runner
3
+ attr_accessor :bundle_path
4
+ attr_accessor :sdk
5
+ attr_accessor :device
6
+ def initialize(options)
7
+ devices = [:iphone, :ipad]
8
+ sdks = [:ios4, :ios5]
9
+ if options[:project].nil?
10
+ project = Dir.glob("*.xcodeproj").first
11
+ if project
12
+ options[:project] = project.gsub(".xcodeproj","")
13
+ else
14
+ UI.info "You must specify project name at your Guardfile."
15
+ end
16
+ end
17
+ self.bundle_path = bundle(options)
18
+ self.sdk =:ios5
19
+ if sdks.include? options[:sdk]
20
+ self.sdk = options[:sdk]
21
+ end
22
+ self.device = :iphone
23
+ if devices.include? options[:device]
24
+ self.device = options[:device]
25
+ end
26
+ end
27
+
28
+ def run(features)
29
+ unless File.exists? self.bundle_path
30
+ UI.info "Could not run Calabash. \n'#{self.bundle_path}' not found."
31
+ return false
32
+ end
33
+ if features.eql?("features")
34
+ start_message = "Run all features"
35
+ else
36
+ features = features.join(' ') if features.kind_of? Array
37
+ start_message = "Run #{features}"
38
+ end
39
+ UI.info start_message
40
+ system(command(features))
41
+ end
42
+
43
+ def command(features)
44
+ if features.kind_of? Array
45
+ features = features.join(' ')
46
+ end
47
+ "APP_BUNDLE_PATH='#{self.bundle_path}' OS=#{self.sdk} DEVICE=#{self.device} cucumber #{features} --require features"
48
+ end
49
+
50
+ def bundle(options)
51
+ pwd = Dir::pwd
52
+ project = options[:project]
53
+ target = options[:target] || "frankified"
54
+ config = options[:config] || "Debug"
55
+ bundle_path = "#{pwd}/DerivedData/#{project}/Build/Products/#{config}-iphonesimulator/#{project}-cal.app"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,6 @@
1
+ guard 'calabash-ios', :sdk => :ios5, :device => :iphone do
2
+ watch(%r{^features/.+\.feature$})
3
+ watch(%r{^features/support/.+$}) { 'features' }
4
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
5
+ end
6
+
@@ -0,0 +1,6 @@
1
+ module Guard
2
+ module CalabashiOSVersion
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
6
+
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-calabash-ios
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Alex Denisov
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-08 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: guard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: calabash-cucumber
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ description: "Guard::Calabash-iOS automatically run your calabash features for iOS "
49
+ email:
50
+ - 1101.debian@gmail.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - lib/guard/calabash-ios/runner.rb
59
+ - lib/guard/calabash-ios/templates/Guardfile
60
+ - lib/guard/calabash-ios/version.rb
61
+ - lib/guard/calabash-ios.rb
62
+ - LICENSE
63
+ - README.md
64
+ homepage: https://github.com/AlexDenisov/guard-calabash-ios
65
+ licenses: []
66
+
67
+ post_install_message:
68
+ rdoc_options: []
69
+
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 57
78
+ segments:
79
+ - 1
80
+ - 8
81
+ - 7
82
+ version: 1.8.7
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 23
89
+ segments:
90
+ - 1
91
+ - 3
92
+ - 6
93
+ version: 1.3.6
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.19
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Guard gem for calabash-ios
101
+ test_files: []
102
+