Permalink
Browse files

Remove RSpec 1.x support

- some cleaning too
  • Loading branch information...
thibaudgg committed Sep 29, 2012
1 parent 49fef65 commit 31e1be02503c51ed37aeda486866550f7f8395d2
View
35 Gemfile
@@ -1,9 +1,36 @@
-source "http://rubygems.org"
+source :rubygems
gemspec
gem 'rake'
-gem 'ruby_gntp'
-platforms :ruby do
- gem 'rb-readline'
+gem 'listen', :github => 'guard/listen'
+
+# The development group will no be
+# installed on Travis CI.
+#
+group :development do
+
+ platform :ruby_19 do
+ gem 'coolline'
+ end
+
+ require 'rbconfig'
+
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
+ gem 'growl', :require => false
+ gem 'rb-fsevent', :require => false
+
+ if `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
+ gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
+ end rescue Errno::ENOENT
+
+ elsif RbConfig::CONFIG['target_os'] =~ /linux/i
+ gem 'libnotify', '~> 0.7.1', :require => false
+ gem 'rb-inotify', :require => false
+
+ elsif RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
+ gem 'win32console', :require => false
+ gem 'rb-notifu', '>= 0.0.4', :require => false
+ gem 'wdm', :require => false
+ end
end
View
@@ -1,4 +1,4 @@
-guard 'rspec', :version => 2 do
+guard 'rspec' do
watch(%r{^spec/.+_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
View
@@ -2,7 +2,7 @@
RSpec guard allows to automatically & intelligently launch specs when files are modified.
-* Compatible with RSpec 1.x & RSpec 2.x (>= 2.4 needed for the notification feature).
+* Compatible with RSpec >= 2.11 (use guard-rspec 1.2.x for older release, including RSpec 1.x)
* Tested against Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest versions of JRuby & Rubinius.
## Install
@@ -66,14 +66,6 @@ Please read [Guard doc](https://github.com/guard/guard#readme) for more informat
## Options
-By default, Guard::RSpec automatically detect your RSpec version (with the `spec_helper.rb` syntax or with Bundler) but you can force the version with the `:version` option:
-
-``` ruby
-guard 'rspec', :version => 2 do
- # ...
-end
-```
-
You can pass any of the standard RSpec CLI options using the `:cli` option:
``` ruby
@@ -116,7 +108,6 @@ Former `:color`, `:drb`, `:fail_fast` and `:formatter` options are deprecated an
### List of available options:
``` ruby
-:version => 1 # force use RSpec version 1, default: 2
:cli => "-c -f doc" # pass arbitrary RSpec CLI arguments, default: "-f progress"
:bundler => false # use "bundle exec" to run the RSpec command, default: true
:binstubs => true # use "bin/rspec" to run the RSpec command (takes precedence over :bundle), default: false
View
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.add_dependency 'guard', '>= 1.1'
s.add_dependency 'rspec', '~> 2.11'
- s.add_development_dependency 'bundler', '~> 1.0'
+ s.add_development_dependency 'bundler', '~> 1.2'
s.files = Dir.glob('{lib}/**/*') + %w[LICENSE README.md]
s.require_path = 'lib'
View
@@ -24,7 +24,7 @@ def initialize(watchers = [], options = {})
# Call once when guard starts
def start
- UI.info "Guard::RSpec is running, with RSpec #{@runner.rspec_version}!"
+ UI.info "Guard::RSpec is running"
run_all if @options[:all_on_start]
end
@@ -1,7 +1,14 @@
require "#{File.dirname(__FILE__)}/../rspec"
require 'guard/notifier'
+require "rspec/core/formatters/base_formatter"
-module Guard::RSpec::Formatter
+class Guard::RSpec::Formatter < RSpec::Core::Formatters::BaseFormatter
+
+ def dump_summary(duration, total, failures, pending)
+ message = guard_message(total, failures, pending, duration)
+ image = guard_image(failures, pending)
+ notify(message, image)
+ end
def guard_message(example_count, failure_count, pending_count, duration)
message = "#{example_count} examples, #{failure_count} failures"
@@ -1,13 +0,0 @@
-require "#{File.dirname(__FILE__)}/../formatter"
-require "rspec/core/formatters/base_formatter"
-
-class Guard::RSpec::Formatter::NotificationRSpec < RSpec::Core::Formatters::BaseFormatter
- include Guard::RSpec::Formatter
-
- def dump_summary(duration, total, failures, pending)
- message = guard_message(total, failures, pending, duration)
- image = guard_image(failures, pending)
- notify(message, image)
- end
-
-end
@@ -1,13 +0,0 @@
-require "#{File.dirname(__FILE__)}/../formatter"
-require "spec/runner/formatter/base_formatter"
-
-class Guard::RSpec::Formatter::NotificationSpec < Spec::Runner::Formatter::BaseFormatter
- include Guard::RSpec::Formatter
-
- def dump_summary(duration, total, failures, pending)
- message = guard_message(total, failures, pending, duration)
- image = guard_image(failures, pending)
- notify(message, image)
- end
-
-end
View
@@ -4,7 +4,6 @@
module Guard
class RSpec
class Runner
- attr_reader :rspec_version
FAILURE_EXIT_CODE = 2
@@ -37,15 +36,8 @@ def run(paths, options = {})
end
end
- def rspec_version
- @rspec_version ||= @options[:version] || determine_rspec_version
- end
-
def rspec_executable
- @rspec_executable ||= begin
- exec = rspec_class.downcase
- binstubs? ? "#{binstubs}/#{exec}" : exec
- end
+ @rspec_executable ||= binstubs? ? "#{binstubs}/rspec" : "rspec"
end
def failure_exit_code_supported?
@@ -58,15 +50,6 @@ def failure_exit_code_supported?
end
end
- def rspec_class
- @rspec_class ||= case rspec_version
- when 1
- "Spec"
- when 2
- "RSpec"
- end
- end
-
def parsed_or_default_formatter
@parsed_or_default_formatter ||= begin
# Use RSpec's parser to parse formatters
@@ -91,8 +74,8 @@ def rspec_arguments(paths, options)
arg_parts << options[:cli]
if @options[:notification]
arg_parts << parsed_or_default_formatter unless options[:cli] =~ formatter_regex
- arg_parts << "-r #{File.dirname(__FILE__)}/formatters/notification_#{rspec_class.downcase}.rb"
- arg_parts << "-f Guard::RSpec::Formatter::Notification#{rspec_class}#{rspec_version == 1 ? ":" : " --out "}/dev/null"
+ arg_parts << "-r #{File.dirname(__FILE__)}/formatter.rb"
+ arg_parts << "-f Guard::RSpec::Formatter --out /dev/null"
end
arg_parts << "--failure-exit-code #{FAILURE_EXIT_CODE}" if failure_exit_code_supported?
arg_parts << "-r turnip/rspec" if @options[:turnip]
@@ -145,20 +128,15 @@ def run_via_drb(paths, options)
end
def drb_used?
- if @drb_used.nil?
- @drb_used = @options[:cli] && @options[:cli].include?('--drb')
- else
- @drb_used
- end
+ @drb_used ||= @options[:cli] && @options[:cli].include?('--drb')
end
- # RSpec 1 & 2 use the same DRb call signature, and we can avoid loading a large chunk of rspec
+ # W we can avoid loading a large chunk of rspec
# just to let DRb know what to do.
#
# For reference:
#
- # * RSpec 1: https://github.com/myronmarston/rspec-1/blob/master/lib/spec/runner/drb_command_line.rb
- # * RSpec 2: https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/drb_command_line.rb
+ # * RSpec: https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/drb_command_line.rb
def drb_service(port)
require "drb/drb"
@@ -178,52 +156,25 @@ def drb_service(port)
end
def bundler_allowed?
- if @bundler_allowed.nil?
- @bundler_allowed = File.exist?("#{Dir.pwd}/Gemfile")
- else
- @bundler_allowed
- end
+ @bundler_allowed ||= File.exist?("#{Dir.pwd}/Gemfile")
end
def bundler?
- if @bundler.nil?
- @bundler = bundler_allowed? && @options[:bundler]
- else
- @bundler
- end
+ @bundler ||= bundler_allowed? && @options[:bundler]
end
def binstubs?
- if @binstubs.nil?
- @binstubs = !!@options[:binstubs]
- else
- @binstubs
- end
+ @binstubs ||= !!@options[:binstubs]
end
def binstubs
- if @options[:binstubs] == true
- "bin"
- else
- @options[:binstubs]
- end
+ @options[:binstubs] == true ? "bin" : @options[:binstubs]
end
def bundle_exec?
bundler? && !binstubs?
end
- def determine_rspec_version
- if File.exist?("#{Dir.pwd}/spec/spec_helper.rb")
- File.new("#{Dir.pwd}/spec/spec_helper.rb").read.include?("Spec::Runner") ? 1 : 2
- elsif bundler_allowed?
- ENV['BUNDLE_GEMFILE'] = "#{Dir.pwd}/Gemfile"
- `bundle show rspec`.include?("/rspec-1.") ? 1 : 2
- else
- 2
- end
- end
-
def deprecations_warnings
[:color, :drb, [:fail_fast, "fail-fast"], [:formatter, "format"]].each do |option|
key, value = option.is_a?(Array) ? option : [option, option.to_s]
@@ -232,6 +183,10 @@ def deprecations_warnings
UI.info %{DEPRECATION WARNING: The :#{key} option is deprecated. Pass standard command line argument "--#{value}" to RSpec with the :cli option.}
end
end
+ if @options.key?(:version)
+ @options.delete(:version)
+ UI.info %{DEPRECATION WARNING: The :version option is deprecated. Only RSpec 2 is now supported.}
+ end
end
def formatter_regex
@@ -1,4 +1,4 @@
-guard 'rspec', :version => 2 do
+guard 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
@@ -10,10 +10,10 @@ guard 'rspec', :version => 2 do
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
-
+
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
-
+
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
@@ -1,3 +0,0 @@
-source "http://rubygems.org"
-
-gem "rspec", "~> 1.3.1"
@@ -1,11 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- rspec (1.3.1)
-
-PLATFORMS
- java
- ruby
-
-DEPENDENCIES
- rspec (~> 1.3.1)
@@ -1,5 +0,0 @@
-source "http://rubygems.org"
-
-gem "rspec", "~> 1.3.1"
-gem "guard"
-gem "guard-rspec"
@@ -1,26 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- configuration (1.2.0)
- guard (0.3.0)
- open_gem (~> 1.4.2)
- thor (~> 0.14.6)
- guard-rspec (0.1.9)
- guard (>= 0.2.2)
- launchy (0.3.7)
- configuration (>= 0.0.5)
- rake (>= 0.8.1)
- open_gem (1.4.2)
- launchy (~> 0.3.5)
- rake (0.8.7)
- rspec (1.3.1)
- thor (0.14.6)
-
-PLATFORMS
- java
- ruby
-
-DEPENDENCIES
- guard
- guard-rspec
- rspec (~> 1.3.1)
@@ -1,5 +0,0 @@
-guard 'rspec', :version => 1 do
- watch(%r{^spec/.+_spec\.rb})
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
- watch('spec/spec_helper.rb') { "spec" }
-end
@@ -1,9 +0,0 @@
-require 'spec_helper'
-
-describe "Foo" do
-
- it "should be true" do
- true.should be_true
- end
-
-end
@@ -1,5 +0,0 @@
-require 'rubygems'
-require 'spec'
-
-Spec::Runner.configure do |config|
-end
@@ -1,7 +1,7 @@
require "#{File.dirname(__FILE__)}/../../../lib/guard/rspec/formatter"
describe Guard::RSpec::Formatter do
- subject { Class.new { include Guard::RSpec::Formatter }.new }
+ subject { Guard::RSpec::Formatter.new(StringIO.new) }
describe '#guard_message' do
context 'with a pending example' do
Oops, something went wrong.

0 comments on commit 31e1be0

Please sign in to comment.