Permalink
Browse files

change top-level module from Rspec to RSpec

- capture const_missing on Rspec and return RSpec
  • Loading branch information...
1 parent 4902ca2 commit ba95bb14b82dcd17c3dc0c6e79bc2ef27409668f @dchelimsky dchelimsky committed May 17, 2010
Showing with 271 additions and 258 deletions.
  1. +1 −1 README.markdown
  2. +7 −7 Rakefile
  3. +6 −6 Upgrade.markdown
  4. +3 −3 features/matchers/access_running_example.feature
  5. +1 −1 features/matchers/define_diffable_matcher.feature
  6. +7 −7 features/matchers/define_matcher.feature
  7. +2 −2 features/matchers/define_matcher_outside_rspec.feature
  8. +1 −1 features/matchers/define_matcher_with_fluent_interface.feature
  9. +6 −5 lib/rspec/expectations.rb
  10. +12 −0 lib/rspec/expectations/backward_compatibility.rb
  11. +1 −1 lib/rspec/expectations/differs/default.rb
  12. +1 −1 lib/rspec/expectations/errors.rb
  13. +4 −4 lib/rspec/expectations/extensions/kernel.rb
  14. +1 −1 lib/rspec/expectations/extensions/rspec/core/example_group.rb
  15. +3 −3 lib/rspec/expectations/fail_with.rb
  16. +11 −11 lib/rspec/expectations/handler.rb
  17. +1 −1 lib/rspec/expectations/version.rb
  18. +7 −8 lib/rspec/matchers.rb
  19. +6 −6 lib/rspec/matchers/be.rb
  20. +1 −1 lib/rspec/matchers/be_close.rb
  21. +1 −1 lib/rspec/matchers/be_instance_of.rb
  22. +1 −1 lib/rspec/matchers/be_kind_of.rb
  23. +1 −1 lib/rspec/matchers/change.rb
  24. +2 −2 lib/rspec/matchers/compatibility.rb
  25. +4 −4 lib/rspec/matchers/dsl.rb
  26. +1 −1 lib/rspec/matchers/eq.rb
  27. +1 −1 lib/rspec/matchers/eql.rb
  28. +1 −1 lib/rspec/matchers/equal.rb
  29. +1 −1 lib/rspec/matchers/errors.rb
  30. +1 −1 lib/rspec/matchers/exist.rb
  31. +1 −1 lib/rspec/matchers/extensions/instance_exec.rb
  32. +1 −1 lib/rspec/matchers/generated_descriptions.rb
  33. +1 −1 lib/rspec/matchers/has.rb
  34. +1 −1 lib/rspec/matchers/have.rb
  35. +1 −1 lib/rspec/matchers/include.rb
  36. +1 −1 lib/rspec/matchers/match.rb
  37. +3 −3 lib/rspec/matchers/match_array.rb
  38. +13 −13 lib/rspec/matchers/matcher.rb
  39. +1 −1 lib/rspec/matchers/method_missing.rb
  40. +4 −4 lib/rspec/matchers/operator_matcher.rb
  41. +1 −1 lib/rspec/matchers/pretty.rb
  42. +1 −1 lib/rspec/matchers/raise_error.rb
  43. +1 −1 lib/rspec/matchers/respond_to.rb
  44. +1 −1 lib/rspec/matchers/satisfy.rb
  45. +1 −1 lib/rspec/matchers/throw_symbol.rb
  46. +2 −1 rspec-expectations.gemspec
  47. +7 −7 spec/rspec/expectations/differs/default_spec.rb
  48. +20 −20 spec/rspec/expectations/fail_with_spec.rb
  49. +22 −22 spec/rspec/expectations/handler_spec.rb
  50. +1 −1 spec/rspec/matchers/be_close_spec.rb
  51. +1 −1 spec/rspec/matchers/be_instance_of_spec.rb
  52. +1 −1 spec/rspec/matchers/be_kind_of_spec.rb
  53. +3 −3 spec/rspec/matchers/change_spec.rb
  54. +3 −3 spec/rspec/matchers/compatibility_spec.rb
  55. +28 −28 spec/rspec/matchers/description_generation_spec.rb
  56. +3 −3 spec/rspec/matchers/dsl_spec.rb
  57. +1 −1 spec/rspec/matchers/eq_spec.rb
  58. +1 −1 spec/rspec/matchers/eql_spec.rb
  59. +1 −1 spec/rspec/matchers/equal_spec.rb
  60. +1 −1 spec/rspec/matchers/exist_spec.rb
  61. +3 −3 spec/rspec/matchers/have_spec.rb
  62. +25 −25 spec/rspec/matchers/matcher_spec.rb
  63. +12 −12 spec/rspec/matchers/operator_matcher_spec.rb
  64. +1 −1 spec/rspec/matchers/throw_symbol_spec.rb
  65. +6 −6 spec/spec_helper.rb
  66. +1 −1 spec/support/classes.rb
View
2 README.markdown
@@ -1,7 +1,7 @@
# RSpec Expectations
rspec-expectations adds `should` and `should_not` to every object and includes
-Rspec::Matchers, a library of standard matchers.
+RSpec::Matchers, a library of standard matchers.
rspec-expectations is currently in alpha release. While you are welcome to
track, fork, explore, etc, we're too early in the process to start fielding
View
14 Rakefile
@@ -6,17 +6,17 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "rspec-expectations"
- gem.version = Rspec::Expectations::Version::STRING
- gem.summary = "rspec-expectations-#{Rspec::Expectations::Version::STRING}"
+ gem.version = RSpec::Expectations::Version::STRING
+ gem.summary = "rspec-expectations-#{RSpec::Expectations::Version::STRING}"
gem.description = "rspec expectations (should[_not] and matchers)"
gem.rubyforge_project = "rspec"
gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
gem.homepage = "http://github.com/rspec/expectations"
gem.authors = ["David Chelimsky", "Chad Humphries"]
gem.add_development_dependency('cucumber', ">= 0.6.2")
gem.add_development_dependency('aruba', ">= 0.1.1")
- gem.add_development_dependency('rspec-core', ">= #{Rspec::Expectations::Version::STRING}")
- gem.add_development_dependency('rspec-mocks', ">= #{Rspec::Expectations::Version::STRING}")
+ gem.add_development_dependency('rspec-core', ">= #{RSpec::Expectations::Version::STRING}")
+ gem.add_development_dependency('rspec-mocks', ">= #{RSpec::Expectations::Version::STRING}")
gem.post_install_message = <<-EOM
#{"*"*50}
@@ -36,15 +36,15 @@ end
namespace :gem do
desc "push to gemcutter"
task :push => :build do
- system "gem push pkg/rspec-expectations-#{Rspec::Expectations::Version::STRING}.gem"
+ system "gem push pkg/rspec-expectations-#{RSpec::Expectations::Version::STRING}.gem"
end
end
begin
require 'rspec/core/rake_task'
- Rspec::Core::RakeTask.new(:spec)
+ RSpec::Core::RakeTask.new(:spec)
rescue LoadError
- puts "Rspec core or one of its dependencies is not installed. Install it with: gem install rspec-core"
+ puts "RSpec core or one of its dependencies is not installed. Install it with: gem install rspec-core"
end
begin
View
12 Upgrade.markdown
@@ -4,7 +4,7 @@
### New `eq` matcher.
-`Rspec::Matchers` now offers you two approaches to differentiating between
+`RSpec::Matchers` now offers you two approaches to differentiating between
object identity. You can use the rspec-1 approach:
actual.should == expected # object equality
@@ -19,7 +19,7 @@ object identity. You can use the rspec-1 approach:
### simple_matcher
-Use Rspec::Matchers.define instead. For example, if you had:
+Use RSpec::Matchers.define instead. For example, if you had:
def eat_cheese
simple_matcher("eat cheese") do |actual|
@@ -29,23 +29,23 @@ Use Rspec::Matchers.define instead. For example, if you had:
Change it to:
- Rspec::Matchers.define :eat_cheese do
+ RSpec::Matchers.define :eat_cheese do
match do |actual|
actual.eat?(:cheese)
end
end
### wrap_expectation
-Use Rspec::Matchers.define instead.
+Use RSpec::Matchers.define instead.
- Rspec::Matchers.define :eat_cheese do
+ RSpec::Matchers.define :eat_cheese do
match do |actual|
actual.should eat?(:cheese)
end
end
- Rspec::Matchers.define :eat_cheese do
+ RSpec::Matchers.define :eat_cheese do
include MyCheesyAssertions
match_unless_raises Test::Unit::AssertionFailedError do |actual|
assert_eats_chesse actual
View
6 features/matchers/access_running_example.feature
@@ -12,7 +12,7 @@ Feature: access running example
Scenario: call method defined on example from matcher
Given a file named "example_spec.rb" with:
"""
- Rspec::Matchers.define :bar do
+ RSpec::Matchers.define :bar do
match do |_|
foo == "foo"
end
@@ -34,7 +34,7 @@ Feature: access running example
Scenario: call method _not_ defined on example from matcher
Given a file named "example_spec.rb" with:
"""
- Rspec::Matchers.define :bar do
+ RSpec::Matchers.define :bar do
match do |_|
foo == "foo"
end
@@ -49,5 +49,5 @@ Feature: access running example
When I run "rspec example_spec.rb"
Then I should see "1 example, 1 failure"
And I should see "undefined local variable"
- And I should see "Rspec::Matchers::Matcher"
+ And I should see "RSpec::Matchers::Matcher"
And I should not see "ExampleGroup"
View
2 features/matchers/define_diffable_matcher.feature
@@ -8,7 +8,7 @@ Feature: define diffable matcher
Scenario: define a diffable matcher
Given a file named "diffable_matcher_spec.rb" with:
"""
- Rspec::Matchers.define :be_just_like do |expected|
+ RSpec::Matchers.define :be_just_like do |expected|
match do |actual|
actual == expected
end
View
14 features/matchers/define_matcher.feature
@@ -9,7 +9,7 @@ Feature: define matcher
"""
require 'rspec/expectations'
- Rspec::Matchers.define :be_a_multiple_of do |expected|
+ RSpec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
end
@@ -51,7 +51,7 @@ Feature: define matcher
"""
require 'rspec/expectations'
- Rspec::Matchers.define :be_a_multiple_of do |expected|
+ RSpec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
end
@@ -75,7 +75,7 @@ Feature: define matcher
"""
require 'rspec/expectations'
- Rspec::Matchers.define :be_a_multiple_of do |expected|
+ RSpec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
end
@@ -99,7 +99,7 @@ Feature: define matcher
"""
require 'rspec/expectations'
- Rspec::Matchers.define :be_a_multiple_of do |expected|
+ RSpec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
end
@@ -127,7 +127,7 @@ Feature: define matcher
"""
require 'rspec/expectations'
- Rspec::Matchers.define :have_7_fingers do
+ RSpec::Matchers.define :have_7_fingers do
match do |thing|
thing.fingers.length == 7
end
@@ -151,7 +151,7 @@ Feature: define matcher
"""
require 'rspec/expectations'
- Rspec::Matchers.define :be_the_sum_of do |a,b,c,d|
+ RSpec::Matchers.define :be_the_sum_of do |a,b,c,d|
match do |sum|
a + b + c + d == sum
end
@@ -171,7 +171,7 @@ Feature: define matcher
"""
require 'rspec/expectations'
- Rspec::Matchers.define :have_same_elements_as do |sample|
+ RSpec::Matchers.define :have_same_elements_as do |sample|
match do |actual|
similar?(sample, actual)
end
View
4 features/matchers/define_matcher_outside_rspec.feature
@@ -10,14 +10,14 @@ Feature: define matcher outside rspec
require "rspec/expectations"
require "test/unit"
- Rspec::Matchers.define :be_a_multiple_of do |expected|
+ RSpec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
end
end
class Test::Unit::TestCase
- include Rspec::Matchers
+ include RSpec::Matchers
end
class TestMultiples < Test::Unit::TestCase
View
2 features/matchers/define_matcher_with_fluent_interface.feature
@@ -7,7 +7,7 @@ Feature: define matcher
Scenario: one additional method
Given a file named "between_spec.rb" with:
"""
- Rspec::Matchers.define :be_bigger_than do |first|
+ RSpec::Matchers.define :be_bigger_than do |first|
def but_smaller_than(second)
@second = second
self
View
11 lib/rspec/expectations.rb
@@ -4,22 +4,23 @@
require 'rspec/expectations/extensions'
require 'rspec/expectations/handler'
require 'rspec/expectations/version'
+require 'rspec/expectations/backward_compatibility'
-module Rspec
+module RSpec
- # Rspec::Expectations lets you set expectations on your objects.
+ # RSpec::Expectations lets you set expectations on your objects.
#
# result.should == 37
# team.should have(11).players_on_the_field
#
# == How Expectations work.
#
- # Rspec::Expectations adds two methods to Object:
+ # RSpec::Expectations adds two methods to Object:
#
# should(matcher=nil)
# should_not(matcher=nil)
#
- # Both methods take an optional Expression Matcher (See Rspec::Matchers).
+ # Both methods take an optional Expression Matcher (See RSpec::Matchers).
#
# When +should+ receives an Expression Matcher, it calls <tt>matches?(self)</tt>. If
# it returns +true+, the spec passes and execution continues. If it returns
@@ -30,7 +31,7 @@ module Rspec
# +true+, then the spec fails with the message returned by <tt>matcher.negative_failure_message</tt>.
#
# RSpec ships with a standard set of useful matchers, and writing your own
- # matchers is quite simple. See Rspec::Matchers for details.
+ # matchers is quite simple. See RSpec::Matchers for details.
module Expectations
end
end
View
12 lib/rspec/expectations/backward_compatibility.rb
@@ -0,0 +1,12 @@
+# Cucumber 0.7 includes Rspec::Expectations
+module RSpec
+ module Expectations
+ module ConstMissing
+ def const_missing(name)
+ name == :Rspec ? RSpec : super(name)
+ end
+ end
+ end
+end
+
+Object.extend(RSpec::Expectations::ConstMissing)
View
2 lib/rspec/expectations/differs/default.rb
@@ -1,7 +1,7 @@
require File.join(File.dirname(__FILE__), "/load-diff-lcs")
require 'pp'
-module Rspec
+module RSpec
module Expectations
module Differs
unless defined?(Default)
View
2 lib/rspec/expectations/errors.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Expectations
# If Test::Unit is loaed, we'll use its error as baseclass, so that Test::Unit
# will report unmet RSpec expectations as failures rather than errors.
View
8 lib/rspec/expectations/extensions/kernel.rb
@@ -17,14 +17,14 @@ module Kernel
# receiver.should =~ regexp
# => Passes if (receiver =~ regexp)
#
- # See Rspec::Matchers for more information about matchers
+ # See RSpec::Matchers for more information about matchers
#
# == Warning
#
# NOTE that this does NOT support receiver.should != expected.
# Instead, use receiver.should_not == expected
def should(matcher=nil, message=nil, &block)
- Rspec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
end
# :call-seq:
@@ -45,8 +45,8 @@ def should(matcher=nil, message=nil, &block)
# receiver.should_not =~ regexp
# => Passes unless (receiver =~ regexp)
#
- # See Rspec::Matchers for more information about matchers
+ # See RSpec::Matchers for more information about matchers
def should_not(matcher=nil, message=nil, &block)
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
end
end
View
2 lib/rspec/expectations/extensions/rspec/core/example_group.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Core
class ExampleGroup
module BlockAliases
View
6 lib/rspec/expectations/fail_with.rb
@@ -1,9 +1,9 @@
-module Rspec
+module RSpec
module Expectations
class << self
attr_accessor :differ
- # raises a Rspec::Expectations::ExpectationNotMetError with message
+ # raises a RSpec::Expectations::ExpectationNotMetError with message
#
# When a differ has been assigned and fail_with is passed
# <code>expected</code> and <code>target</code>, passes them
@@ -20,7 +20,7 @@ def fail_with(message, expected=nil, target=nil) # :nodoc:
message << "\nDiff:" << self.differ.diff_as_object(target, expected)
end
end
- Kernel::raise(Rspec::Expectations::ExpectationNotMetError.new(message))
+ Kernel::raise(RSpec::Expectations::ExpectationNotMetError.new(message))
end
end
end
View
22 lib/rspec/expectations/handler.rb
@@ -1,12 +1,12 @@
-module Rspec
+module RSpec
module Expectations
class InvalidMatcherError < ArgumentError; end
class PositiveExpectationHandler
def self.handle_matcher(actual, matcher, message=nil, &block)
- ::Rspec::Matchers.last_should = :should
- ::Rspec::Matchers.last_matcher = matcher
- return ::Rspec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?
+ ::RSpec::Matchers.last_should = :should
+ ::RSpec::Matchers.last_matcher = matcher
+ return ::RSpec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?
match = matcher.matches?(actual, &block)
return match if match
@@ -16,18 +16,18 @@ def self.handle_matcher(actual, matcher, message=nil, &block)
matcher.failure_message
if matcher.respond_to?(:diffable?) && matcher.diffable?
- ::Rspec::Expectations.fail_with message, matcher.expected.first, matcher.actual
+ ::RSpec::Expectations.fail_with message, matcher.expected.first, matcher.actual
else
- ::Rspec::Expectations.fail_with message
+ ::RSpec::Expectations.fail_with message
end
end
end
class NegativeExpectationHandler
def self.handle_matcher(actual, matcher, message=nil, &block)
- ::Rspec::Matchers.last_should = :should_not
- ::Rspec::Matchers.last_matcher = matcher
- return ::Rspec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
+ ::RSpec::Matchers.last_should = :should_not
+ ::RSpec::Matchers.last_matcher = matcher
+ return ::RSpec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
match = matcher.respond_to?(:does_not_match?) ?
!matcher.does_not_match?(actual, &block) :
@@ -39,9 +39,9 @@ def self.handle_matcher(actual, matcher, message=nil, &block)
matcher.negative_failure_message
if matcher.respond_to?(:diffable?) && matcher.diffable?
- ::Rspec::Expectations.fail_with message, matcher.expected.first, matcher.actual
+ ::RSpec::Expectations.fail_with message, matcher.expected.first, matcher.actual
else
- ::Rspec::Expectations.fail_with message
+ ::RSpec::Expectations.fail_with message
end
end
end
View
2 lib/rspec/expectations/version.rb
@@ -1,4 +1,4 @@
-module Rspec # :nodoc:
+module RSpec # :nodoc:
module Expectations # :nodoc:
module Version # :nodoc:
STRING = File.readlines(File.expand_path('../../../../VERSION', __FILE__)).first
View
15 lib/rspec/matchers.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
# RSpec ships with a number of useful Expression Matchers. An Expression Matcher
# is any object that responds to the following methods:
#
@@ -17,7 +17,7 @@ module Rspec
# failure_message (use failure_message_for_should instead)
# negative_failure_message (use failure_message_for_should_not instead)
#
- # See Rspec::Expectations to learn how to use these as Expectation Matchers.
+ # See RSpec::Expectations to learn how to use these as Expectation Matchers.
#
# == Predicates
#
@@ -78,7 +78,7 @@ module Rspec
#
# You can create such a matcher like so:
#
- # Rspec::Matchers.define :be_in_zone do |zone|
+ # RSpec::Matchers.define :be_in_zone do |zone|
# match do |player|
# player.in_zone?(zone)
# end
@@ -88,7 +88,7 @@ module Rspec
# with logical default messages for failures. You can override the failure
# messages and the generated description as follows:
#
- # Rspec::Matchers.define :be_in_zone do |zone|
+ # RSpec::Matchers.define :be_in_zone do |zone|
# match do |player|
# player.in_zone?(zone)
# end
@@ -157,13 +157,13 @@ module Rspec
# or you can include in globally in a spec_helper.rb file <tt>require</tt>d
# from your spec file(s):
#
- # Rspec::Runner.configure do |config|
+ # RSpec::Runner.configure do |config|
# config.include(CustomGameMatchers)
# end
#
module Matchers
- if Rspec.respond_to?(:configure)
- Rspec.configure {|c| c.include self}
+ if RSpec.respond_to?(:configure)
+ RSpec.configure {|c| c.include self}
end
end
end
@@ -195,4 +195,3 @@ module Matchers
require 'rspec/matchers/throw_symbol'
require 'rspec/matchers/compatibility'
require 'rspec/matchers/dsl'
-
View
12 lib/rspec/matchers/be.rb
@@ -1,18 +1,18 @@
require 'rspec/matchers/dsl'
-Rspec::Matchers.define :be_true do
+RSpec::Matchers.define :be_true do
match do |actual|
!!actual
end
end
-Rspec::Matchers.define :be_false do
+RSpec::Matchers.define :be_false do
match do |actual|
!actual
end
end
-Rspec::Matchers.define :be_nil do
+RSpec::Matchers.define :be_nil do
match do |actual|
actual.nil?
end
@@ -26,11 +26,11 @@
end
end
-module Rspec
+module RSpec
module Matchers
class Be #:nodoc:
- include Rspec::Matchers::Pretty
+ include RSpec::Matchers::Pretty
def initialize(*args, &block)
@args = args
@@ -216,7 +216,7 @@ def description
# the caller should satisfy an if condition (to be or not to be).
#
# Predicates are any Ruby method that ends in a "?" and returns true or false.
- # Given be_ followed by arbitrary_predicate (without the "?"), Rspec will match
+ # Given be_ followed by arbitrary_predicate (without the "?"), RSpec will match
# convert that into a query against the target object.
#
# The arbitrary_predicate feature will handle any predicate
View
2 lib/rspec/matchers/be_close.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should be_close(expected, delta)
View
2 lib/rspec/matchers/be_instance_of.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should be_instance_of(expected)
View
2 lib/rspec/matchers/be_kind_of.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should be_kind_of(expected)
View
2 lib/rspec/matchers/change.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
#Based on patch from Wilson Bilkovich
View
4 lib/rspec/matchers/compatibility.rb
@@ -1,5 +1,5 @@
-Rspec::Matchers.constants.each do |c|
- if Class === (klass = Rspec::Matchers.const_get(c))
+RSpec::Matchers.constants.each do |c|
+ if Class === (klass = RSpec::Matchers.const_get(c))
if klass.public_instance_methods.any? {|m| ['failure_message_for_should',:failure_message_for_should].include?(m)}
klass.class_eval do
alias_method :failure_message, :failure_message_for_should
View
8 lib/rspec/matchers/dsl.rb
@@ -1,15 +1,15 @@
-module Rspec
+module RSpec
module Matchers
module DSL
- # See Rspec::Matchers
+ # See RSpec::Matchers
def define(name, &declarations)
define_method name do |*expected|
$matcher_execution_context = self
- Rspec::Matchers::Matcher.new name, *expected, &declarations
+ RSpec::Matchers::Matcher.new name, *expected, &declarations
end
end
end
end
end
-Rspec::Matchers.extend Rspec::Matchers::DSL
+RSpec::Matchers.extend RSpec::Matchers::DSL
View
2 lib/rspec/matchers/eq.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should eq(expected)
View
2 lib/rspec/matchers/eql.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should eql(expected)
View
2 lib/rspec/matchers/equal.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
View
2 lib/rspec/matchers/errors.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class MatcherError < StandardError; end
end
View
2 lib/rspec/matchers/exist.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should exist
View
2 lib/rspec/matchers/extensions/instance_exec.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
module InstanceExec
unless respond_to?(:instance_exec)
View
2 lib/rspec/matchers/generated_descriptions.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class << self
attr_accessor :last_matcher, :last_should # :nodoc:
View
2 lib/rspec/matchers/has.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class Has
View
2 lib/rspec/matchers/have.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class Have #:nodoc:
def initialize(expected, relativity=:exactly)
View
2 lib/rspec/matchers/include.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should include(expected)
View
2 lib/rspec/matchers/match.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
# :call-seq:
# should match(pattern)
View
6 lib/rspec/matchers/match_array.rb
@@ -1,8 +1,8 @@
-module Rspec
+module RSpec
module Matchers
class MatchArray #:nodoc:
- include Rspec::Matchers::Pretty
+ include RSpec::Matchers::Pretty
def initialize(expected)
@expected = expected
@@ -66,6 +66,6 @@ def difference_between_arrays(array_1, array_2)
# [1,2,3,4].should =~ [1,2,3] # => would fail
# [1,2,2,3].should =~ [1,2,3] # => would fail
# [1,2,3].should =~ [1,2,3,4] # => would fail
- OperatorMatcher.register(Array, '=~', Rspec::Matchers::MatchArray)
+ OperatorMatcher.register(Array, '=~', RSpec::Matchers::MatchArray)
end
end
View
26 lib/rspec/matchers/matcher.rb
@@ -1,9 +1,9 @@
-module Rspec
+module RSpec
module Matchers
class Matcher
- include Rspec::Matchers::InstanceExec
- include Rspec::Matchers::Pretty
- include Rspec::Matchers
+ include RSpec::Matchers::InstanceExec
+ include RSpec::Matchers::Pretty
+ include RSpec::Matchers
attr_reader :expected, :actual
def initialize(name, *expected, &declarations)
@@ -35,34 +35,34 @@ def matches?(actual)
else
begin
instance_exec(actual, &@match_block)
- rescue Rspec::Expectations::ExpectationNotMetError
+ rescue RSpec::Expectations::ExpectationNotMetError
false
end
end
end
- # See Rspec::Matchers
+ # See RSpec::Matchers
def match(&block)
@match_block = block
end
- # See Rspec::Matchers
+ # See RSpec::Matchers
def match_unless_raises(exception=Exception, &block)
@expected_exception = exception
match(&block)
end
- # See Rspec::Matchers
+ # See RSpec::Matchers
def failure_message_for_should(&block)
cache_or_call_cached(:failure_message_for_should, &block)
end
- # See Rspec::Matchers
+ # See RSpec::Matchers
def failure_message_for_should_not(&block)
cache_or_call_cached(:failure_message_for_should_not, &block)
end
- # See Rspec::Matchers
+ # See RSpec::Matchers
def description(&block)
cache_or_call_cached(:description, &block)
end
@@ -72,12 +72,12 @@ def diffable?
@diffable
end
- # See Rspec::Matchers
+ # See RSpec::Matchers
def diffable
@diffable = true
end
- # See Rspec::Matchers
+ # See RSpec::Matchers
def chain(method, &block)
self.class.class_eval do
define_method method do |*args|
@@ -105,7 +105,7 @@ def making_declared_methods_public # :nodoc:
#
# Also, due some crazy scoping that I don't understand, these methods
# are actually available in the specs (something about the matcher being
- # defined in the scope of Rspec::Matchers or within an example), so not
+ # defined in the scope of RSpec::Matchers or within an example), so not
# doing the following will not cause specs to fail, but they *will*
# cause features to fail and that will make users unhappy. So don't.
orig_private_methods = private_methods
View
2 lib/rspec/matchers/method_missing.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
def method_missing(sym, *args, &block) # :nodoc:
return Matchers::BePredicate.new(sym, *args, &block) if sym.to_s =~ /^be_/
View
8 lib/rspec/matchers/operator_matcher.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class OperatorMatcher
@@ -24,7 +24,7 @@ def initialize(actual)
def self.use_custom_matcher_or_delegate(operator)
define_method(operator) do |expected|
if matcher = OperatorMatcher.get(@actual.class, operator)
- @actual.send(::Rspec::Matchers.last_should, matcher.new(expected))
+ @actual.send(::RSpec::Matchers.last_should, matcher.new(expected))
else
eval_match(@actual, operator, expected)
end
@@ -36,7 +36,7 @@ def self.use_custom_matcher_or_delegate(operator)
end
def fail_with_message(message)
- Rspec::Expectations.fail_with(message, @expected, @actual)
+ RSpec::Expectations.fail_with(message, @expected, @actual)
end
def description
@@ -46,7 +46,7 @@ def description
private
def eval_match(actual, operator, expected)
- ::Rspec::Matchers.last_matcher = self
+ ::RSpec::Matchers.last_matcher = self
@operator, @expected = operator, expected
__delegate_operator(actual, operator, expected)
end
View
2 lib/rspec/matchers/pretty.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
module Pretty
def split_words(sym)
View
2 lib/rspec/matchers/raise_error.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class RaiseError #:nodoc:
def initialize(expected_error_or_message=Exception, expected_message=nil, &block)
View
2 lib/rspec/matchers/respond_to.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class RespondTo #:nodoc:
View
2 lib/rspec/matchers/satisfy.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class Satisfy #:nodoc:
View
2 lib/rspec/matchers/throw_symbol.rb
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Matchers
class ThrowSymbol #:nodoc:
View
3 rspec-expectations.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["David Chelimsky", "Chad Humphries"]
- s.date = %q{2010-04-27}
+ s.date = %q{2010-05-16}
s.description = %q{rspec expectations (should[_not] and matchers)}
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
s.extra_rdoc_files = [
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
"features/matchers/expect_error.feature",
"features/support/env.rb",
"lib/rspec/expectations.rb",
+ "lib/rspec/expectations/backward_compatibility.rb",
"lib/rspec/expectations/differs/default.rb",
"lib/rspec/expectations/differs/load-diff-lcs.rb",
"lib/rspec/expectations/errors.rb",
View
14 spec/rspec/expectations/differs/default_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'ostruct'
-module Rspec
+module RSpec
module Fixtures
class Animal
def initialize(name,species)
@@ -23,7 +23,7 @@ def inspect
describe "Diff" do
before(:each) do
@options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
- @differ = Rspec::Expectations::Differs::Default.new(@options)
+ @differ = RSpec::Expectations::Differs::Default.new(@options)
end
it "should output unified diff of two strings" do
@@ -76,8 +76,8 @@ def inspect
end
it "should output unified diff message of two objects" do
- expected = Rspec::Fixtures::Animal.new "bob", "giraffe"
- actual = Rspec::Fixtures::Animal.new "bob", "tortoise"
+ expected = RSpec::Fixtures::Animal.new "bob", "giraffe"
+ actual = RSpec::Fixtures::Animal.new "bob", "tortoise"
expected_diff = <<'EOD'
@@ -100,12 +100,12 @@ def inspect
before(:each) do
@options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
@options.diff_format = :context
- @differ = Rspec::Expectations::Differs::Default.new(@options)
+ @differ = RSpec::Expectations::Differs::Default.new(@options)
end
it "should output unified diff message of two objects" do
- expected = Rspec::Fixtures::Animal.new "bob", "giraffe"
- actual = Rspec::Fixtures::Animal.new "bob", "tortoise"
+ expected = RSpec::Fixtures::Animal.new "bob", "giraffe"
+ actual = RSpec::Fixtures::Animal.new "bob", "tortoise"
expected_diff = <<'EOD'
View
40 spec/rspec/expectations/fail_with_spec.rb
@@ -1,81 +1,81 @@
require 'spec_helper'
-describe Rspec::Expectations, "#fail_with with no diff" do
+describe RSpec::Expectations, "#fail_with with no diff" do
before(:each) do
- @old_differ = Rspec::Expectations.differ
- Rspec::Expectations.differ = nil
+ @old_differ = RSpec::Expectations.differ
+ RSpec::Expectations.differ = nil
end
it "should handle just a message" do
lambda {
- Rspec::Expectations.fail_with "the message"
+ RSpec::Expectations.fail_with "the message"
}.should fail_with("the message")
end
after(:each) do
- Rspec::Expectations.differ = @old_differ
+ RSpec::Expectations.differ = @old_differ
end
end
-describe Rspec::Expectations, "#fail_with with Array" do
+describe RSpec::Expectations, "#fail_with with Array" do
before(:each) do
- Rspec::Core.stub!(:warn)
+ RSpec::Core.stub!(:warn)
end
end
-describe Rspec::Expectations, "#fail_with with diff" do
+describe RSpec::Expectations, "#fail_with with diff" do
before(:each) do
- @old_differ = Rspec::Expectations.differ
+ @old_differ = RSpec::Expectations.differ
@differ = mock("differ")
- Rspec::Expectations.differ = @differ
+ RSpec::Expectations.differ = @differ
end
it "should not call differ if no expected/actual" do
lambda {
- Rspec::Expectations.fail_with "the message"
+ RSpec::Expectations.fail_with "the message"
}.should fail_with("the message")
end
it "should call differ if expected/actual are presented separately" do
@differ.should_receive(:diff_as_string).and_return("diff")
lambda {
- Rspec::Expectations.fail_with "the message", "expected", "actual"
+ RSpec::Expectations.fail_with "the message", "expected", "actual"
}.should fail_with("the message\nDiff:diff")
end
it "should call differ if expected/actual are not strings" do
@differ.should_receive(:diff_as_object).and_return("diff")
lambda {
- Rspec::Expectations.fail_with "the message", :expected, :actual
+ RSpec::Expectations.fail_with "the message", :expected, :actual
}.should fail_with("the message\nDiff:diff")
end
it "should not call differ if expected or actual are procs" do
@differ.should_not_receive(:diff_as_string)
@differ.should_not_receive(:diff_as_object)
lambda {
- Rspec::Expectations.fail_with "the message", lambda {}, lambda {}
+ RSpec::Expectations.fail_with "the message", lambda {}, lambda {}
}.should fail_with("the message")
end
after(:each) do
- Rspec::Expectations.differ = @old_differ
+ RSpec::Expectations.differ = @old_differ
end
end
-describe Rspec::Expectations, "#fail_with with a nil message" do
+describe RSpec::Expectations, "#fail_with with a nil message" do
before(:each) do
- @old_differ = Rspec::Expectations.differ
- Rspec::Expectations.differ = nil
+ @old_differ = RSpec::Expectations.differ
+ RSpec::Expectations.differ = nil
end
it "should handle just a message" do
lambda {
- Rspec::Expectations.fail_with nil
+ RSpec::Expectations.fail_with nil
}.should raise_error(ArgumentError, /Failure message is nil\. Does your matcher define the appropriate failure_message_for_\* method to return a string\?/)
end
after(:each) do
- Rspec::Expectations.differ = @old_differ
+ RSpec::Expectations.differ = @old_differ
end
end
View
44 spec/rspec/expectations/handler_spec.rb
@@ -44,31 +44,31 @@ def positive_only_matcher(*args, &block)
end
-module Rspec
+module RSpec
module Expectations
describe PositiveExpectationHandler do
describe "#handle_matcher" do
it "asks the matcher if it matches" do
matcher = mock("matcher")
actual = Object.new
matcher.should_receive(:matches?).with(actual).and_return(true)
- Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
end
it "returns the match value" do
matcher = mock("matcher")
actual = Object.new
matcher.should_receive(:matches?).with(actual).and_return(:this_value)
- Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher).should == :this_value
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher).should == :this_value
end
it "calls failure_message_for_should if the matcher implements it" do
matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("message")
+ ::RSpec::Expectations.should_receive(:fail_with).with("message")
- Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
end
it "calls fail if matcher.diffable?" do
@@ -81,28 +81,28 @@ module Expectations
)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("message", 1, 2)
+ ::RSpec::Expectations.should_receive(:fail_with).with("message", 1, 2)
- Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
end
it "calls failure_message if the matcher does not implement failure_message_for_should" do
matcher = mock("matcher", :failure_message => "message", :matches? => false)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("message")
+ ::RSpec::Expectations.should_receive(:fail_with).with("message")
- Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
end
it "appends the :or message in the options hash passed to should" do
matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("custom")
+ ::RSpec::Expectations.should_receive(:fail_with).with("custom")
- Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher, "custom")
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher, "custom")
end
end
end
@@ -113,43 +113,43 @@ module Expectations
matcher = mock("matcher", :does_not_match? => true, :negative_failure_message => nil)
actual = Object.new
matcher.should_receive(:does_not_match?).with(actual).and_return(true)
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
end
it "asks the matcher if it matches when the matcher doesn't respond to #does_not_match?" do
matcher = mock("matcher")
actual = Object.new
matcher.stub!(:negative_failure_message)
matcher.should_receive(:matches?).with(actual).and_return(false)
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
end
it "returns the match value" do
matcher = mock("matcher")
actual = Object.new
matcher.should_receive(:matches?).with(actual).and_return(false)
matcher.stub!(:negative_failure_message).and_return("ignore")
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher).should be_false
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher).should be_false
end
it "calls failure_message_for_should_not if the matcher implements it" do
matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("message")
+ ::RSpec::Expectations.should_receive(:fail_with).with("message")
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
end
it "calls negative_failure_message if the matcher does not implement failure_message_for_should_not" do
matcher = mock("matcher", :negative_failure_message => "message", :matches? => true)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("message")
+ ::RSpec::Expectations.should_receive(:fail_with).with("message")
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
end
@@ -164,18 +164,18 @@ module Expectations
)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("message", 1, 2)
+ ::RSpec::Expectations.should_receive(:fail_with).with("message", 1, 2)
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
end
it "appends the :or message in the options hash passed to should" do
matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true)
actual = Object.new
- ::Rspec::Expectations.should_receive(:fail_with).with("custom")
+ ::RSpec::Expectations.should_receive(:fail_with).with("custom")
- Rspec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher, "custom")
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher, "custom")
end
end
View
2 spec/rspec/matchers/be_close_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
-module Rspec
+module RSpec
module Matchers
describe "[actual.should] be_close(expected, delta)" do
it "matches when actual == expected" do
View
2 spec/rspec/matchers/be_instance_of_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-module Rspec
+module RSpec
module Matchers
[:be_an_instance_of, :be_instance_of].each do |method|
describe "actual.should #{method}(expected)" do
View
2 spec/rspec/matchers/be_kind_of_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-module Rspec
+module RSpec
module Matchers
[:be_a_kind_of, :be_kind_of].each do |method|
describe "actual.should #{method}(expected)" do
View
6 spec/rspec/matchers/change_spec.rb
@@ -62,7 +62,7 @@ class SomethingExpected
it "should warn if passed a block using do/end instead of {}" do
expect do
expect {}.to change do; end
- end.to raise_error(Rspec::Matchers::MatcherError, /block passed to should or should_not/)
+ end.to raise_error(RSpec::Matchers::MatcherError, /block passed to should or should_not/)
end
it "provides a #description" do
@@ -89,7 +89,7 @@ class SomethingExpected
it "should warn if passed a block using do/end instead of {}" do
expect do
expect {}.to_not change do; end
- end.to raise_error(Rspec::Matchers::MatcherError, /block passed to should or should_not/)
+ end.to raise_error(RSpec::Matchers::MatcherError, /block passed to should or should_not/)
end
end
@@ -336,7 +336,7 @@ class SomethingExpected
end
end
-describe Rspec::Matchers::Change do
+describe RSpec::Matchers::Change do
it "should work when the receiver has implemented #send" do
@instance = SomethingExpected.new
@instance.some_value = "string"
View
6 spec/rspec/matchers/compatibility_spec.rb
@@ -1,13 +1,13 @@
require 'spec_helper'
-Rspec::Matchers.define :have_public_instance_method do |method|
+RSpec::Matchers.define :have_public_instance_method do |method|
match do |klass|
klass.public_instance_methods.any? {|m| [method, method.to_sym].include?(m)}
end
end
-(Rspec::Matchers.constants.sort).each do |c|
- if (Class === (klass = Rspec::Matchers.const_get(c)))
+(RSpec::Matchers.constants.sort).each do |c|
+ if (Class === (klass = RSpec::Matchers.const_get(c)))
describe klass do
if klass.public_instance_methods.any? {|m| ['failure_message_for_should',:failure_message_for_should].include?(m)}
describe "called with should" do
View
56 spec/rspec/matchers/description_generation_spec.rb
@@ -2,138 +2,138 @@
describe "Matchers should be able to generate their own descriptions" do
after(:each) do
- Rspec::Matchers.clear_generated_description
+ RSpec::Matchers.clear_generated_description
end
it "should == expected" do
"this".should == "this"
- Rspec::Matchers.generated_description.should == "should == \"this\""
+ RSpec::Matchers.generated_description.should == "should == \"this\""
end
it "should not == expected" do
"this".should_not == "that"
- Rspec::Matchers.generated_description.should == "should not == \"that\""
+ RSpec::Matchers.generated_description.should == "should not == \"that\""
end
it "should be empty (arbitrary predicate)" do
[].should be_empty
- Rspec::Matchers.generated_description.should == "should be empty"
+ RSpec::Matchers.generated_description.should == "should be empty"
end
it "should not be empty (arbitrary predicate)" do
[1].should_not be_empty
- Rspec::Matchers.generated_description.should == "should not be empty"
+ RSpec::Matchers.generated_description.should == "should not be empty"
end
it "should be true" do
true.should be_true
- Rspec::Matchers.generated_description.should == "should be true"
+ RSpec::Matchers.generated_description.should == "should be true"
end
it "should be false" do
false.should be_false
- Rspec::Matchers.generated_description.should == "should be false"
+ RSpec::Matchers.generated_description.should == "should be false"
end
it "should be nil" do
nil.should be_nil
- Rspec::Matchers.generated_description.should == "should be nil"
+ RSpec::Matchers.generated_description.should == "should be nil"
end
it "should be > n" do
5.should be > 3
- Rspec::Matchers.generated_description.should == "should be > 3"
+ RSpec::Matchers.generated_description.should == "should be > 3"
end
it "should be predicate arg1, arg2 and arg3" do
5.0.should be_between(0,10)
- Rspec::Matchers.generated_description.should == "should be between 0 and 10"
+ RSpec::Matchers.generated_description.should == "should be between 0 and 10"
end
it "should equal" do
expected = "expected"
expected.should equal(expected)
- Rspec::Matchers.generated_description.should == "should equal \"expected\""
+ RSpec::Matchers.generated_description.should == "should equal \"expected\""
end
it "should_not equal" do
5.should_not equal(37)
- Rspec::Matchers.generated_description.should == "should not equal 37"
+ RSpec::Matchers.generated_description.should == "should not equal 37"
end
it "should eql" do
"string".should eql("string")
- Rspec::Matchers.generated_description.should == "should eql \"string\""
+ RSpec::Matchers.generated_description.should == "should eql \"string\""
end
it "should not eql" do
"a".should_not eql(:a)
- Rspec::Matchers.generated_description.should == "should not eql :a"
+ RSpec::Matchers.generated_description.should == "should not eql :a"
end
it "should have_key" do
{:a => "a"}.should have_key(:a)
- Rspec::Matchers.generated_description.should == "should have key :a"
+ RSpec::Matchers.generated_description.should == "should have key :a"
end
it "should have n items" do
team.should have(3).players
- Rspec::Matchers.generated_description.should == "should have 3 players"
+ RSpec::Matchers.generated_description.should == "should have 3 players"
end
it "should have at least n items" do
team.should have_at_least(2).players
- Rspec::Matchers.generated_description.should == "should have at least 2 players"
+ RSpec::Matchers.generated_description.should == "should have at least 2 players"
end
it "should have at most n items" do
team.should have_at_most(4).players
- Rspec::Matchers.generated_description.should == "should have at most 4 players"
+ RSpec::Matchers.generated_description.should == "should have at most 4 players"
end
it "should include" do
[1,2,3].should include(3)
- Rspec::Matchers.generated_description.should == "should include 3"
+ RSpec::Matchers.generated_description.should == "should include 3"
end
it "array.should =~ [1,2,3]" do
[1,2,3].should =~ [1,2,3]
- Rspec::Matchers.generated_description.should == "should contain exactly 1, 2 and 3"
+ RSpec::Matchers.generated_description.should == "should contain exactly 1, 2 and 3"
end
it "should match" do
"this string".should match(/this string/)
- Rspec::Matchers.generated_description.should == "should match /this string/"
+ RSpec::Matchers.generated_description.should == "should match /this string/"
end
it "should raise_error" do
lambda { raise }.should raise_error
- Rspec::Matchers.generated_description.should == "should raise Exception"
+ RSpec::Matchers.generated_description.should == "should raise Exception"
end
it "should raise_error with type" do
lambda { raise }.should raise_error(RuntimeError)
- Rspec::Matchers.generated_description.should == "should raise RuntimeError"
+ RSpec::Matchers.generated_description.should == "should raise RuntimeError"
end
it "should raise_error with type and message" do
lambda { raise "there was an error" }.should raise_error(RuntimeError, "there was an error")
- Rspec::Matchers.generated_description.should == "should raise RuntimeError with \"there was an error\""
+ RSpec::Matchers.generated_description.should == "should raise RuntimeError with \"there was an error\""
end
it "should respond_to" do
[].should respond_to(:insert)
- Rspec::Matchers.generated_description.should == "should respond to #insert"
+ RSpec::Matchers.generated_description.should == "should respond to #insert"
end
it "should throw symbol" do
lambda { throw :what_a_mess }.should throw_symbol
- Rspec::Matchers.generated_description.should == "should throw a Symbol"
+ RSpec::Matchers.generated_description.should == "should throw a Symbol"
end
it "should throw symbol (with named symbol)" do
lambda { throw :what_a_mess }.should throw_symbol(:what_a_mess)
- Rspec::Matchers.generated_description.should == "should throw :what_a_mess"
+ RSpec::Matchers.generated_description.should == "should throw :what_a_mess"
end
def team
@@ -155,6 +155,6 @@ def failure_message; ""; end
it "should provide a helpful message when used in a string-less example block" do
5.should matcher
- Rspec::Matchers.generated_description.should =~ /When you call.*description method/m
+ RSpec::Matchers.generated_description.should =~ /When you call.*description method/m
end
end
View
6 spec/rspec/matchers/dsl_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-module Rspec
+module RSpec
module Matchers
module DSL
describe "#define" do
@@ -9,13 +9,13 @@ module DSL
# more robust - that expects new to be called with a specific
# block (lambda, proc, whatever)
mod = Module.new
- mod.extend Rspec::Matchers::DSL
+ mod.extend RSpec::Matchers::DSL
mod.define(:foo)
obj = Object.new
obj.extend mod
- Rspec::Matchers::Matcher.should_receive(:new).with(:foo, 3) { stub('matcher').as_null_object }
+ RSpec::Matchers::Matcher.should_receive(:new).with(:foo, 3) { stub('matcher').as_null_object }
obj.foo(3)
end
View
2 spec/rspec/matchers/eq_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-module Rspec
+module RSpec
module Matchers
describe "eq" do
it "matches when actual == expected" do
View
2 spec/rspec/matchers/eql_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-module Rspec
+module RSpec
module Matchers
describe "eql" do
it "should match when actual.eql?(expected)" do
View
2 spec/rspec/matchers/equal_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
-module Rspec
+module RSpec
module Matchers
describe "equal" do
View
2 spec/rspec/matchers/exist_spec.rb
@@ -14,7 +14,7 @@ def inspect
end
class SubstanceTester
- include Rspec::Matchers
+ include RSpec::Matchers
def initialize substance
@substance = substance
end
View
6 spec/rspec/matchers/have_spec.rb
@@ -3,7 +3,7 @@
share_as :HaveSpecHelper do
def create_collection_owner_with(n)
- owner = Rspec::Expectations::Helper::CollectionOwner.new
+ owner = RSpec::Expectations::Helper::CollectionOwner.new
(1..n).each do |number|
owner.add_to_collection_with_length_method(number)
owner.add_to_collection_with_size_method(number)
@@ -329,7 +329,7 @@ def items
end
end
-describe Rspec::Matchers::Have, "for a collection owner that implements #send" do
+describe RSpec::Matchers::Have, "for a collection owner that implements #send" do
include HaveSpecHelper
before(:each) do
@@ -357,7 +357,7 @@ def @collection.send(*args); raise "DOH! Library developers shouldn't use #send!
end
end
-module Rspec
+module RSpec
module Matchers
describe Have do
it "should have method_missing as private" do
View
50 spec/rspec/matchers/matcher_spec.rb
@@ -2,12 +2,12 @@
class UnexpectedError < StandardError; end
-module Rspec
+module RSpec
module Matchers
describe Matcher do
context "without overrides" do
before(:each) do
- @matcher = Rspec::Matchers::Matcher.new(:be_a_multiple_of, 3) do |multiple|
+ @matcher = RSpec::Matchers::Matcher.new(:be_a_multiple_of, 3) do |multiple|
match do |actual|
actual % multiple == 0
end
@@ -30,22 +30,22 @@ module Matchers
end
it "is not diffable by default" do
- matcher = Rspec::Matchers::Matcher.new(:name) {}
+ matcher = RSpec::Matchers::Matcher.new(:name) {}
matcher.should_not be_diffable
end
it "is diffable when told to be" do
- matcher = Rspec::Matchers::Matcher.new(:name) { diffable }
+ matcher = RSpec::Matchers::Matcher.new(:name) { diffable }
matcher.should be_diffable
end
it "provides expected" do
- matcher = Rspec::Matchers::Matcher.new(:name, 'expected string') {}
+ matcher = RSpec::Matchers::Matcher.new(:name, 'expected string') {}
matcher.expected.should == ['expected string']
end
it "provides actual" do
- matcher = Rspec::Matchers::Matcher.new(:name, 'expected string') do
+ matcher = RSpec::Matchers::Matcher.new(:name, 'expected string') do
match {|actual|}
end
@@ -56,7 +56,7 @@ module Matchers
context "wrapping another expectation (should == ...)" do
it "returns true if the wrapped expectation passes" do
- matcher = Rspec::Matchers::Matcher.new(:name, 'value') do |expected|
+ matcher = RSpec::Matchers::Matcher.new(:name, 'value') do |expected|
match do |actual|
actual.should == expected
end
@@ -65,7 +65,7 @@ module Matchers
end
it "returns false if the wrapped expectation fails" do
- matcher = Rspec::Matchers::Matcher.new(:name, 'value') do |expected|
+ matcher = RSpec::Matchers::Matcher.new(:name, 'value') do |expected|
match do |actual|
actual.should == expected
end
@@ -76,7 +76,7 @@ module Matchers
context "with overrides" do
before(:each) do
- @matcher = Rspec::Matchers::Matcher.new(:be_boolean, true) do |boolean|
+ @matcher = RSpec::Matchers::Matcher.new(:be_boolean, true) do |boolean|
match do |actual|
actual
end
@@ -117,7 +117,7 @@ module Matchers
context "#new" do
it "passes matches? arg to match block" do
- matcher = Rspec::Matchers::Matcher.new(:ignore) do
+ matcher = RSpec::Matchers::Matcher.new(:ignore) do
match do |actual|
actual == 5
end
@@ -126,7 +126,7 @@ module Matchers
end
it "exposes arg submitted through #new to matcher block" do
- matcher = Rspec::Matchers::Matcher.new(:ignore, 4) do |expected|
+ matcher = RSpec::Matchers::Matcher.new(:ignore, 4) do |expected|
match do |actual|
actual > expected
end
@@ -137,7 +137,7 @@ module Matchers
context "with no args" do
before(:each) do
- @matcher = Rspec::Matchers::Matcher.new(:matcher_name) do
+ @matcher = RSpec::Matchers::Matcher.new(:matcher_name) do
match do |actual|
actual == 5
end
@@ -155,7 +155,7 @@ module Matchers
context "with 1 arg" do
before(:each) do
- @matcher = Rspec::Matchers::Matcher.new(:matcher_name, 1) do |expected|
+ @matcher = RSpec::Matchers::Matcher.new(:matcher_name, 1) do |expected|
match do |actual|
actual == 5 && expected == 1
end
@@ -173,7 +173,7 @@ module Matchers
context "with multiple args" do
before(:each) do
- @matcher = Rspec::Matchers::Matcher.new(:matcher_name, 1, 2, 3, 4) do |a,b,c,d|
+ @matcher = RSpec::Matchers::Matcher.new(:matcher_name, 1, 2, 3, 4) do |a,b,c,d|
match do |sum|
a + b + c + d == sum
end
@@ -190,7 +190,7 @@ module Matchers
end
it "supports helper methods" do
- matcher = Rspec::Matchers::Matcher.new(:be_similar_to, [1,2,3]) do |sample|
+ matcher = RSpec::Matchers::Matcher.new(:be_similar_to, [1,2,3]) do |sample|
match do |actual|
similar?(sample, actual)
end
@@ -204,7 +204,7 @@ def similar?(a, b)
end
it "supports fluent interface" do
- matcher = Rspec::Matchers::Matcher.new(:first_word) do
+ matcher = RSpec::Matchers::Matcher.new(:first_word) do
def second_word
self
end
@@ -214,14 +214,14 @@ def second_word
end
it "treats method missing normally for undeclared methods" do
- matcher = Rspec::Matchers::Matcher.new(:ignore) { }
+ matcher = RSpec::Matchers::Matcher.new(:ignore) { }
expect { matcher.non_existent_method }.to raise_error(NoMethodError)
end
it "has access to other matchers" do
- matcher = Rspec::Matchers::Matcher.new(:ignore, 3) do |expected|
+ matcher = RSpec::Matchers::Matcher.new(:ignore, 3) do |expected|
match do |actual|
- extend Rspec::Matchers
+ extend RSpec::Matchers
actual.should eql(5 + expected)
end
end
@@ -240,7 +240,7 @@ def assert_equal(a,b)
end
let(:matcher) do
m = mod
- Rspec::Matchers::Matcher.new :equal, 4 do |expected|
+ RSpec::Matchers::Matcher.new :equal, 4 do |expected|
extend m
match_unless_raises UnexpectedError do
assert_equal expected, actual
@@ -257,7 +257,7 @@ def assert_equal(a,b)
context "with an unexpected error" do
let(:matcher) do
- Rspec::Matchers::Matcher.new :foo, :bar do |expected|
+ RSpec::Matchers::Matcher.new :foo, :bar do |expected|
match_unless_raises SyntaxError do |actual|
raise "unexpected exception"
end
@@ -274,7 +274,7 @@ def assert_equal(a,b)
end
it "can define chainable methods" do
- matcher = Rspec::Matchers::Matcher.new(:name) do
+ matcher = RSpec::Matchers::Matcher.new(:name) do
chain(:expecting) do |expected_value|
@expected_value = expected_value
end
@@ -291,7 +291,7 @@ def a_method_in_the_example
end
it "can access methods in the running_example" do
- Rspec::Matchers.define(:__access_running_example) do
+ RSpec::Matchers.define(:__access_running_example) do
match do |actual|
a_method_in_the_example == "method defined in the example"
end
@@ -300,15 +300,15 @@ def a_method_in_the_example
end
it "raises NoMethodError for methods not in the running_example" do
- Rspec::Matchers.define(:__raise_no_method_error) do
+ RSpec::Matchers.define(:__raise_no_method_error) do
match do |actual|
a_method_not_in_the_example == "method defined in the example"
end
end
expect do
running_example.should __raise_no_method_error
- end.to raise_error(/Rspec::Matchers::Matcher/)
+ end.to raise_error(/RSpec::Matchers::Matcher/)
end
end
View
24 spec/rspec/matchers/operator_matcher_spec.rb
@@ -15,7 +15,7 @@
it "should fail when target.==(actual) returns false" do
subject = "apple"
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
subject.should == "orange"
end
@@ -36,7 +36,7 @@
it "should fail when target.==(actual) returns false" do
subject = "apple"
- Rspec::Expectations.should_receive(:fail_with).with(%[expected not: