Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: rspec/rspec-core
base: v2.11.0
...
head fork: rspec/rspec-core
compare: v2.11.1
  • 6 commits
  • 10 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jul 18, 2012
Myron Marston myronmarston Fix ruby warnings.
- lib/rspec/core/shared_example_group.rb:41: warning: `&' interpreted as argument prefix
- spec/rspec/core/configuration_spec.rb:86: warning: ambiguous first argument; put parentheses or even spaces
- spec/rspec/core/configuration_spec.rb:182: warning: ambiguous first argument; put parentheses or even spaces
- spec/rspec/core/option_parser_spec.rb:71: warning: possibly useless use of == in void context

Closes #645.
1f78187
Jo Liss joliss Fix typo
This used to be a multi-line string with "',\n    '" in it.
e75df2c
Myron Marston myronmarston Fix the way we autoload RSpec::Matchers.
`autoload`, besides being deprecated by Matz, does not work to require files
that are in unactivated gems--it only works with ruby's built in require, for
files that are available relative to a directory on the load path. Instead,
we use `const_missing` to make it work.

Closes #647.
2e32d6e
Myron Marston myronmarston Update change log. c2ea08c
Myron Marston myronmarston Ignore mock expectation failures when the example has already failed.
Mock expectation failures have always been ignored in this situation,
but due to my changes in 27059bf it was printing a confusing message.

Closes #651.
30e81b5
Commits on Jul 19, 2012
Myron Marston myronmarston 2.11.1 release. b819726
15 Changelog.md
View
@@ -1,3 +1,18 @@
+### 2.11.1 / 2012-07-18
+[full changelog](http://github.com/rspec/rspec-core/compare/v2.11.0...v2.11.1)
+
+Bug fixes
+
+* Fix the way we autoload RSpec::Matchers so that custom matchers can be
+ defined before rspec-core has been configured to definitely use
+ rspec-expectations. (Myron Marston)
+* Fix typo in --help message printed for -e option. (Jo Liss)
+* Fix ruby warnings. (Myron Marston)
+* Ignore mock expectation failures when the example has already failed.
+ Mock expectation failures have always been ignored in this situation,
+ but due to my changes in 27059bf1 it was printing a confusing message.
+ (Myron Marston).
+
### 2.11.0 / 2012-07-07
[full changelog](http://github.com/rspec/rspec-core/compare/v2.10.1...v2.11.0)
16 features/expectation_framework_integration/configure_expectation_framework.feature
View
@@ -13,6 +13,22 @@ Feature: configure expectation framework
provide a description to every example. You cannot rely on the generated
descriptions provided by rspec-expectations.
+ Scenario: rspec-expectations can be used by default if nothing is configured
+ Given a file named "example_spec.rb" with:
+ """
+ RSpec::Matchers.define :be_a_multiple_of do |factor|
+ match do |actual|
+ actual % factor == 0
+ end
+ end
+
+ describe 6 do
+ it { should be_a_multiple_of(3) }
+ end
+ """
+ When I run `rspec example_spec.rb`
+ Then the examples should all pass
+
Scenario: configure rspec-expectations (explicitly)
Given a file named "example_spec.rb" with:
"""
17 lib/rspec/core.rb
View
@@ -40,7 +40,6 @@ def require_rspec(path)
require_rspec 'core/version'
module RSpec
- autoload :Matchers, 'rspec/matchers'
autoload :SharedContext, 'rspec/core/shared_context'
# @private
@@ -106,6 +105,22 @@ def self.windows_os?
module Core
end
+
+ def self.const_missing(name)
+ case name
+ when :Matchers
+ # Load rspec-expectations when RSpec::Matchers is referenced. This allows
+ # people to define custom matchers (using `RSpec::Matchers.define`) before
+ # rspec-core has loaded rspec-expectations (since it delays the loading of
+ # it to allow users to configure a different assertion/expectation
+ # framework). `autoload` can't be used since it works with ruby's built-in
+ # require (e.g. for files that are available relative to a load path dir),
+ # but not with rubygems' extended require.
+ require 'rspec/expectations'
+ ::RSpec::Matchers
+ else super
+ end
+ end
end
require_rspec 'core/backward_compatibility'
10 lib/rspec/core/example.rb
View
@@ -205,7 +205,7 @@ def around_each_hooks
# Used internally to set an exception in an after hook, which
# captures the exception but doesn't raise it.
def set_exception(exception, context=nil)
- if @exception
+ if @exception && context != :dont_print
# An error has already been set; we don't want to override it,
# but we also don't want silence the error, so let's print it.
msg = <<-EOS
@@ -301,13 +301,19 @@ def run_before_each
def run_after_each
@example_group_class.run_after_each_hooks(self)
- @example_group_instance.verify_mocks_for_rspec
+ verify_mocks
rescue Exception => e
set_exception(e, "in an after(:each) hook")
ensure
@example_group_instance.teardown_mocks_for_rspec
end
+ def verify_mocks
+ @example_group_instance.verify_mocks_for_rspec
+ rescue Exception => e
+ set_exception(e, :dont_print)
+ end
+
def assign_generated_description
return unless RSpec.configuration.expecting_with_rspec?
if metadata[:description].empty? and !pending?
4 lib/rspec/core/option_parser.rb
View
@@ -134,8 +134,8 @@ def parser(options)
options[:pattern] = o
end
- parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING (may be',
- ' used more than once)") do |o|
+ parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING (may be",
+ " used more than once)") do |o|
(options[:full_description] ||= []) << Regexp.compile(Regexp.escape(o))
end
2  lib/rspec/core/shared_example_group.rb
View
@@ -38,7 +38,7 @@ def shared_examples *args, &block
unless args.empty?
mod = Module.new
(class << mod; self; end).send :define_method, :extended do |host|
- host.class_eval &block
+ host.class_eval(&block)
end
RSpec.configuration.extend mod, *args
end
2  lib/rspec/core/version.rb
View
@@ -1,7 +1,7 @@
module RSpec
module Core
module Version
- STRING = '2.11.0'
+ STRING = '2.11.1'
end
end
end
4 spec/rspec/core/configuration_spec.rb
View
@@ -83,7 +83,7 @@ module RSpec::Core
lambda do
config.send m, mod do |mod_config|
end
- end.should raise_error /must respond to `configuration`/
+ end.should raise_error(/must respond to `configuration`/)
end
end
@@ -179,7 +179,7 @@ module RSpec::Core
lambda do
config.expect_with :rspec, :stdlib do |mod_config|
end
- end.should raise_error /expect_with only accepts/
+ end.should raise_error(/expect_with only accepts/)
end
it "raises ArgumentError if framework is not supported" do
47 spec/rspec/core/example_spec.rb
View
@@ -259,37 +259,48 @@ def assert(val)
end
end
- context "when the example and an around hook raise errors" do
- it "prints the around hook error rather than silencing it" do
- group = RSpec::Core::ExampleGroup.describe do
- around(:each) { |e| e.run; raise "around" }
- example("e") { raise "example" }
- end
-
+ context 'when the example raises an error' do
+ def run_and_capture_reported_message(group)
reported_msg = nil
# We can't use should_receive(:message).with(/.../) here,
# because if that fails, it would fail within our example-under-test,
# and since there's already two errors, it would just be reported again.
RSpec.configuration.reporter.stub(:message) { |msg| reported_msg = msg }
group.run
- reported_msg.should =~ /An error occurred in an around.* hook/i
+ reported_msg
+ end
+
+ it "prints any around hook errors rather than silencing them" do
+ group = RSpec::Core::ExampleGroup.describe do
+ around(:each) { |e| e.run; raise "around" }
+ example("e") { raise "example" }
+ end
+
+ message = run_and_capture_reported_message(group)
+ message.should =~ /An error occurred in an around.* hook/i
end
- end
- context "when the example and an after hook raise errors" do
- it "prints the after hook error rather than silencing it" do
+ it "prints any after hook errors rather than silencing them" do
group = RSpec::Core::ExampleGroup.describe do
after(:each) { raise "after" }
example("e") { raise "example" }
end
- reported_msg = nil
- # We can't use should_receive(:message).with(/.../) here,
- # because if that fails, it would fail within our example-under-test,
- # and since there's already two errors, it would just be reported again.
- RSpec.configuration.reporter.stub(:message) { |msg| reported_msg = msg }
- group.run
- reported_msg.should =~ /An error occurred in an after.* hook/i
+ message = run_and_capture_reported_message(group)
+ message.should =~ /An error occurred in an after.* hook/i
+ end
+
+ it 'does not print mock expectation errors' do
+ group = RSpec::Core::ExampleGroup.describe do
+ example do
+ foo = mock
+ foo.should_receive(:bar)
+ raise "boom"
+ end
+ end
+
+ message = run_and_capture_reported_message(group)
+ message.should be_nil
end
end
end
2  spec/rspec/core/option_parser_spec.rb
View
@@ -68,7 +68,7 @@ module RSpec::Core
describe option do
it "escapes the arg" do
options = Parser.parse!([option, "this (and that)"])
- options[:full_description].length.should == 1
+ options[:full_description].length.should eq(1)
"this (and that)".should match(options[:full_description].first)
end
end

No commit comments for this range

Something went wrong with that request. Please try again.