guard-stendhal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use ruby-1.9.2@guard-stendhal
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in guard-stendhal.gemspec
4
+ gemspec
5
+
6
+ require 'rbconfig'
7
+
8
+ if Config::CONFIG['target_os'] =~ /darwin/i
9
+ gem 'rb-fsevent', '>= 0.3.2'
10
+ gem 'growl', '~> 1.0.3'
11
+ end
12
+ if Config::CONFIG['target_os'] =~ /linux/i
13
+ gem 'rb-inotify', '>= 0.5.1'
14
+ gem 'libnotify', '~> 0.1.3'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guard-stendhal (0.0.1)
5
+ guard (>= 0.2.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ configuration (1.1.0)
11
+ diff-lcs (1.1.2)
12
+ growl (1.0.3)
13
+ guard (0.2.2)
14
+ open_gem (~> 1.4.2)
15
+ thor (~> 0.14.3)
16
+ launchy (0.3.7)
17
+ configuration (>= 0.0.5)
18
+ rake (>= 0.8.1)
19
+ open_gem (1.4.2)
20
+ launchy (~> 0.3.5)
21
+ rake (0.8.7)
22
+ rb-fsevent (0.3.9)
23
+ rspec (2.1.0)
24
+ rspec-core (~> 2.1.0)
25
+ rspec-expectations (~> 2.1.0)
26
+ rspec-mocks (~> 2.1.0)
27
+ rspec-core (2.1.0)
28
+ rspec-expectations (2.1.0)
29
+ diff-lcs (~> 1.1.2)
30
+ rspec-mocks (2.1.0)
31
+ stendhal (0.1.9)
32
+ thor (0.14.4)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler (~> 1.0.3)
39
+ growl (~> 1.0.3)
40
+ guard (>= 0.2.0)
41
+ guard-stendhal!
42
+ rb-fsevent (>= 0.3.2)
43
+ rspec (~> 2.1.0)
44
+ stendhal (~> 0.1.9)
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :default => :spec
7
+
8
+ namespace(:spec) do
9
+ desc "Run all specs on multiple ruby versions (requires rvm)"
10
+ task(:portability) do
11
+ %w[1.8.6 1.8.7 1.9.2].each do |version|
12
+ system <<-BASH
13
+ bash -c 'source ~/.rvm/scripts/rvm;
14
+ rvm #{version};
15
+ echo "--------- version #{version} ----------\n";
16
+ bundle install;
17
+ rake spec:prepare_fixtures
18
+ rake spec'
19
+ BASH
20
+ end
21
+ end
22
+
23
+ desc "Run bundle install on each fixtures directories with Gemfile"
24
+ task(:prepare_fixtures) do
25
+ Dir.foreach("spec/fixtures") do |dir|
26
+ if File.exists?("spec/fixtures/#{dir}/Gemfile")
27
+ system <<-BASH
28
+ cd spec/fixtures/#{dir};
29
+ bundle install
30
+ BASH
31
+ end
32
+ end
33
+ end
34
+ end
data/Readme.rdoc ADDED
@@ -0,0 +1,77 @@
1
+ = Guard::Stendhal
2
+
3
+ Stendhal guard allows to automatically & intelligently launch specs using
4
+ stendhal when files are modified.
5
+
6
+ - Compatible with {stendhal}[http://github.com/txus/stendhal] 0.1.9 and above.
7
+ - Tested on Ruby 1.8.7 & 1.9.2.
8
+
9
+ == Install
10
+
11
+ Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
12
+
13
+ Install the gem:
14
+
15
+ gem install guard-stendhal
16
+
17
+ Add it to your Gemfile (inside test group):
18
+
19
+ gem 'guard-stendhal'
20
+
21
+ Add guard definition to your Guardfile by running this command:
22
+
23
+ guard init stendhal
24
+
25
+ == Usage
26
+
27
+ Please read {guard usage doc}[http://github.com/guard/guard#readme]
28
+
29
+ == Guardfile
30
+
31
+ Stendhal guard can be really be adapted to all kinds of projects.
32
+ Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
33
+
34
+ === Standard ruby gems
35
+
36
+ guard 'stendhal' do
37
+ watch('^spec/(.*)_spec.rb')
38
+ watch('^lib/(.*)\.rb') { |m| "spec/#{m[1]}_spec.rb" }
39
+ watch('^spec/spec_helper.rb') { "spec" }
40
+ end
41
+
42
+ === Rails app
43
+
44
+ guard 'stendhal' do
45
+ watch('^spec/(.*)_spec.rb')
46
+ watch('^app/(.*)\.rb') { |m| "spec/#{m[1]}_spec.rb" }
47
+ watch('^lib/(.*)\.rb') { |m| "spec/lib/#{m[1]}_spec.rb" }
48
+ watch('^spec/spec_helper.rb') { "spec" }
49
+ watch('^config/routes.rb') { "spec/routing" }
50
+ watch('^app/controllers/application_controller.rb') { "spec/controllers" }
51
+ watch('^spec/factories.rb') { "spec/models" }
52
+ end
53
+
54
+ == Options
55
+
56
+ :bundler => false # don't use "bundle exec"
57
+
58
+ == Development
59
+
60
+ - Source hosted at {GitHub}[http://github.com/txus/guard-stendhal]
61
+ - Report issues/Questions/Feature requests on {GitHub
62
+ Issues}[http://github.com/txus/guard-stendhal/issues]
63
+
64
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
65
+ you make.
66
+
67
+ === Testing
68
+
69
+ Please run "rake spec:prepare_fixtures" once before launching specs.
70
+
71
+ == Authors
72
+
73
+ {Txus (Josep M. Bach)}[http://github.com/txus]
74
+
75
+ Acknowledgements to {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg],
76
+ author of Guard :)
77
+
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "guard/stendhal/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "guard-stendhal"
7
+ s.version = Guard::StendhalVersion::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Josep M. Bach"]
10
+ s.email = ["josep.m.bach@gmail.com"]
11
+ s.homepage = "http://rubygems.org/gems/guard-stendhal"
12
+ s.summary = %q{Guard gem for Stendhal}
13
+ s.description = %q{Guard::Stendhal automatically runs your specs with stendhal}
14
+
15
+ s.required_rubygems_version = '>= 1.3.6'
16
+ s.rubyforge_project = "guard-stendhal"
17
+
18
+ s.add_dependency 'guard', '>= 0.2.0'
19
+
20
+ s.add_development_dependency 'bundler', '~> 1.0.3'
21
+ s.add_development_dependency 'rspec', '~> 2.1.0'
22
+ s.add_development_dependency 'stendhal', '~> 0.1.9'
23
+
24
+ s.files = `git ls-files`.split("\n")
25
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
+ s.require_paths = ["lib"]
28
+ end
@@ -0,0 +1,20 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class Stendhal < Guard
6
+
7
+ autoload :Runner, 'guard/stendhal/runner'
8
+ autoload :Inspector, 'guard/stendhal/inspector'
9
+
10
+ def run_all
11
+ Runner.run [""], options.merge(:message => "Running all specs")
12
+ end
13
+
14
+ def run_on_change(paths)
15
+ paths = Inspector.clean(paths)
16
+ Runner.run(paths, options) unless paths.empty?
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,41 @@
1
+ module Guard
2
+ class Stendhal
3
+ module Inspector
4
+ class << self
5
+
6
+ def clean(paths)
7
+ paths.uniq!
8
+ paths.compact!
9
+ paths = paths.select { |p| spec_file?(p) || spec_folder?(p) }
10
+ paths = paths.delete_if { |p| included_in_other_path?(p, paths) }
11
+ clear_spec_files_list
12
+ paths
13
+ end
14
+
15
+ private
16
+
17
+ def spec_folder?(path)
18
+ path.match(/^\/?spec/) && !path.match(/\..+$/)
19
+ end
20
+
21
+ def spec_file?(path)
22
+ spec_files.include?(path)
23
+ end
24
+
25
+ def spec_files
26
+ @spec_files ||= Dir.glob("spec/**/*_spec.rb")
27
+ end
28
+
29
+ def clear_spec_files_list
30
+ @spec_files = nil
31
+ end
32
+
33
+ def included_in_other_path?(path, paths)
34
+ paths = paths.select { |p| p != path }
35
+ paths.any? { |p| path.include?(p) && (path.gsub(p, '')).include?("/") }
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ module Guard
2
+ class Stendhal
3
+ module Runner
4
+ class << self
5
+
6
+ def run(paths, options = {})
7
+ message = options[:message] || "Running: #{paths.join(' ')}"
8
+ UI.info message, :reset => true
9
+ system(stendhal_command(paths, options))
10
+ end
11
+
12
+ private
13
+
14
+ def stendhal_command(paths, options = {})
15
+ cmd_parts = []
16
+ cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
17
+ cmd_parts << "stendhal"
18
+ cmd_parts << paths.join(' ')
19
+ cmd_parts.flatten.compact.reject(&:empty?).join(" ")
20
+ end
21
+
22
+ def bundler?
23
+ @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ guard 'stendhal' do
2
+ watch('^spec/(.*)_spec.rb')
3
+ watch('^lib/(.*)\.rb') { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('^spec/spec_helper.rb') { "spec" }
5
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module StendhalVersion
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rspec", "~> 2.0.0"
4
+ gem "guard"
5
+ gem "guard-stendhal"
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Stendhal::Inspector do
4
+ subject { Guard::Stendhal::Inspector }
5
+
6
+ describe "clean" do
7
+
8
+ it "should remove non-spec files" do
9
+ subject.clean(["spec/guard/stendhal_spec.rb", "bob.rb"]).should == ["spec/guard/stendhal_spec.rb"]
10
+ end
11
+
12
+ it "should remove non-spec existing files" do
13
+ subject.clean(["spec/guard/stendhal_spec.rb", "bob_spec.rb"]).should == ["spec/guard/stendhal_spec.rb"]
14
+ end
15
+
16
+ it "should remove non-spec existing files (2)" do
17
+ subject.clean(["spec/guard/stendhal/formatter_spec.rb"]).should == []
18
+ end
19
+
20
+ it "should keep spec folder path" do
21
+ subject.clean(["spec/guard/stendhal_spec.rb", "spec/models"]).should == ["spec/guard/stendhal_spec.rb", "spec/models"]
22
+ end
23
+
24
+ it "should remove duplication" do
25
+ subject.clean(["spec", "spec"]).should == ["spec"]
26
+ end
27
+
28
+ it "should remove spec folder includes in other spec folder" do
29
+ subject.clean(["spec/models", "spec"]).should == ["spec"]
30
+ end
31
+
32
+ it "should remove spec files includes in spec folder" do
33
+ subject.clean(["spec/guard/stendhal_spec.rb", "spec"]).should == ["spec"]
34
+ end
35
+
36
+ it "should remove spec files includes in spec folder (2)" do
37
+ subject.clean(["spec/guard/stendhal_spec.rb", "spec/guard/stendhal/runner_spec.rb", "spec/guard/stendhal"]).should == ["spec/guard/stendhal_spec.rb", "spec/guard/stendhal"]
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Stendhal::Runner do
4
+ subject { Guard::Stendhal::Runner }
5
+
6
+ describe "#run" do
7
+
8
+ context "in empty folder" do
9
+ before(:each) do
10
+ Dir.stub(:pwd).and_return(@fixture_path.join("empty"))
11
+ end
12
+
13
+ it "should run with Stendhal" do
14
+ subject.should_receive(:system).with(
15
+ "stendhal"
16
+ )
17
+ subject.run([""])
18
+ end
19
+
20
+ it "should run without bundler in spite of the option" do
21
+ subject.should_receive(:system).with(
22
+ "stendhal"
23
+ )
24
+ subject.run([""], :bundler => true)
25
+ end
26
+
27
+ it "should run without bundler" do
28
+ subject.should_receive(:system).with(
29
+ "stendhal"
30
+ )
31
+ subject.run([""], :bundler => false)
32
+ end
33
+ end
34
+
35
+ context "in a folder with a Gemfile" do
36
+ before(:each) do
37
+ Dir.stub(:pwd).and_return(@fixture_path.join("bundler"))
38
+ end
39
+
40
+ it "should run with Stendhal" do
41
+ subject.should_receive(:system).with(
42
+ "bundle exec stendhal"
43
+ )
44
+ subject.run([""])
45
+ end
46
+
47
+ it "should run with bundler argument" do
48
+ subject.should_receive(:system).with(
49
+ "bundle exec stendhal"
50
+ )
51
+ subject.run([""], :bundler => true)
52
+ end
53
+
54
+ it "should run without bundler" do
55
+ subject.should_receive(:system).with(
56
+ "stendhal"
57
+ )
58
+ subject.run([""], :bundler => false)
59
+ end
60
+ end
61
+ end
62
+
63
+
64
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Stendhal do
4
+ subject { Guard::Stendhal.new }
5
+
6
+ describe "run_all" do
7
+ it "runs all specs" do
8
+ Guard::Stendhal::Runner.should_receive(:run).with([""], :message => "Running all specs")
9
+ subject.run_all
10
+ end
11
+
12
+ it "should pass options to runner" do
13
+ subject = Guard::Stendhal.new([], { :bundler => false })
14
+ Guard::Stendhal::Runner.should_receive(:run).with([""], :message => "Running all specs", :bundler => false)
15
+ subject.run_all
16
+ end
17
+ end
18
+
19
+ describe "run_on_change" do
20
+ it "should run stendhal with paths" do
21
+ Guard::Stendhal::Runner.should_receive(:run).with(["spec"], {})
22
+ subject.run_on_change(["spec"])
23
+ end
24
+
25
+ it "should pass options to runner" do
26
+ subject = Guard::Stendhal.new([], { :bundler => false })
27
+ Guard::Stendhal::Runner.should_receive(:run).with(["spec"], :bundler => false)
28
+ subject.run_on_change(["spec"])
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,19 @@
1
+ require 'stendhal'
2
+ require 'guard/stendhal'
3
+
4
+ RSpec.configure do |config|
5
+ config.color_enabled = true
6
+ config.filter_run :focus => true
7
+ config.run_all_when_everything_filtered = true
8
+
9
+ config.before(:each) do
10
+ ENV["GUARD_ENV"] = 'test'
11
+ @fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__))
12
+ @lib_path = Pathname.new(File.expand_path('../../lib/', __FILE__))
13
+ end
14
+
15
+ config.after(:each) do
16
+ ENV["GUARD_ENV"] = nil
17
+ end
18
+
19
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-stendhal
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Josep M. Bach
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-15 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: guard
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 0
34
+ version: 0.2.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 17
46
+ segments:
47
+ - 1
48
+ - 0
49
+ - 3
50
+ version: 1.0.3
51
+ type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 11
62
+ segments:
63
+ - 2
64
+ - 1
65
+ - 0
66
+ version: 2.1.0
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: stendhal
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 9
78
+ segments:
79
+ - 0
80
+ - 1
81
+ - 9
82
+ version: 0.1.9
83
+ type: :development
84
+ version_requirements: *id004
85
+ description: Guard::Stendhal automatically runs your specs with stendhal
86
+ email:
87
+ - josep.m.bach@gmail.com
88
+ executables: []
89
+
90
+ extensions: []
91
+
92
+ extra_rdoc_files: []
93
+
94
+ files:
95
+ - .gitignore
96
+ - .rvmrc
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - Rakefile
100
+ - Readme.rdoc
101
+ - guard-stendhal.gemspec
102
+ - lib/guard/stendhal.rb
103
+ - lib/guard/stendhal/inspector.rb
104
+ - lib/guard/stendhal/runner.rb
105
+ - lib/guard/stendhal/templates/Guardfile
106
+ - lib/guard/stendhal/version.rb
107
+ - spec/fixtures/bundler/Gemfile
108
+ - spec/guard/stendhal/inspector_spec.rb
109
+ - spec/guard/stendhal/runner_spec.rb
110
+ - spec/guard/stendhal_spec.rb
111
+ - spec/spec_helper.rb
112
+ has_rdoc: true
113
+ homepage: http://rubygems.org/gems/guard-stendhal
114
+ licenses: []
115
+
116
+ post_install_message:
117
+ rdoc_options: []
118
+
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ hash: 23
136
+ segments:
137
+ - 1
138
+ - 3
139
+ - 6
140
+ version: 1.3.6
141
+ requirements: []
142
+
143
+ rubyforge_project: guard-stendhal
144
+ rubygems_version: 1.3.7
145
+ signing_key:
146
+ specification_version: 3
147
+ summary: Guard gem for Stendhal
148
+ test_files:
149
+ - spec/fixtures/bundler/Gemfile
150
+ - spec/guard/stendhal/inspector_spec.rb
151
+ - spec/guard/stendhal/runner_spec.rb
152
+ - spec/guard/stendhal_spec.rb
153
+ - spec/spec_helper.rb