guard-spring 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 1fe8b01bf83d7011956e435e43a5001fcfd06068
4
+ data.tar.gz: 8b882c52f98b74009c9fd29482148661c17b0714
5
+ !binary "U0hBNTEy":
6
+ metadata.gz: 5886f5019146b9035245ab3c167e28a1237ee741b2144e682c65b43c868e0cea364c2b2280a57ec0e2f5fd135f8d56684ee34032a56f9c0331fdd062c431f5ae
7
+ data.tar.gz: e1c453e8ef97a78250d560da9fff3a2aaab706e9208b1d7af6a7ebd005d4b8616019a200d4c2c808bfac065c8a9dfc334f83ede7c1cc111699f58d93378d7636
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'guard/spring/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "guard-spring"
7
+ gem.name = 'guard-spring'
8
8
  gem.version = Guard::SpringVersion::VERSION
9
9
  gem.platform = Gem::Platform::RUBY
10
- gem.authors = ["Michał Knapik"]
11
- gem.email = ["mknapik@student.agh.edu.pl"]
10
+ gem.authors = ['Michał Knapik']
11
+ gem.email = ['mknapik@student.agh.edu.pl']
12
12
  gem.description = %q{Guard::Spring automatically runs tests with spring}
13
13
  gem.summary = %q{Pushes watched files to spring}
14
14
  gem.homepage = 'https://github.com/mknapik/guard-spring'
@@ -16,8 +16,12 @@ Gem::Specification.new do |gem|
16
16
  gem.files = `git ls-files`.split($/)
17
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ["lib"]
19
+ gem.require_paths = ['lib']
20
20
 
21
21
  gem.add_dependency 'guard'
22
22
  gem.add_dependency 'spring'
23
+
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency 'rake'
26
+ gem.add_development_dependency 'mocha'
23
27
  end
@@ -7,7 +7,7 @@ module Guard
7
7
 
8
8
  def initialize(options = {})
9
9
  @options = options
10
- create_bin_stubs %w(rspec)
10
+ @spring_cmd = get_spring_cmd
11
11
  UI.info 'Guard::Spring Initialized'
12
12
  end
13
13
 
@@ -23,7 +23,7 @@ module Guard
23
23
  def run(paths)
24
24
  existing_paths = paths.uniq.select { |path| File.exist? "#{Dir.pwd}/#{path}" }
25
25
  rspec_paths = existing_paths.select { |path| path =~ /spec(\/\w+)*(\/\w+_spec\.rb)?/ }
26
- run_command './bin/spring rspec', existing_paths.join(' ') unless rspec_paths.empty?
26
+ run_command "#@spring_cmd rspec", existing_paths.join(' ') unless rspec_paths.empty?
27
27
 
28
28
  # TBD: # testunit_paths = existing_paths.select { |path| path =~ /test(.*\.rb)?/ }
29
29
  # TBD: # run_command 'spring testunit', existing_paths.join(' ') unless testunit_paths.empty?
@@ -52,25 +52,34 @@ module Guard
52
52
  end
53
53
 
54
54
  def start_spring
55
- fork_exec('./bin/spring start > /dev/null')
55
+ fork_exec("#@spring_cmd start > /dev/null")
56
56
  end
57
57
 
58
58
  def stop_spring
59
- run_command('./bin/spring stop')
59
+ run_command("#@spring_cmd stop")
60
60
  UI.info 'Stopping Spring ', :reset => true
61
61
  end
62
62
 
63
63
  def push_command(paths)
64
64
  cmd_parts = []
65
- cmd_parts << './bin/spring rspec'
65
+ cmd_parts << "#@spring_cmd rspec"
66
66
  cmd_parts << paths.join(' ')
67
67
  cmd_parts.join(' ')
68
68
  end
69
69
 
70
+ def get_spring_cmd
71
+ return './bin/spring' if create_bin_stubs %w(rspec)
72
+
73
+ UI.warning('Failed to create all required binstubs')
74
+ 'spring'
75
+ end
76
+
77
+ # returns false if creation of any binstub failed
70
78
  def create_bin_stubs(stubs)
71
- stubs.each do |stub|
79
+ results = stubs.map do |stub|
72
80
  run_command 'spring binstub', stub unless File.exist? "#{Dir.pwd}/bin/#{stub}"
73
81
  end
82
+ results.empty? or results.all? { |result| result }
74
83
  end
75
84
 
76
85
  def bundler?
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  module SpringVersion
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
6
6
 
@@ -0,0 +1,238 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Spring do
4
+
5
+ describe 'bin exists and is writable' do
6
+ before do
7
+ Dir.mkdir 'bin' unless Dir.exist? 'bin'
8
+ end
9
+
10
+ after do
11
+ %w(rspec spring).each { |f| File.delete('bin/' + f) if File.exist?('bin/' + f) }
12
+ Dir.rmdir 'bin' if Dir.exist? 'bin'
13
+ end
14
+
15
+ it 'should create binstubs' do
16
+ cut = Guard::Spring.new
17
+ #cut.should_receive(:system).with('spring binstub rspec')
18
+ File.exist?('bin/rspec').should be_true
19
+ File.exist?('bin/spring').should be_true
20
+ end
21
+ end
22
+
23
+ describe 'bin exists and is writable' do
24
+ before do
25
+ %w(rspec spring).each { |f| File.delete('bin/' + f) if File.exist?('bin/' + f) }
26
+ Dir.rmdir 'bin' if Dir.exist? 'bin'
27
+ end
28
+
29
+ it 'should not create binstubs' do
30
+ cut = Guard::Spring.new
31
+ File.exist?('bin/rspec').should be_false
32
+ File.exist?('bin/spring').should be_false
33
+ end
34
+ end
35
+ # describe 'position' do
36
+ # it 'should use \'before\' position by default' do
37
+ # subject.options[:position].should == 'before'
38
+ # end
39
+ #
40
+ # it 'should allow user to customize position (before)' do
41
+ # subject = Guard::Spring.new( [], :position => 'before' )
42
+ # subject.options[:position].should == 'before'
43
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before')
44
+ # subject.start
45
+ # end
46
+ #
47
+ # it 'should allow user to customize position (after)' do
48
+ # subject = Guard::Spring.new( [], :position => 'after' )
49
+ # subject.options[:position].should == 'after'
50
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p after')
51
+ # subject.start
52
+ # end
53
+ # end
54
+ #
55
+ # describe 'routes' do
56
+ # it 'should not run routes by default' do
57
+ # subject.options[:routes].should be_false
58
+ # end
59
+ #
60
+ # it 'should allow the users to run routes if desired' do
61
+ # subject = Guard::Spring.new( [], :routes => true)
62
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before')
63
+ # subject.should_receive(:system).with('bundle exec Spring -r -p before')
64
+ # subject.start
65
+ # end
66
+ #
67
+ # it 'should allow the user to customize routes annotation position (before)' do
68
+ # subject = Guard::Spring.new( [], :routes => true, :position => 'before')
69
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before')
70
+ # subject.should_receive(:system).with('bundle exec Spring -r -p before')
71
+ # subject.start
72
+ # end
73
+ #
74
+ # it 'should allow the user to customize routes annotation position (after)' do
75
+ # subject = Guard::Spring.new( [], :routes => true, :position => 'after')
76
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p after')
77
+ # subject.should_receive(:system).with('bundle exec Spring -r -p after')
78
+ # subject.start
79
+ # end
80
+ # end
81
+ #
82
+ # describe 'tests & fixtures' do
83
+ # it 'should not run tests annotations by default' do
84
+ # subject.options[:tests].should be_false
85
+ # end
86
+ #
87
+ # it 'should allow user to run tests and fixtures annotations if desired' do
88
+ # subject = Guard::Spring.new( [], :tests => true )
89
+ # subject.should_receive(:system).with('bundle exec Spring -p before')
90
+ # subject.start
91
+ # end
92
+ # end
93
+ #
94
+ # describe 'indexes' do
95
+ # it 'should not add indexes to annotations by default' do
96
+ # subject.options[:show_indexes].should be_false
97
+ # end
98
+ #
99
+ # it 'should allow user to add indexes to annotations if desired' do
100
+ # subject = Guard::Spring.new( [], :show_indexes => true )
101
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before --show-indexes')
102
+ # subject.start
103
+ # end
104
+ # end
105
+ #
106
+ # describe 'simple indexes' do
107
+ # it 'should not add simple indexes to annotations by default' do
108
+ # subject.options[:simple_indexes].should be_false
109
+ # end
110
+ #
111
+ # it 'should allow user to add simple indexes to annotations if desired' do
112
+ # subject = Guard::Spring.new( [], :simple_indexes => true )
113
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before --simple-indexes')
114
+ # subject.start
115
+ # end
116
+ # end
117
+ #
118
+ # describe 'show migration' do
119
+ # it 'should not show migration version in annotations by default' do
120
+ # subject.options[:show_migration].should be_false
121
+ # end
122
+ #
123
+ # it 'should allow user to add migration version in annotations if desired' do
124
+ # subject = Guard::Spring.new( [], :show_migration => true )
125
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before --show-migration')
126
+ # subject.start
127
+ # end
128
+ # end
129
+ #
130
+ # describe 'annotation format' do
131
+ # it 'should not add format type to annotations by default' do
132
+ # subject.options[:show_migration].should be_false
133
+ # end
134
+ #
135
+ # describe 'invalid' do
136
+ # it 'should not add format type if option given is invalid' do
137
+ # subject = Guard::Spring.new( [], :format => :invalid_option)
138
+ # subject.options[:show_migration].should be_false
139
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before')
140
+ # subject.start
141
+ # end
142
+ # end
143
+ # describe 'bare' do
144
+ # it 'should allow user to choose format of annotations if desired' do
145
+ # subject = Guard::Spring.new( [], :format => :bare )
146
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before --format=bare')
147
+ # subject.start
148
+ # end
149
+ # end
150
+ # describe 'rdoc' do
151
+ # it 'should allow user to choose format of annotations if desired' do
152
+ # subject = Guard::Spring.new( [], :format => :rdoc )
153
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before --format=rdoc')
154
+ # subject.start
155
+ # end
156
+ # end
157
+ # describe 'markdown' do
158
+ # it 'should allow user to choose format of annotations if desired' do
159
+ # subject = Guard::Spring.new( [], :format => :markdown )
160
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before --format=markdown')
161
+ # subject.start
162
+ # end
163
+ # end
164
+ # end
165
+ #
166
+ # describe 'run_at_start' do
167
+ # it 'should run at start by default' do
168
+ # subject.options[:run_at_start].should be_true
169
+ # end
170
+ #
171
+ # it 'should allow user to opt out of running at start' do
172
+ # subject = Guard::Spring.new( [], :run_at_start => false)
173
+ # subject.options[:run_at_start].should be_false
174
+ # end
175
+ # end
176
+ #end
177
+ #
178
+ #context 'start' do
179
+ # it 'should run Spring command' do
180
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before')
181
+ # subject.start
182
+ # end
183
+ #
184
+ # it 'should return false if Spring command fails' do
185
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before').and_return(false)
186
+ # subject.start.should be_false
187
+ # end
188
+ #
189
+ # it 'should not run Spring command if disabled :run_at_start' do
190
+ # subject.should_not_receive(:system)
191
+ # subject.options[:run_at_start] = false
192
+ # subject.start
193
+ # end
194
+ #end
195
+ #
196
+ #context 'stop' do
197
+ # it 'should be a noop (return true)' do
198
+ # subject.stop.should be_true
199
+ # end
200
+ #end
201
+ #
202
+ #context 'reload' do
203
+ # it 'should run Spring command' do
204
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before')
205
+ # subject.reload
206
+ # end
207
+ #
208
+ # it 'should return false if Spring command fails' do
209
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before').and_return(false)
210
+ # subject.reload.should be_false
211
+ # end
212
+ #
213
+ # it 'should not run Spring command if disabled :run_at_start' do
214
+ # subject.should_not_receive(:system)
215
+ # subject.options[:run_at_start] = false
216
+ # subject.reload
217
+ # end
218
+ #end
219
+ #
220
+ #context 'run_all' do
221
+ # it 'should be a noop (return true)' do
222
+ # subject.run_all.should be_true
223
+ # end
224
+ #end
225
+ #
226
+ ## For Guard 1.1. #run_on_change is deprecated
227
+ #context 'run_on_changes' do
228
+ # it 'should run Spring command' do
229
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before')
230
+ # subject.run_on_changes
231
+ # end
232
+ #
233
+ # it 'should return false if Spring command fails' do
234
+ # subject.should_receive(:system).with('bundle exec Spring --exclude tests,fixtures -p before').and_return(false)
235
+ # subject.run_on_changes.should be_false
236
+ # end
237
+ #end
238
+ end
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require 'guard/spring'
3
+ require 'test/unit'
4
+ require 'mocha/setup'
5
+
6
+ Dir["#{File.expand_path('..', __FILE__)}/support/**/*.rb"].each { |f| require f }
7
+
8
+ RSpec.configure do |c|
9
+ c.color_enabled = true
10
+ c.filter_run :focus => true
11
+ c.run_all_when_everything_filtered = true
12
+
13
+ c.before( :each ) do
14
+ ENV['GUARD_ENV'] = 'test'
15
+ ::Guard::Notifier.stub( :notify ).and_return( true )
16
+ @lib_path = Pathname.new( File.expand_path( '../../lib/', __FILE__ ) )
17
+ end
18
+
19
+ c.after( :each ) do
20
+ ENV['GUARD_ENV'] = nil
21
+ end
22
+ end
metadata CHANGED
@@ -1,46 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-spring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michał Knapik
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-23 00:00:00.000000000 Z
11
+ date: 2013-04-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: guard
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: spring
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
44
81
  - !ruby/object:Gem::Version
45
82
  version: '0'
46
83
  description: Guard::Spring automatically runs tests with spring
@@ -50,7 +87,7 @@ executables: []
50
87
  extensions: []
51
88
  extra_rdoc_files: []
52
89
  files:
53
- - .gitignore
90
+ - ".gitignore"
54
91
  - Gemfile
55
92
  - LICENSE.txt
56
93
  - README.md
@@ -60,28 +97,31 @@ files:
60
97
  - lib/guard/spring/runner.rb
61
98
  - lib/guard/spring/templates/Guardfile
62
99
  - lib/guard/spring/version.rb
100
+ - spec/guard/spring_spec.rb
101
+ - spec/spec_helper.rb
63
102
  homepage: https://github.com/mknapik/guard-spring
64
103
  licenses: []
104
+ metadata: {}
65
105
  post_install_message:
66
106
  rdoc_options: []
67
107
  require_paths:
68
108
  - lib
69
109
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
110
  requirements:
72
- - - ! '>='
111
+ - - ">="
73
112
  - !ruby/object:Gem::Version
74
113
  version: '0'
75
114
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
115
  requirements:
78
- - - ! '>='
116
+ - - ">="
79
117
  - !ruby/object:Gem::Version
80
118
  version: '0'
81
119
  requirements: []
82
120
  rubyforge_project:
83
- rubygems_version: 1.8.25
121
+ rubygems_version: 2.0.3
84
122
  signing_key:
85
- specification_version: 3
123
+ specification_version: 4
86
124
  summary: Pushes watched files to spring
87
- test_files: []
125
+ test_files:
126
+ - spec/guard/spring_spec.rb
127
+ - spec/spec_helper.rb