guard-cedar 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ /tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format nested
2
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create ruby-1.9.3@guard-cedar
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ script: script/ci.sh
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - ruby-head
6
+ matrix:
7
+ allow_failures:
8
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem "gem-release"
7
+ gem "rb-fsevent"
8
+ end
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ guard 'bundler' do
4
+ watch('Gemfile')
5
+ watch(/^.+\.gemspec/)
6
+ end
7
+
8
+ guard 'rspec' do
9
+ watch(%r{^spec/.+_spec\.rb$})
10
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2013 Doc Ritezel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # Guard::Cedar [![Build Status](https://secure.travis-ci.org/ohrite/guard-cedar.png)](http://travis-ci.org/ohrite/guard-cedar) [![Dependency Status](https://gemnasium.com/ohrite/guard-cedar.png)](https://gemnasium.com/ohrite/guard-cedar) [![Code Climate](https://codeclimate.com/github/ohrite/guard-cedar.png)](https://codeclimate.com/github/ohrite/guard-cedar)
2
+
3
+ guard-cedar automatically recompiles your source and launches the Cedar spec runner application when files are modified.
4
+
5
+ Install
6
+ -------
7
+
8
+ Please be sure to have [Guard](https://github.com/guard/guard) installed before continue.
9
+
10
+ Install the gem:
11
+
12
+ ```
13
+ $ gem install guard-cedar
14
+ ```
15
+
16
+ Add it to your Gemfile (inside development group):
17
+
18
+ ``` ruby
19
+ group :development do
20
+ gem 'guard-cedar'
21
+ end
22
+ ```
23
+
24
+ Add guard definition to your Guardfile by running this command:
25
+
26
+ ```
27
+ $ guard init cedar
28
+ ```
29
+
30
+ You will need to edit the Guardfile
31
+
32
+ ``` ruby
33
+ guard 'cedar', :project_path => 'YourProject.xcodeproject', :target => 'YourSpecs' do
34
+ watch(%r{^YourSpecs/.+Spec\.mm$})
35
+ watch(%r{^YourProject/.+(\.m|\.h)$})
36
+ end
37
+ ```
38
+
39
+
40
+ Options
41
+ -------
42
+
43
+ By default, Guard::Cedar builds a Release configuration, which you can override with the :configuration option:
44
+
45
+ ``` ruby
46
+ guard 'cedar', :configuration => 'Debug' do
47
+ # ...
48
+ end
49
+ ```
50
+
51
+ Guard::Cedar can build against another version of the iOS SDK if you set the :sdk_version option:
52
+
53
+ ``` ruby
54
+ guard 'cedar', :sdk_version => '7.0' do
55
+ # ...
56
+ end
57
+ ```
58
+
59
+ If you want to set an environment variable, you can configure :env option with a hash:
60
+
61
+ ``` ruby
62
+ guard 'cedar', :env => {'CEDAR_REPORTER_OPTS' => 'nested'} do
63
+ # ...
64
+ end
65
+ ```
66
+
67
+
68
+ Usage
69
+ -----
70
+
71
+ Please read [Guard usage doc](https://github.com/guard/guard#readme)
72
+
73
+
74
+ Note on Patches/Pull Requests
75
+ -----------------------------
76
+
77
+ * Fork the project.
78
+ * Make your feature addition or bug fix.
79
+ * Send me a pull request. Bonus points for topic branches.
80
+
81
+
82
+ Thanks and Attribution
83
+ ----------------------
84
+
85
+ * [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) for guard-rspec
86
+ * [Adam Milligan](https://github.com/amilligan) for Cedar
87
+ * [Jonah Williams](https://github.com/jonah-carbonfive) for pairing
88
+
89
+
90
+ License
91
+ -------
92
+ See LICENSE for more information.
@@ -0,0 +1,23 @@
1
+ require File.expand_path("../lib/guard/cedar/version", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "guard-cedar"
5
+ s.version = Guard::CedarVersion::VERSION
6
+ s.platform = Gem::Platform::RUBY
7
+ s.homepage = "https://github.com/ohrite/guard-cedar"
8
+ s.authors = ["Doc Ritezel"]
9
+ s.email = "ritezel+guard-cedar@gmail.com"
10
+ s.summary = "Guard gem for Cedar."
11
+ s.description = "Guard::Cedar automatically runs your Cedar suite."
12
+
13
+ s.add_dependency "guard"
14
+
15
+ s.add_development_dependency "rspec"
16
+ s.add_development_dependency "guard-rspec"
17
+ s.add_development_dependency "guard-bundler"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- spec/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename( f ) }
22
+ s.require_path = "lib"
23
+ end
@@ -0,0 +1,32 @@
1
+ require "guard"
2
+ require "guard/guard"
3
+ require "guard/cedar/runner"
4
+
5
+ module ::Guard
6
+ class Cedar < ::Guard::Guard
7
+ attr_reader :options
8
+
9
+ def initialize(watchers=[], options={})
10
+ @options = options
11
+ super
12
+ end
13
+
14
+ def start
15
+ run_all if options[:all_on_start]
16
+ end
17
+
18
+ def run_all
19
+ runner.run
20
+ end
21
+
22
+ def run_on_changes(paths)
23
+ run_all
24
+ end
25
+
26
+ private
27
+ def runner
28
+ ::Guard::Cedar::Runner.new(options)
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,110 @@
1
+ require "guard/guard"
2
+
3
+ module Guard
4
+ class Cedar < ::Guard::Guard
5
+ class Runner
6
+ attr_reader :options
7
+
8
+ def initialize(options = {})
9
+ @options = options
10
+ end
11
+
12
+ def configuration
13
+ options[:configuration] || "Debug"
14
+ end
15
+
16
+ def sdk_version
17
+ options[:sdk_version] || "6.1"
18
+ end
19
+
20
+ def environment_options
21
+ options[:env] || {}
22
+ end
23
+
24
+ def target
25
+ options[:target]
26
+ end
27
+
28
+ def project_path
29
+ options[:project_path]
30
+ end
31
+
32
+ def run
33
+ return false unless compile
34
+ execute
35
+ end
36
+
37
+ def compile
38
+ system(
39
+ compile_command,
40
+ :out => "/dev/null"
41
+ )
42
+ end
43
+
44
+ def execute
45
+ system(
46
+ cedar_environment,
47
+ execute_command,
48
+ :unsetenv_others => true
49
+ )
50
+ end
51
+
52
+ private
53
+ def cedar_environment
54
+ environment_options.merge({
55
+ "DYLD_ROOT_PATH" => simulator_path,
56
+ "CFFIXED_USER_HOME" => Dir.tmpdir,
57
+ "CEDAR_HEADLESS_SPECS" => "1",
58
+ "CEDAR_REPORTER_CLASS" => "CDRColorizedReporter",
59
+ "IPHONE_SIMULATOR_ROOT" => simulator_path
60
+ })
61
+ end
62
+
63
+ def execute_command
64
+ [
65
+ cedar_app_path,
66
+ "-RegisterForSystemEvents"
67
+ ].join(" ")
68
+ end
69
+
70
+ def cedar_app_path
71
+ File.expand_path("#{target}.app/#{target}", configuration_path)
72
+ end
73
+
74
+ def configuration_path
75
+ File.expand_path("#{configuration}-iphonesimulator", build_path)
76
+ end
77
+
78
+ def build_path
79
+ File.expand_path("../build", project_path)
80
+ end
81
+
82
+ def compile_command
83
+ [
84
+ xcodebuild_path,
85
+ "-project #{project_path}",
86
+ "-target #{target}",
87
+ "-configuration #{configuration}",
88
+ "-sdk iphonesimulator",
89
+ "build"
90
+ ].join(" ")
91
+ end
92
+
93
+ def xcodebuild_path
94
+ `which xcodebuild`.strip
95
+ end
96
+
97
+ def xcode_developer_path
98
+ `xcode-select -print-path`.strip
99
+ end
100
+
101
+ def simulator_path
102
+ File.expand_path("iPhoneSimulator#{sdk_version}.sdk", simulator_base_path)
103
+ end
104
+
105
+ def simulator_base_path
106
+ File.expand_path("Platforms/iPhoneSimulator.platform/Developer/SDKs", xcode_developer_path)
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,6 @@
1
+ # Set :project_path to the location of your XCode project file
2
+ # Set :target to the name of the Cedar build target
3
+ guard 'cedar', :project_path => 'YourProject.xcodeproj', :target => 'YourSpecs' do
4
+ # watch(%r{^YourSpecs/.+Spec\.mm$})
5
+ # watch(%r{^YourProject/.+(\.m|\.h)$})
6
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module CedarVersion
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
data/script/ci.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rspec
@@ -0,0 +1,124 @@
1
+ require "spec_helper"
2
+
3
+ describe Guard::Cedar::Runner do
4
+ let(:options) do
5
+ {
6
+ project_path: "terrifying-sputum.xcodeproject",
7
+ target: "IMissRSpec"
8
+ }
9
+ end
10
+ let(:runner) { Guard::Cedar::Runner.new(options) }
11
+
12
+ describe "#configuration" do
13
+ it "returns Debug by default" do
14
+ runner.configuration.should == "Debug"
15
+ end
16
+
17
+ context "when the configuration option is set" do
18
+ before { options[:configuration] = "Release" }
19
+
20
+ it "returns Release" do
21
+ runner.configuration.should == "Release"
22
+ end
23
+ end
24
+ end
25
+
26
+ describe "#sdk_version" do
27
+ it "returns 6.1 by default" do
28
+ runner.sdk_version.should == "6.1"
29
+ end
30
+
31
+ context "when sdk_version is set" do
32
+ before { options[:sdk_version] = "0.1" }
33
+
34
+ it "returns the version" do
35
+ runner.sdk_version.should == "0.1"
36
+ end
37
+ end
38
+ end
39
+
40
+ describe "#run" do
41
+ before { runner.stub(compile: true, execute: true) }
42
+
43
+ it "compiles the code" do
44
+ runner.should_receive(:compile)
45
+ runner.run
46
+ end
47
+
48
+ it "executes the cedar app" do
49
+ runner.should_receive(:execute)
50
+ runner.run
51
+ end
52
+
53
+ context "when compilation fails" do
54
+ before { runner.stub(compile: false) }
55
+
56
+ it "does not execute the cedar app" do
57
+ runner.should_not_receive(:execute)
58
+ runner.run
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "#compile" do
64
+ it "runs xcodebuild" do
65
+ runner.should_receive(:system).with do |command, options|
66
+ command.should include "xcodebuild"
67
+ end
68
+ runner.compile
69
+ end
70
+
71
+ it "runs against the project" do
72
+ runner.should_receive(:system).with do |command, options|
73
+ command.should include " -project terrifying-sputum.xcodeproject "
74
+ end
75
+ runner.compile
76
+ end
77
+
78
+ it "runs against the target" do
79
+ runner.should_receive(:system).with do |command, options|
80
+ command.should include " -target IMissRSpec "
81
+ end
82
+ runner.compile
83
+ end
84
+ end
85
+
86
+ describe "#execute" do
87
+ it "runs the target app" do
88
+ runner.should_receive(:system).with do |env, command, options|
89
+ command.should include "IMissRSpec.app/IMissRSpec "
90
+ end
91
+ runner.execute
92
+ end
93
+
94
+ it "sets IPHONE_SIMULATOR_ROOT when running" do
95
+ runner.should_receive(:system).with do |env, command, options|
96
+ env["IPHONE_SIMULATOR_ROOT"].should =~ /iPhoneSimulator6.1/
97
+ end
98
+ runner.execute
99
+ end
100
+
101
+ context "with user-provided environment variables" do
102
+ before do
103
+ options[:env] = {
104
+ "PANTS" => "meh",
105
+ "CFFIXED_USER_HOME" => "/etc"
106
+ }
107
+ end
108
+
109
+ it "passes environment variables through" do
110
+ runner.should_receive(:system).with do |env, command, options|
111
+ env["PANTS"].should == "meh"
112
+ end
113
+ runner.execute
114
+ end
115
+
116
+ it "does not trample important settings" do
117
+ runner.should_receive(:system).with do |env, command, options|
118
+ env["CFFIXED_USER_HOME"].should == Dir.tmpdir
119
+ end
120
+ runner.execute
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Guard::Cedar do
4
+ let(:guard) { Guard::Cedar.new }
5
+
6
+ describe "#start" do
7
+ context "when all_on_start is set" do
8
+ before { guard.options[:all_on_start] = true }
9
+
10
+ it "runs all the specs" do
11
+ guard.should_receive(:run_all)
12
+ guard.start
13
+ end
14
+ end
15
+
16
+ context "when all_on_start is not set" do
17
+ before { guard.options[:all_on_start] = false }
18
+
19
+ it "runs all the specs" do
20
+ guard.should_not_receive(:run_all)
21
+ guard.start
22
+ end
23
+ end
24
+ end
25
+
26
+ describe "#run_on_changes" do
27
+ it "runs all the specs" do
28
+ guard.should_receive(:run_all)
29
+ guard.run_on_changes("monkey-butt")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ $:<< File.expand_path("../../lib", __FILE__)
2
+
3
+ require "guard/cedar"
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-cedar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Doc Ritezel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: guard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard-rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard-bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Guard::Cedar automatically runs your Cedar suite.
79
+ email: ritezel+guard-cedar@gmail.com
80
+ executables: []
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - .gitignore
85
+ - .rspec
86
+ - .rvmrc
87
+ - .travis.yml
88
+ - Gemfile
89
+ - Guardfile
90
+ - LICENSE
91
+ - README.md
92
+ - guard-cedar.gemspec
93
+ - lib/guard/cedar.rb
94
+ - lib/guard/cedar/runner.rb
95
+ - lib/guard/cedar/templates/Guardfile
96
+ - lib/guard/cedar/version.rb
97
+ - script/ci.sh
98
+ - spec/lib/guard/cedar/runner_spec.rb
99
+ - spec/lib/guard/cedar_spec.rb
100
+ - spec/spec_helper.rb
101
+ homepage: https://github.com/ohrite/guard-cedar
102
+ licenses: []
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.23
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Guard gem for Cedar.
125
+ test_files:
126
+ - spec/lib/guard/cedar/runner_spec.rb
127
+ - spec/lib/guard/cedar_spec.rb
128
+ - spec/spec_helper.rb