Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-core
base: v2.6.1
...
head fork: rspec/rspec-core
compare: v2.6.3.beta1
Checking mergeability… Don't worry, you can still create the pull request.
  • 16 commits
  • 13 files changed
  • 1 commit comment
  • 4 contributors
View
3  Gemfile
@@ -10,9 +10,8 @@ source "http://rubygems.org"
end
end
-
### dev dependencies
-gem "rake", "0.8.7"
+gem "rake", "~> 0.8"
gem "cucumber", "~> 0.10.2"
gem "aruba", "~> 0.3.6"
gem "rcov", "0.9.9", :platforms => :mri
View
15 Rakefile
@@ -2,6 +2,20 @@ require "bundler"
Bundler.setup
Bundler::GemHelper.install_tasks
+task :build => :raise_if_psych_is_defined
+
+task :raise_if_psych_is_defined do
+ if defined?(Psych)
+ raise <<-MSG
+===============================================================================
+Gems compiled in Ruby environments with Psych loaded are incompatible with Ruby
+environments that don't have Psych loaded. Try building this gem in Ruby 1.8.7
+instead.
+===============================================================================
+MSG
+ end
+end
+
require "rake"
require "yaml"
@@ -10,6 +24,7 @@ require "rspec/core/rake_task"
require "rspec/core/version"
cucumber_loaded = false
+
begin
require "cucumber/rake/task"
View
17 features/Changelog.md
@@ -1,3 +1,20 @@
+### dev
+
+[full changelog](http://github.com/rspec/rspec-core/compare/v2.6.2...master)
+
+* Bug fixes
+ * Explicitly convert exit code to integer, avoiding TypeError when return
+ value of run is IO object proxied by DRb::DRbObject (Julian Scheid)
+
+
+### 2.6.2 / 2011-05-21
+
+[full changelog](http://github.com/rspec/rspec-core/compare/v2.6.1...v2.6.2)
+
+* Bug fixes
+ * Warn rather than raise when HOME env var is not defined
+ * Properly merge command-line exclusions with default :if and :unless (joshcooper)
+
### 2.6.1 / 2011-05-19
[full changelog](http://github.com/rspec/rspec-core/compare/v2.6.0...v2.6.1)
View
12 gem-info.txt
@@ -0,0 +1,12 @@
+build | read | status
+1.3.7 | 1.3.7 | ok
+1.3.7 | 1.6.2 | ok
+1.3.7 | 1.7.2 | ok
+1.3.7 | 1.8.3 | ok
+
+1.8.3 | 1.8.3 | ok
+1.8.3 | 1.7.2 | ok
+1.8.3 | 1.6.2 | ok
+1.8.3 | 1.3.7 | ok
+
+1.7.2
View
34 lib/rspec/core/configuration_options.rb
@@ -2,9 +2,6 @@ module RSpec
module Core
class ConfigurationOptions
- LOCAL_OPTIONS_FILE = ".rspec"
- GLOBAL_OPTIONS_FILE = File.join(File.expand_path("~"), ".rspec")
-
attr_reader :options
def initialize(args)
@@ -15,15 +12,16 @@ def configure(config)
keys = options.keys
keys.unshift(:requires) if keys.delete(:requires)
keys.unshift(:libs) if keys.delete(:libs)
+
formatters = options[:formatters] if keys.delete(:formatters)
+
+ config.exclusion_filter.merge! options[:exclusion_filter] if keys.delete(:exclusion_filter)
+
keys.each do |key|
config.send("#{key}=", options[key]) if config.respond_to?("#{key}=")
end
- if formatters
- formatters.each do |pair|
- config.add_formatter(*pair)
- end
- end
+
+ formatters.each {|pair| config.add_formatter(*pair) } if formatters
end
def drb_argv
@@ -79,11 +77,11 @@ def custom_options
end
def local_options
- @local_options ||= options_from(LOCAL_OPTIONS_FILE)
+ @local_options ||= options_from(local_options_file)
end
def global_options
- @global_options ||= options_from(GLOBAL_OPTIONS_FILE)
+ @global_options ||= options_from(global_options_file)
end
def options_from(path)
@@ -91,7 +89,7 @@ def options_from(path)
end
def args_from_options_file(path)
- return [] unless File.exist?(path)
+ return [] unless path && File.exist?(path)
config_string = options_file_as_erb_string(path)
config_string.split(/\n+/).map {|l| l.split}.flatten
end
@@ -104,6 +102,20 @@ def options_file_as_erb_string(path)
def custom_options_file
command_line_options[:custom_options_file]
end
+
+ def local_options_file
+ ".rspec"
+ end
+
+ def global_options_file
+ begin
+ File.join(File.expand_path("~"), ".rspec")
+ rescue ArgumentError
+ warn "Unable to find ~/.rspec because the HOME environment variable is not set"
+ nil
+ end
+ end
+
end
end
end
View
12 lib/rspec/core/formatters/base_formatter.rb
@@ -12,6 +12,13 @@ class BaseFormatter
attr_reader :example_count, :pending_count, :failure_count
attr_reader :failed_examples, :pending_examples
+ def self.relative_path(line)
+ line = line.sub(File.expand_path("."), ".")
+ line = line.sub(/\A([^:]+:\d+)$/, '\\1')
+ return nil if line == '-e:1'
+ line
+ end
+
def initialize(output)
@output = output || StringIO.new
@example_count = @pending_count = @failure_count = 0
@@ -113,10 +120,7 @@ def configuration
def backtrace_line(line)
return nil if configuration.cleaned_from_backtrace?(line)
- line = line.sub(File.expand_path("."), ".")
- line = line.sub(/\A([^:]+:\d+)$/, '\\1')
- return nil if line == '-e:1'
- line
+ self.class.relative_path(line)
end
def read_failed_line(exception, example)
View
12 lib/rspec/core/formatters/base_text_formatter.rb
@@ -39,6 +39,18 @@ def dump_summary(duration, example_count, failure_count, pending_count)
dump_profile if profile_examples? && failure_count == 0
output.puts "\nFinished in #{format_seconds(duration)} seconds\n"
output.puts colorise_summary(summary_line(example_count, failure_count, pending_count))
+ dump_commands_to_rerun_failed_examples
+ end
+
+ def dump_commands_to_rerun_failed_examples
+ return if failed_examples.empty?
+ output.puts
+ output.puts("Failed examples:")
+ output.puts
+
+ failed_examples.each do |example|
+ output.puts(red("rspec #{BaseFormatter::relative_path(example.location)}") + " " + grey("# #{example.full_description}"))
+ end
end
def dump_profile
View
3  lib/rspec/core/option_parser.rb
@@ -40,8 +40,7 @@ def parser(options)
options[:debug] = true
end
- parser.on('-e', '--example PATTERN', "Run examples whose full descriptions match this pattern",
- "(PATTERN is compiled into a Ruby regular expression)") do |o|
+ parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING") do |o|
options[:full_description] = Regexp.compile(Regexp.escape(o))
end
View
6 lib/rspec/core/reporter.rb
@@ -11,11 +11,11 @@ def report(count)
begin
yield self
ensure
- conclude
+ finish
end
end
- def conclude
+ def finish
begin
stop
notify :start_dump
@@ -27,7 +27,7 @@ def conclude
end
end
- alias_method :abort, :conclude
+ alias_method :abort, :finish
def start(expected_example_count)
@start = Time.now
View
2  lib/rspec/core/runner.rb
@@ -8,7 +8,7 @@ class Runner
def self.autorun
return if autorun_disabled? || installed_at_exit? || running_in_drb?
@installed_at_exit = true
- at_exit { exit(run(ARGV, $stderr, $stdout)) }
+ at_exit { exit(run(ARGV, $stderr, $stdout).to_i) }
end
AT_EXIT_HOOK_BACKTRACE_LINE = "#{__FILE__}:#{__LINE__ - 2}:in `autorun'"
View
2  lib/rspec/core/version.rb
@@ -1,7 +1,7 @@
module RSpec # :nodoc:
module Core # :nodoc:
module Version # :nodoc:
- STRING = '2.6.1'
+ STRING = '2.6.3.beta1'
end
end
end
View
37 spec/rspec/core/configuration_options_spec.rb
@@ -14,6 +14,17 @@ def parse_options(*args)
config_options_object(*args).options
end
+ it "warns when HOME env var is not set" do
+ begin
+ orig_home = ENV.delete("HOME")
+ coo = RSpec::Core::ConfigurationOptions.new([])
+ coo.should_receive(:warn)
+ coo.parse_options
+ ensure
+ ENV["HOME"] = orig_home
+ end
+ end
+
describe "#configure" do
it "sends libs before requires" do
opts = config_options_object(*%w[--require a/path -I a/lib])
@@ -30,6 +41,13 @@ def parse_options(*args)
config.should_receive(:add_formatter).ordered
opts.configure(config)
end
+
+ it "merges the :exclusion_filter option with the default exclusion_filter" do
+ opts = config_options_object(*%w[--tag ~slow])
+ config = RSpec::Core::Configuration.new
+ opts.configure(config)
+ config.exclusion_filter.should have_key(:slow)
+ end
end
describe "-c, --color, and --colour" do
@@ -279,23 +297,16 @@ def parse_options(*args)
before do
@orig_spec_opts = ENV["SPEC_OPTS"]
- @orig_global_options_file = RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE
- @orig_local_options_file = RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :GLOBAL_OPTIONS_FILE
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :LOCAL_OPTIONS_FILE
- RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE = global_options_file
- RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE = local_options_file
- FileUtils.rm local_options_file if File.exist? local_options_file
- FileUtils.rm global_options_file if File.exist? global_options_file
- FileUtils.rm custom_options_file if File.exist? custom_options_file
+ RSpec::Core::ConfigurationOptions::send :public, :global_options_file
+ RSpec::Core::ConfigurationOptions::send :public, :local_options_file
+ RSpec::Core::ConfigurationOptions::any_instance.stub(:global_options_file) { global_options_file }
+ RSpec::Core::ConfigurationOptions::any_instance.stub(:local_options_file) { local_options_file }
end
after do
ENV["SPEC_OPTS"] = @orig_spec_opts
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :GLOBAL_OPTIONS_FILE
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :LOCAL_OPTIONS_FILE
- RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE = @orig_global_options_file
- RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE = @orig_local_options_file
+ RSpec::Core::ConfigurationOptions::send :private, :global_options_file
+ RSpec::Core::ConfigurationOptions::send :private, :local_options_file
end
def write_options(scope, options)
View
249 spec/rspec/core/formatters/base_text_formatter_spec.rb
@@ -1,89 +1,112 @@
require 'spec_helper'
require 'rspec/core/formatters/base_text_formatter'
-module RSpec::Core::Formatters
+describe RSpec::Core::Formatters::BaseTextFormatter do
+ let(:output) { StringIO.new }
+ let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) }
- describe BaseTextFormatter do
- let(:output) { StringIO.new }
- let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) }
+ describe "#summary_line" do
+ it "with 0s outputs pluralized (excluding pending)" do
+ formatter.summary_line(0,0,0).should eq("0 examples, 0 failures")
+ end
- describe "#summary_line" do
- context "with 0s" do
- it "outputs pluralized (excluding pending)" do
- formatter.summary_line(0,0,0).should eq("0 examples, 0 failures")
- end
- end
+ it "with 1s outputs singular (including pending)" do
+ formatter.summary_line(1,1,1).should eq("1 example, 1 failure, 1 pending")
+ end
- context "with 1s" do
- it "outputs singular (including pending)" do
- formatter.summary_line(1,1,1).should eq("1 example, 1 failure, 1 pending")
- end
- end
+ it "with 2s outputs pluralized (including pending)" do
+ formatter.summary_line(2,2,2).should eq("2 examples, 2 failures, 2 pending")
+ end
+ end
- context "with 2s" do
- it "outputs pluralized (including pending)" do
- formatter.summary_line(2,2,2).should eq("2 examples, 2 failures, 2 pending")
- end
+ describe "#dump_commands_to_rerun_failed_examples" do
+ it "includes command to re-run each failed example" do
+ group = RSpec::Core::ExampleGroup.describe("example group") do
+ it("fails") { fail }
end
+ line = __LINE__ - 2
+ group.run(formatter)
+ formatter.dump_commands_to_rerun_failed_examples
+ output.string.should include("rspec #{RSpec::Core::Formatters::BaseFormatter::relative_path("#{__FILE__}:#{line}")} # example group fails")
end
+ end
- describe "#dump_failures" do
- let(:group) { RSpec::Core::ExampleGroup.describe("group name") }
+ describe "#dump_failures" do
+ let(:group) { RSpec::Core::ExampleGroup.describe("group name") }
- before { RSpec.configuration.stub(:color_enabled?) { false } }
+ before { RSpec.configuration.stub(:color_enabled?) { false } }
- def run_all_and_dump_failures
- group.run(formatter)
- formatter.dump_failures
- end
+ def run_all_and_dump_failures
+ group.run(formatter)
+ formatter.dump_failures
+ end
- it "preserves formatting" do
- group.example("example name") { "this".should eq("that") }
+ it "preserves formatting" do
+ group.example("example name") { "this".should eq("that") }
- run_all_and_dump_failures
+ run_all_and_dump_failures
+
+ output.string.should =~ /group name example name/m
+ output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
+ end
- output.string.should =~ /group name example name/m
- output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
+ context "with an exception without a message" do
+ it "does not throw NoMethodError" do
+ exception_without_message = Exception.new()
+ exception_without_message.stub(:message) { nil }
+ group.example("example name") { raise exception_without_message }
+ expect { run_all_and_dump_failures }.not_to raise_error(NoMethodError)
end
+ end
- context "with an exception without a message" do
- it "does not throw NoMethodError" do
- exception_without_message = Exception.new()
- exception_without_message.stub(:message) { nil }
- group.example("example name") { raise exception_without_message }
- expect { run_all_and_dump_failures }.not_to raise_error(NoMethodError)
- end
+ context "with an exception class other than RSpec" do
+ it "does not show the error class" do
+ group.example("example name") { raise NameError.new('foo') }
+ run_all_and_dump_failures
+ output.string.should =~ /NameError/m
end
+ end
- context "with an exception class other than RSpec" do
- it "does not show the error class" do
- group.example("example name") { raise NameError.new('foo') }
- run_all_and_dump_failures
- output.string.should =~ /NameError/m
- end
+ context "with a failed expectation (rspec-expectations)" do
+ it "does not show the error class" do
+ group.example("example name") { "this".should eq("that") }
+ run_all_and_dump_failures
+ output.string.should_not =~ /RSpec/m
end
+ end
- context "with a failed expectation (rspec-expectations)" do
- it "does not show the error class" do
- group.example("example name") { "this".should eq("that") }
- run_all_and_dump_failures
- output.string.should_not =~ /RSpec/m
- end
+ context "with a failed message expectation (rspec-mocks)" do
+ it "does not show the error class" do
+ group.example("example name") { "this".should_receive("that") }
+ run_all_and_dump_failures
+ output.string.should_not =~ /RSpec/m
end
+ end
- context "with a failed message expectation (rspec-mocks)" do
- it "does not show the error class" do
- group.example("example name") { "this".should_receive("that") }
- run_all_and_dump_failures
- output.string.should_not =~ /RSpec/m
+ context 'for #share_examples_for' do
+ it 'outputs the name and location' do
+
+ share_examples_for 'foo bar' do
+ it("example name") { "this".should eq("that") }
end
+
+ line = __LINE__.next
+ group.it_should_behave_like('foo bar')
+
+ run_all_and_dump_failures
+
+ output.string.should include(
+ 'Shared Example Group: "foo bar" called from ' +
+ "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
+ )
end
- context 'for #share_examples_for' do
+ context 'that contains nested example groups' do
it 'outputs the name and location' do
-
share_examples_for 'foo bar' do
- it("example name") { "this".should eq("that") }
+ describe 'nested group' do
+ it("example name") { "this".should eq("that") }
+ end
end
line = __LINE__.next
@@ -96,98 +119,78 @@ def run_all_and_dump_failures
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
)
end
+ end
+ end
- context 'that contains nested example groups' do
- it 'outputs the name and location' do
- share_examples_for 'foo bar' do
- describe 'nested group' do
- it("example name") { "this".should eq("that") }
- end
- end
+ context 'for #share_as' do
+ it 'outputs the name and location' do
- line = __LINE__.next
- group.it_should_behave_like('foo bar')
+ share_as :FooBar do
+ it("example name") { "this".should eq("that") }
+ end
- run_all_and_dump_failures
+ line = __LINE__.next
+ group.send(:include, FooBar)
- output.string.should include(
- 'Shared Example Group: "foo bar" called from ' +
- "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
- )
- end
- end
+ run_all_and_dump_failures
+
+ output.string.should include(
+ 'Shared Example Group: "FooBar" called from ' +
+ "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
+ )
end
- context 'for #share_as' do
+ context 'that contains nested example groups' do
it 'outputs the name and location' do
- share_as :FooBar do
- it("example name") { "this".should eq("that") }
+ share_as :NestedFoo do
+ describe 'nested group' do
+ describe 'hell' do
+ it("example name") { "this".should eq("that") }
+ end
+ end
end
line = __LINE__.next
- group.send(:include, FooBar)
+ group.send(:include, NestedFoo)
run_all_and_dump_failures
output.string.should include(
- 'Shared Example Group: "FooBar" called from ' +
+ 'Shared Example Group: "NestedFoo" called from ' +
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
)
end
-
- context 'that contains nested example groups' do
- it 'outputs the name and location' do
-
- share_as :NestedFoo do
- describe 'nested group' do
- describe 'hell' do
- it("example name") { "this".should eq("that") }
- end
- end
- end
-
- line = __LINE__.next
- group.send(:include, NestedFoo)
-
- run_all_and_dump_failures
-
- output.string.should include(
- 'Shared Example Group: "NestedFoo" called from ' +
- "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
- )
- end
- end
end
end
+ end
- describe "#dump_profile" do
- before do
- formatter.stub(:examples) do
- group = RSpec::Core::ExampleGroup.describe("group") do
- example("example")
- end
- group.run(double('reporter').as_null_object)
- group.examples
+ describe "#dump_profile" do
+ before do
+ formatter.stub(:examples) do
+ group = RSpec::Core::ExampleGroup.describe("group") do
+ example("example")
end
+ group.run(double('reporter').as_null_object)
+ group.examples
end
+ end
- it "names the example" do
- formatter.dump_profile
- output.string.should =~ /group example/m
- end
+ it "names the example" do
+ formatter.dump_profile
+ output.string.should =~ /group example/m
+ end
- it "prints the time" do
- formatter.dump_profile
- output.string.should =~ /0(\.\d+)? seconds/
- end
+ it "prints the time" do
+ formatter.dump_profile
+ output.string.should =~ /0(\.\d+)? seconds/
+ end
- it "prints the path" do
- formatter.dump_profile
- filename = __FILE__.split(File::SEPARATOR).last
+ it "prints the path" do
+ formatter.dump_profile
+ filename = __FILE__.split(File::SEPARATOR).last
- output.string.should =~ /#{filename}\:#{__LINE__ - 21}/
- end
+ output.string.should =~ /#{filename}\:#{__LINE__ - 21}/
end
end
end

Showing you all comments on commits in this comparison.

@justinko

Noted.

Something went wrong with that request. Please try again.