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
@@ -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
@@ -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
@@ -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
@@ -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"
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
@@ -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)
@@ -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.
@@ -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
@@ -1,4 +1,4 @@
-module Rspec
+module RSpec
module Core
class ExampleGroup
module BlockAliases
@@ -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
@@ -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
@@ -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
Oops, something went wrong.

0 comments on commit ba95bb1

Please sign in to comment.