Skip to content
Browse files

Rename to Guard::RSpecRails

  • Loading branch information...
1 parent 850e69f commit e367f072a348003d52bca2e1a713e637230d2bed @netzpirat committed Sep 30, 2011
View
2 .yardopts
@@ -1,7 +1,7 @@
--readme README.md
--markup markdown
--markup-provider kramdown
---title 'Guard::RSpectacular Documentation'
+--title 'Guard::RSpecRails Documentation'
--hide-void-return
--protected
--private
View
2 Gemfile
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
-# Specify your gem's dependencies in guard-rspectacular.gemspec
+# Specify your gem's dependencies in guard-rspec_rails.gemspec
gemspec
gem 'rake'
View
12 README.md
@@ -1,6 +1,6 @@
-# Guard::RSpectacular [![Build Status](https://secure.travis-ci.org/netzpirat/guard-rspectacular.png)](http://travis-ci.org/netzpirat/guard-rspectacular)
+# Guard::RSpecRails [![Build Status](https://secure.travis-ci.org/netzpirat/guard-rspec-rails.png)](http://travis-ci.org/netzpirat/guard-rspec-rails)
-Guard::RSpectacular automatically tests your Rails application when files are modified.
+Guard::RSpecRails automatically tests your Rails application when files are modified.
Tested on MRI Ruby 1.8.7, 1.9.2, REE and the latest versions of JRuby & Rubinius.
@@ -9,21 +9,21 @@ If you have any questions please join us on our [Google group](http://groups.goo
## Install
-### Guard and Guard::RSpectacular
+### Guard and Guard::RSpecRails
Please be sure to have [Guard][] installed.
Install the gem:
- $ gem install guard-rspectacular
+ $ gem install guard-rspec-rails
Add it to your `Gemfile`, preferably inside the development group:
- gem 'guard-rspectacular'
+ gem 'guard-rspec-rails'
Add guard definition to your `Guardfile` by running this command:
- $ guard init rspectacular
+ $ guard init rspec-rails
## Usage
View
12 guard-rspectacular.gemspec → guard-rspec-rails.gemspec
@@ -1,21 +1,21 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path('../lib', __FILE__)
-require 'guard/rspectacular/version'
+require 'guard/rspec_rails/version'
Gem::Specification.new do |s|
- s.name = 'guard-rspectacular'
- s.version = Guard::RSpectacularVersion::VERSION
+ s.name = 'guard-rspec_rails'
+ s.version = Guard::RSpecRailsVersion::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Michael Kessler']
s.email = ['michi@netzpiraten.ch']
- s.homepage = 'http://github.com/netzpirat/guard-rspectacular'
+ s.homepage = 'http://github.com/netzpirat/guard-rspec_rails'
s.summary = 'Guard gem for fast Rails RSpec testing'
- s.description = 'Guard::Rspectacular automatically tests your Rails app with RSpec'
+ s.description = 'Guard::RSpecRails automatically tests your Rails app with RSpec'
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = 'guard-rspec'
- s.add_dependency 'guard', '>= 0.4'
+ s.add_dependency 'guard', '>= 0.8.0'
s.add_development_dependency 'bundler', '~> 1.0'
s.add_development_dependency 'guard-rspec', '~> 0.4'
View
45 lib/guard/rspectacular.rb → lib/guard/rspec_rails.rb
@@ -4,26 +4,29 @@
module Guard
- # The RSpectacular guard that gets notifications about the following
+ # The RSpecRails guard that gets notifications about the following
# Guard events: `start`, `stop`, `reload`, `run_all` and `run_on_change`.
#
- class RSpectacular < Guard
+ class RSpecRails < Guard
- autoload :Formatter, 'guard/rspectacular/formatter'
- autoload :Inspector, 'guard/rspectacular/inspector'
- autoload :Runner, 'guard/rspectacular/runner'
+ autoload :Formatter, 'guard/rspec_rails/formatter'
+ autoload :Inspector, 'guard/rspec_rails/inspector'
+ autoload :Runner, 'guard/rspec_rails/runner'
DEFAULT_OPTIONS = {
+ :cli => ''
}
- # Initialize Guard::RSpectacular.
+ # Initialize Guard::RSpecRails.
#
# @param [Array<Guard::Watcher>] watchers the watchers in the Guard block
# @param [Hash] options the options for the Guard
#
def initialize(watchers = [], options = { })
options = DEFAULT_OPTIONS.merge(options)
+ watchers << ::Guard::Watcher.new(%r{^.*$})
+
super(watchers, options)
end
@@ -32,6 +35,17 @@ def initialize(watchers = [], options = { })
# @return [Boolean] when the start was successful
#
def start
+ ENV['RAILS_ENV'] = 'test'
+
+ if File.exists?('config/application.rb')
+ Formatter.info 'Load Rails...'
+ require 'config/application'
+ end
+
+ Formatter.info 'Load RSpec...'
+ require 'spec/spec_helper'
+
+ Formatter.info 'RSpectacular ready!'
true
end
@@ -40,6 +54,8 @@ def start
# @return [Boolean] when the reload was successful
#
def reload
+ Dir.glob('**/*').each { |file| reload_file(file) }
+
true
end
@@ -57,8 +73,25 @@ def run_all
# @return [Boolean] when running the changed specs was successful
#
def run_on_change(paths)
+ paths.each { |path| reload_file(path) }
Runner.run(Inspector.clean(paths), options)
end
+ private
+
+ # Reloads the given file.
+ #
+ # @param [String] file the changed file
+ #
+ def reload_file(file)
+ return unless file =~ /\.rb$/
+
+ Formatter.info "Reload #{ file }"
+ load file
+
+ rescue Exception => e
+ Formatter.error "Error reloading file #{ file }: #{ e.message }"
+ end
+
end
end
View
2 lib/guard/rspectacular/formatter.rb → lib/guard/rspec_rails/formatter.rb
@@ -1,5 +1,5 @@
module Guard
- class RSpectacular
+ class RSpecRails
# The Guard::RSpectacular formatter collects console and
# system notification methods and enhances them with
View
2 lib/guard/rspectacular/inspector.rb → lib/guard/rspec_rails/inspector.rb
@@ -1,5 +1,5 @@
module Guard
- class RSpectacular
+ class RSpecRails
# The inspector verifies if the changed paths are valid
# for Guard::RSpectacular.
View
34 lib/guard/rspec_rails/runner.rb
@@ -0,0 +1,34 @@
+# coding: utf-8
+
+require 'rspec/core/runner'
+
+module Guard
+ class RSpecRails
+
+ autoload :Formatter, 'guard/rspec_rails/formatter'
+
+ # The RSpectacular runner handles the execution of the rspec test.
+ #
+ module Runner
+ class << self
+
+ # Run the supplied specs.
+ #
+ # @param [Array<String>] paths the spec files or directories
+ # @param [Hash] options the options for the Guard
+ #
+ def run(paths, options = {})
+ return false if paths.empty?
+
+ Formatter.info "Run #{ paths.join('') }"
+
+ RSpec::Core::Runner.run(paths)
+
+ rescue Exception => e
+ Formatter.error "Error while spec run: #{ e.message }"
+ end
+
+ end
+ end
+ end
+end
View
2 lib/guard/rspectacular/templates/Guardfile → lib/guard/rspec_rails/templates/Guardfile
@@ -1,4 +1,4 @@
-guard 'rspectacular' do
+guard 'rspec_rails' do
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
View
6 lib/guard/rspec_rails/version.rb
@@ -0,0 +1,6 @@
+module Guard
+ module RSpecRailsVersion
+ # Guard::Spec version that is used for the Gem specification
+ VERSION = '0.1.0'
+ end
+end
View
22 lib/guard/rspectacular/runner.rb
@@ -1,22 +0,0 @@
-# coding: utf-8
-
-module Guard
- class RSpectacular
-
- # The RSpectacular runner handles the execution of the rspec test.
- #
- module Runner
- class << self
-
- # Run the supplied specs.
- #
- # @param [Array<String>] paths the spec files or directories
- # @param [Hash] options the options for the Guard
- #
- def run(paths, options = { })
- end
-
- end
- end
- end
-end
View
6 lib/guard/rspectacular/version.rb
@@ -1,6 +0,0 @@
-module Guard
- module RSpectacularVersion
- # Guard::RSpectacular version that is used for the Gem specification
- VERSION = '0.1.0'
- end
-end
View
4 spec/guard/rspectacular/formatter_spec.rb → spec/guard/rspec_rails/formatter_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
-describe Guard::RSpectacular::Formatter do
+describe Guard::RSpecRails::Formatter do
- let(:formatter) { Guard::RSpectacular::Formatter }
+ let(:formatter) { Guard::RSpecRails::Formatter }
let(:ui) { Guard::UI }
let(:notifier) { Guard::Notifier }
View
4 spec/guard/rspectacular/inspector_spec.rb → spec/guard/rspec_rails/inspector_spec.rb
@@ -1,11 +1,11 @@
require 'spec_helper'
-describe Guard::RSpectacular::Inspector do
+describe Guard::RSpecRails::Inspector do
before do
Dir.stub(:glob).and_return ['spec/models/model_spec.rb', 'spec/constrollers/test_controller_spec.rb']
end
- subject { Guard::RSpectacular::Inspector }
+ subject { Guard::RSpecRails::Inspector }
describe 'clean' do
it 'allows the RSpec spec dir' do
View
12 spec/guard/rspec_rails/runner_spec.rb
@@ -0,0 +1,12 @@
+# coding: utf-8
+
+require 'spec_helper'
+
+describe Guard::RSpecRails::Runner do
+
+ let(:runner) { Guard::RSpecRails::Runner }
+
+ describe '#run' do
+ end
+
+end
View
9 spec/guard/rspec_rails/version_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe Guard::RSpecRails do
+ describe 'VERSION' do
+ it 'defines the version' do
+ Guard::RSpecRailsVersion::VERSION.should match /\d+.\d+.\d+/
+ end
+ end
+end
View
25 spec/guard/rspec_rails_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe Guard::RSpecRails do
+
+ let(:guard) { Guard::RSpecRails.new }
+
+ let(:runner) { Guard::RSpecRails::Runner }
+ let(:inspector) { Guard::RSpecRails::Inspector }
+ let(:formatter) { Guard::RSpecRails::Formatter }
+
+ let(:defaults) { Guard::RSpecRails::DEFAULT_OPTIONS }
+
+ describe '.start' do
+ end
+
+ describe '.reload' do
+ end
+
+ describe '.run_all' do
+ end
+
+ describe '.run_on_change' do
+ end
+
+end
View
12 spec/guard/rspectacular/runner_spec.rb
@@ -1,12 +0,0 @@
-# coding: utf-8
-
-require 'spec_helper'
-
-describe Guard::RSpectacular::Runner do
-
- let(:runner) { Guard::RSpectacular::Runner }
-
- describe '#run' do
- end
-
-end
View
9 spec/guard/rspectacular/version_spec.rb
@@ -1,9 +0,0 @@
-require 'spec_helper'
-
-describe Guard::RSpectacularVersion do
- describe 'VERSION' do
- it 'defines the version' do
- Guard::RSpectacularVersion::VERSION.should match /\d+.\d+.\d+/
- end
- end
-end
View
25 spec/guard/rspectacular_spec.rb
@@ -1,25 +0,0 @@
-require 'spec_helper'
-
-describe Guard::RSpectacular do
-
- let(:guard) { Guard::RSpectacular.new }
-
- let(:runner) { Guard::RSpectacular::Runner }
- let(:inspector) { Guard::RSpectacular::Inspector }
- let(:formatter) { Guard::RSpectacular::Formatter }
-
- let(:defaults) { Guard::RSpectacular::DEFAULT_OPTIONS }
-
- describe '.start' do
- end
-
- describe '.reload' do
- end
-
- describe '.run_all' do
- end
-
- describe '.run_on_change' do
- end
-
-end
View
6 spec/spec_helper.rb
@@ -1,5 +1,5 @@
require 'rspec'
-require 'guard/rspectacular'
+require 'guard/rspec_rails'
RSpec.configure do |config|
@@ -8,11 +8,11 @@
config.run_all_when_everything_filtered = true
config.before(:each) do
- ENV["GUARD_ENV"] = 'test'
+ ENV['GUARD_ENV'] = 'test'
@project_path = Pathname.new(File.expand_path('../../', __FILE__))
end
config.after(:each) do
- ENV["GUARD_ENV"] = nil
+ ENV['GUARD_ENV'] = nil
end
end

0 comments on commit e367f07

Please sign in to comment.
Something went wrong with that request. Please try again.