Guardfile in rzo-0.3.0 vs Guardfile in rzo-0.4.0
- old
+ new
@@ -1,41 +1,56 @@
-# Note: The cmd option is now required due to the increasing number of ways
-# rspec may be run, below are examples of the most common uses.
-# * bundler: 'bundle exec rspec'
-# * bundler binstubs: 'bin/rspec'
-# * spring: 'bin/rspec' (This will use spring if running and you have
-# installed the spring binstubs per the docs)
-# * zeus: 'zeus rspec' (requires the server to be started separately)
-# * 'just' rspec: 'rspec'
-rspec_results = File.expand_path('.rspec_status')
-guard 'yard', server: false do
- watch(%r{app\/.+\.rb})
- watch(%r{lib\/.+\.rb})
- watch(%r{ext\/.+\.c})
+# Convert a lib path to a spec path
+def to_spec(path)
+ path.sub('lib/', 'spec/').sub(/\.rb$/, '_spec.rb')
end
+# guard 'yard', server: false do
+# watch(%r{app\/.+\.rb})
+# watch(%r{lib\/.+\.rb})
+# watch(%r{ext\/.+\.c})
+# end
+
guard :rubocop do
watch(/.+\.rb$/)
watch('Gemfile')
watch('Guardfile')
watch('Vagrantfile')
watch('rzo.gemspec')
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
end
-guard :rspec, cmd: 'bundle exec rspec', results_file: rspec_results do
+guard :shell do
require 'guard/rspec/dsl'
+ require 'pathname'
dsl = Guard::RSpec::Dsl.new(self)
+ runner = proc do |p|
+ if system("rspec -fd #{p}")
+ n 'Spec tests pass', 'rspec', :success
+ else
+ n 'Spec tests fail', 'rspec', :failed
+ end
+ nil
+ end
+
# Feel free to open issues for suggestions and improvements
# RSpec files
rspec = dsl.rspec
- watch(rspec.spec_helper) { rspec.spec_dir }
- watch(rspec.spec_support) { rspec.spec_dir }
- watch(rspec.spec_files)
+ watch(rspec.spec_helper) do |m|
+ runner.call(m[0])
+ end
+ watch(rspec.spec_support) do
+ runner.call(m[0])
+ end
+ watch rspec.spec_files do |m|
+ runner.call(m[0])
+ end
# Ruby files
ruby = dsl.ruby
- dsl.watch_spec_files_for(ruby.lib_files)
+ watch(ruby.lib_files) do |m|
+ spec = Pathname.new(to_spec(m[0]))
+ runner.call(spec.to_s) if spec.readable?
+ end
end
# vim:ft=ruby