Skip to content
This repository
Browse code

change top-level module from Rspec to RSpec

- capture const_missing on Rspec and return RSpec
  • Loading branch information...
commit ba95bb14b82dcd17c3dc0c6e79bc2ef27409668f 1 parent 4902ca2
David Chelimsky authored May 16, 2010

Showing 66 changed files with 271 additions and 258 deletions. Show diff stats Hide diff stats

  1. 2  README.markdown
  2. 14  Rakefile
  3. 12  Upgrade.markdown
  4. 6  features/matchers/access_running_example.feature
  5. 2  features/matchers/define_diffable_matcher.feature
  6. 14  features/matchers/define_matcher.feature
  7. 4  features/matchers/define_matcher_outside_rspec.feature
  8. 2  features/matchers/define_matcher_with_fluent_interface.feature
  9. 11  lib/rspec/expectations.rb
  10. 12  lib/rspec/expectations/backward_compatibility.rb
  11. 2  lib/rspec/expectations/differs/default.rb
  12. 2  lib/rspec/expectations/errors.rb
  13. 8  lib/rspec/expectations/extensions/kernel.rb
  14. 2  lib/rspec/expectations/extensions/rspec/core/example_group.rb
  15. 6  lib/rspec/expectations/fail_with.rb
  16. 22  lib/rspec/expectations/handler.rb
  17. 2  lib/rspec/expectations/version.rb
  18. 15  lib/rspec/matchers.rb
  19. 12  lib/rspec/matchers/be.rb
  20. 2  lib/rspec/matchers/be_close.rb
  21. 2  lib/rspec/matchers/be_instance_of.rb
  22. 2  lib/rspec/matchers/be_kind_of.rb
  23. 2  lib/rspec/matchers/change.rb
  24. 4  lib/rspec/matchers/compatibility.rb
  25. 8  lib/rspec/matchers/dsl.rb
  26. 2  lib/rspec/matchers/eq.rb
  27. 2  lib/rspec/matchers/eql.rb
  28. 2  lib/rspec/matchers/equal.rb
  29. 2  lib/rspec/matchers/errors.rb
  30. 2  lib/rspec/matchers/exist.rb
  31. 2  lib/rspec/matchers/extensions/instance_exec.rb
  32. 2  lib/rspec/matchers/generated_descriptions.rb
  33. 2  lib/rspec/matchers/has.rb
  34. 2  lib/rspec/matchers/have.rb
  35. 2  lib/rspec/matchers/include.rb
  36. 2  lib/rspec/matchers/match.rb
  37. 6  lib/rspec/matchers/match_array.rb
  38. 26  lib/rspec/matchers/matcher.rb
  39. 2  lib/rspec/matchers/method_missing.rb
  40. 8  lib/rspec/matchers/operator_matcher.rb
  41. 2  lib/rspec/matchers/pretty.rb
  42. 2  lib/rspec/matchers/raise_error.rb
  43. 2  lib/rspec/matchers/respond_to.rb
  44. 2  lib/rspec/matchers/satisfy.rb
  45. 2  lib/rspec/matchers/throw_symbol.rb
  46. 3  rspec-expectations.gemspec
  47. 14  spec/rspec/expectations/differs/default_spec.rb
  48. 40  spec/rspec/expectations/fail_with_spec.rb
  49. 44  spec/rspec/expectations/handler_spec.rb
  50. 2  spec/rspec/matchers/be_close_spec.rb
  51. 2  spec/rspec/matchers/be_instance_of_spec.rb
  52. 2  spec/rspec/matchers/be_kind_of_spec.rb
  53. 6  spec/rspec/matchers/change_spec.rb
  54. 6  spec/rspec/matchers/compatibility_spec.rb
  55. 56  spec/rspec/matchers/description_generation_spec.rb
  56. 6  spec/rspec/matchers/dsl_spec.rb
  57. 2  spec/rspec/matchers/eq_spec.rb
  58. 2  spec/rspec/matchers/eql_spec.rb
  59. 2  spec/rspec/matchers/equal_spec.rb
  60. 2  spec/rspec/matchers/exist_spec.rb
  61. 6  spec/rspec/matchers/have_spec.rb
  62. 50  spec/rspec/matchers/matcher_spec.rb
  63. 24  spec/rspec/matchers/operator_matcher_spec.rb
  64. 2  spec/rspec/matchers/throw_symbol_spec.rb
  65. 12  spec/spec_helper.rb
  66. 2  spec/support/classes.rb
2  README.markdown
Source Rendered
... ...
@@ -1,7 +1,7 @@
1 1
 # RSpec Expectations
2 2
 
3 3
 rspec-expectations adds `should` and `should_not` to every object and includes
4  
-Rspec::Matchers, a library of standard matchers.
  4
+RSpec::Matchers, a library of standard matchers.
5 5
 
6 6
 rspec-expectations is currently in alpha release. While you are welcome to
7 7
 track, fork, explore, etc, we're too early in the process to start fielding
14  Rakefile
@@ -6,8 +6,8 @@ begin
6 6
   require 'jeweler'
7 7
   Jeweler::Tasks.new do |gem|
8 8
     gem.name = "rspec-expectations"
9  
-    gem.version = Rspec::Expectations::Version::STRING
10  
-    gem.summary = "rspec-expectations-#{Rspec::Expectations::Version::STRING}"
  9
+    gem.version = RSpec::Expectations::Version::STRING
  10
+    gem.summary = "rspec-expectations-#{RSpec::Expectations::Version::STRING}"
11 11
     gem.description = "rspec expectations (should[_not] and matchers)"
12 12
     gem.rubyforge_project = "rspec"
13 13
     gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
@@ -15,8 +15,8 @@ begin
15 15
     gem.authors = ["David Chelimsky", "Chad Humphries"]    
16 16
     gem.add_development_dependency('cucumber', ">= 0.6.2")
17 17
     gem.add_development_dependency('aruba', ">= 0.1.1")
18  
-    gem.add_development_dependency('rspec-core', ">= #{Rspec::Expectations::Version::STRING}")
19  
-    gem.add_development_dependency('rspec-mocks', ">= #{Rspec::Expectations::Version::STRING}")
  18
+    gem.add_development_dependency('rspec-core', ">= #{RSpec::Expectations::Version::STRING}")
  19
+    gem.add_development_dependency('rspec-mocks', ">= #{RSpec::Expectations::Version::STRING}")
20 20
     gem.post_install_message = <<-EOM
21 21
 #{"*"*50}
22 22
 
@@ -36,15 +36,15 @@ end
36 36
 namespace :gem do
37 37
   desc "push to gemcutter"
38 38
   task :push => :build do
39  
-    system "gem push pkg/rspec-expectations-#{Rspec::Expectations::Version::STRING}.gem"
  39
+    system "gem push pkg/rspec-expectations-#{RSpec::Expectations::Version::STRING}.gem"
40 40
   end
41 41
 end
42 42
 
43 43
 begin
44 44
   require 'rspec/core/rake_task'
45  
-  Rspec::Core::RakeTask.new(:spec)
  45
+  RSpec::Core::RakeTask.new(:spec)
46 46
 rescue LoadError
47  
-  puts "Rspec core or one of its dependencies is not installed. Install it with: gem install rspec-core"
  47
+  puts "RSpec core or one of its dependencies is not installed. Install it with: gem install rspec-core"
48 48
 end
49 49
 
50 50
 begin
12  Upgrade.markdown
Source Rendered
@@ -4,7 +4,7 @@
4 4
 
5 5
 ### New `eq` matcher.
6 6
 
7  
-`Rspec::Matchers` now offers you two approaches to differentiating between
  7
+`RSpec::Matchers` now offers you two approaches to differentiating between
8 8
 object identity. You can use the rspec-1 approach:
9 9
 
10 10
     actual.should == expected     # object equality
@@ -19,7 +19,7 @@ object identity. You can use the rspec-1 approach:
19 19
 
20 20
 ### simple_matcher
21 21
 
22  
-Use Rspec::Matchers.define instead. For example, if you had:
  22
+Use RSpec::Matchers.define instead. For example, if you had:
23 23
 
24 24
     def eat_cheese
25 25
       simple_matcher("eat cheese") do |actual|
@@ -29,7 +29,7 @@ Use Rspec::Matchers.define instead. For example, if you had:
29 29
 
30 30
 Change it to:
31 31
 
32  
-    Rspec::Matchers.define :eat_cheese do
  32
+    RSpec::Matchers.define :eat_cheese do
33 33
       match do |actual|
34 34
         actual.eat?(:cheese)
35 35
       end
@@ -37,15 +37,15 @@ Change it to:
37 37
 
38 38
 ### wrap_expectation
39 39
 
40  
-Use Rspec::Matchers.define instead.
  40
+Use RSpec::Matchers.define instead.
41 41
 
42  
-    Rspec::Matchers.define :eat_cheese do
  42
+    RSpec::Matchers.define :eat_cheese do
43 43
       match do |actual|
44 44
         actual.should eat?(:cheese)
45 45
       end
46 46
     end
47 47
 
48  
-    Rspec::Matchers.define :eat_cheese do
  48
+    RSpec::Matchers.define :eat_cheese do
49 49
       include MyCheesyAssertions
50 50
       match_unless_raises Test::Unit::AssertionFailedError do |actual|
51 51
         assert_eats_chesse actual
6  features/matchers/access_running_example.feature
@@ -12,7 +12,7 @@ Feature: access running example
12 12
   Scenario: call method defined on example from matcher
13 13
     Given a file named "example_spec.rb" with:
14 14
       """
15  
-      Rspec::Matchers.define :bar do
  15
+      RSpec::Matchers.define :bar do
16 16
         match do |_|
17 17
           foo == "foo"
18 18
         end
@@ -34,7 +34,7 @@ Feature: access running example
34 34
   Scenario: call method _not_ defined on example from matcher
35 35
     Given a file named "example_spec.rb" with:
36 36
       """
37  
-      Rspec::Matchers.define :bar do
  37
+      RSpec::Matchers.define :bar do
38 38
         match do |_|
39 39
           foo == "foo"
40 40
         end
@@ -49,5 +49,5 @@ Feature: access running example
49 49
     When I run "rspec example_spec.rb"
50 50
     Then I should see "1 example, 1 failure"
51 51
     And I should see "undefined local variable"
52  
-    And I should see "Rspec::Matchers::Matcher"
  52
+    And I should see "RSpec::Matchers::Matcher"
53 53
     And I should not see "ExampleGroup"
2  features/matchers/define_diffable_matcher.feature
@@ -8,7 +8,7 @@ Feature: define diffable matcher
8 8
   Scenario: define a diffable matcher
9 9
     Given a file named "diffable_matcher_spec.rb" with:
10 10
       """
11  
-      Rspec::Matchers.define :be_just_like do |expected|
  11
+      RSpec::Matchers.define :be_just_like do |expected|
12 12
         match do |actual|
13 13
           actual == expected
14 14
         end
14  features/matchers/define_matcher.feature
@@ -9,7 +9,7 @@ Feature: define matcher
9 9
       """
10 10
       require 'rspec/expectations'
11 11
 
12  
-      Rspec::Matchers.define :be_a_multiple_of do |expected|
  12
+      RSpec::Matchers.define :be_a_multiple_of do |expected|
13 13
         match do |actual|
14 14
           actual % expected == 0
15 15
         end
@@ -51,7 +51,7 @@ Feature: define matcher
51 51
       """
52 52
       require 'rspec/expectations'
53 53
 
54  
-      Rspec::Matchers.define :be_a_multiple_of do |expected|
  54
+      RSpec::Matchers.define :be_a_multiple_of do |expected|
55 55
         match do |actual|
56 56
           actual % expected == 0
57 57
         end
@@ -75,7 +75,7 @@ Feature: define matcher
75 75
       """
76 76
       require 'rspec/expectations'
77 77
 
78  
-      Rspec::Matchers.define :be_a_multiple_of do |expected|
  78
+      RSpec::Matchers.define :be_a_multiple_of do |expected|
79 79
         match do |actual|
80 80
           actual % expected == 0
81 81
         end
@@ -99,7 +99,7 @@ Feature: define matcher
99 99
       """
100 100
       require 'rspec/expectations'
101 101
 
102  
-      Rspec::Matchers.define :be_a_multiple_of do |expected|
  102
+      RSpec::Matchers.define :be_a_multiple_of do |expected|
103 103
         match do |actual|
104 104
           actual % expected == 0
105 105
         end
@@ -127,7 +127,7 @@ Feature: define matcher
127 127
       """
128 128
       require 'rspec/expectations'
129 129
 
130  
-      Rspec::Matchers.define :have_7_fingers do
  130
+      RSpec::Matchers.define :have_7_fingers do
131 131
         match do |thing|
132 132
           thing.fingers.length == 7
133 133
         end
@@ -151,7 +151,7 @@ Feature: define matcher
151 151
       """
152 152
       require 'rspec/expectations'
153 153
 
154  
-      Rspec::Matchers.define :be_the_sum_of do |a,b,c,d|
  154
+      RSpec::Matchers.define :be_the_sum_of do |a,b,c,d|
155 155
         match do |sum|
156 156
           a + b + c + d == sum
157 157
         end
@@ -171,7 +171,7 @@ Feature: define matcher
171 171
       """
172 172
       require 'rspec/expectations'
173 173
 
174  
-      Rspec::Matchers.define :have_same_elements_as do |sample|
  174
+      RSpec::Matchers.define :have_same_elements_as do |sample|
175 175
         match do |actual|
176 176
           similar?(sample, actual)
177 177
         end
4  features/matchers/define_matcher_outside_rspec.feature
@@ -10,14 +10,14 @@ Feature: define matcher outside rspec
10 10
       require "rspec/expectations"
11 11
       require "test/unit"
12 12
       
13  
-      Rspec::Matchers.define :be_a_multiple_of do |expected|
  13
+      RSpec::Matchers.define :be_a_multiple_of do |expected|
14 14
         match do |actual|
15 15
           actual % expected == 0
16 16
         end
17 17
       end
18 18
       
19 19
       class Test::Unit::TestCase
20  
-        include Rspec::Matchers
  20
+        include RSpec::Matchers
21 21
       end
22 22
       
23 23
       class TestMultiples < Test::Unit::TestCase
2  features/matchers/define_matcher_with_fluent_interface.feature
@@ -7,7 +7,7 @@ Feature: define matcher
7 7
   Scenario: one additional method
8 8
     Given a file named "between_spec.rb" with:
9 9
       """
10  
-      Rspec::Matchers.define :be_bigger_than do |first|
  10
+      RSpec::Matchers.define :be_bigger_than do |first|
11 11
         def but_smaller_than(second)
12 12
           @second = second
13 13
           self
11  lib/rspec/expectations.rb
@@ -4,22 +4,23 @@
4 4
 require 'rspec/expectations/extensions'
5 5
 require 'rspec/expectations/handler'
6 6
 require 'rspec/expectations/version'
  7
+require 'rspec/expectations/backward_compatibility'
7 8
 
8  
-module Rspec
  9
+module RSpec
9 10
   
10  
-  # Rspec::Expectations lets you set expectations on your objects.
  11
+  # RSpec::Expectations lets you set expectations on your objects.
11 12
   #
12 13
   #   result.should == 37
13 14
   #   team.should have(11).players_on_the_field
14 15
   #
15 16
   # == How Expectations work.
16 17
   #
17  
-  # Rspec::Expectations adds two methods to Object:
  18
+  # RSpec::Expectations adds two methods to Object:
18 19
   #
19 20
   #   should(matcher=nil)
20 21
   #   should_not(matcher=nil)
21 22
   #
22  
-  # Both methods take an optional Expression Matcher (See Rspec::Matchers).
  23
+  # Both methods take an optional Expression Matcher (See RSpec::Matchers).
23 24
   #
24 25
   # When +should+ receives an Expression Matcher, it calls <tt>matches?(self)</tt>. If
25 26
   # it returns +true+, the spec passes and execution continues. If it returns
@@ -30,7 +31,7 @@ module Rspec
30 31
   # +true+, then the spec fails with the message returned by <tt>matcher.negative_failure_message</tt>.
31 32
   #
32 33
   # RSpec ships with a standard set of useful matchers, and writing your own
33  
-  # matchers is quite simple. See Rspec::Matchers for details.
  34
+  # matchers is quite simple. See RSpec::Matchers for details.
34 35
   module Expectations
35 36
   end
36 37
 end
12  lib/rspec/expectations/backward_compatibility.rb
... ...
@@ -0,0 +1,12 @@
  1
+# Cucumber 0.7 includes Rspec::Expectations
  2
+module RSpec
  3
+  module Expectations
  4
+    module ConstMissing
  5
+      def const_missing(name)
  6
+        name == :Rspec ? RSpec : super(name)
  7
+      end
  8
+    end
  9
+  end
  10
+end
  11
+
  12
+Object.extend(RSpec::Expectations::ConstMissing)
2  lib/rspec/expectations/differs/default.rb
... ...
@@ -1,7 +1,7 @@
1 1
 require File.join(File.dirname(__FILE__), "/load-diff-lcs")
2 2
 require 'pp'
3 3
 
4  
-module Rspec
  4
+module RSpec
5 5
   module Expectations
6 6
     module Differs
7 7
       unless defined?(Default)
2  lib/rspec/expectations/errors.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Expectations
3 3
     # If Test::Unit is loaed, we'll use its error as baseclass, so that Test::Unit
4 4
     # will report unmet RSpec expectations as failures rather than errors.
8  lib/rspec/expectations/extensions/kernel.rb
@@ -17,14 +17,14 @@ module Kernel
17 17
   #   receiver.should =~ regexp
18 18
   #     => Passes if (receiver =~ regexp)
19 19
   #
20  
-  # See Rspec::Matchers for more information about matchers
  20
+  # See RSpec::Matchers for more information about matchers
21 21
   #
22 22
   # == Warning
23 23
   #
24 24
   # NOTE that this does NOT support receiver.should != expected.
25 25
   # Instead, use receiver.should_not == expected
26 26
   def should(matcher=nil, message=nil, &block)
27  
-    Rspec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
  27
+    RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
28 28
   end
29 29
   
30 30
   # :call-seq:
@@ -45,8 +45,8 @@ def should(matcher=nil, message=nil, &block)
45 45
   #   receiver.should_not =~ regexp
46 46
   #     => Passes unless (receiver =~ regexp)
47 47
   #
48  
-  # See Rspec::Matchers for more information about matchers
  48
+  # See RSpec::Matchers for more information about matchers
49 49
   def should_not(matcher=nil, message=nil, &block)
50  
-    Rspec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
  50
+    RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
51 51
   end
52 52
 end
2  lib/rspec/expectations/extensions/rspec/core/example_group.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Core
3 3
     class ExampleGroup
4 4
       module BlockAliases
6  lib/rspec/expectations/fail_with.rb
... ...
@@ -1,9 +1,9 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Expectations
3 3
     class << self
4 4
       attr_accessor :differ
5 5
       
6  
-      # raises a Rspec::Expectations::ExpectationNotMetError with message
  6
+      # raises a RSpec::Expectations::ExpectationNotMetError with message
7 7
       #
8 8
       # When a differ has been assigned and fail_with is passed
9 9
       # <code>expected</code> and <code>target</code>, passes them
@@ -20,7 +20,7 @@ def fail_with(message, expected=nil, target=nil) # :nodoc:
20 20
             message << "\nDiff:" << self.differ.diff_as_object(target, expected)
21 21
           end
22 22
         end
23  
-        Kernel::raise(Rspec::Expectations::ExpectationNotMetError.new(message))
  23
+        Kernel::raise(RSpec::Expectations::ExpectationNotMetError.new(message))
24 24
       end
25 25
     end
26 26
   end
22  lib/rspec/expectations/handler.rb
... ...
@@ -1,12 +1,12 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Expectations
3 3
     class InvalidMatcherError < ArgumentError; end        
4 4
     
5 5
     class PositiveExpectationHandler        
6 6
       def self.handle_matcher(actual, matcher, message=nil, &block)
7  
-        ::Rspec::Matchers.last_should = :should
8  
-        ::Rspec::Matchers.last_matcher = matcher
9  
-        return ::Rspec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?
  7
+        ::RSpec::Matchers.last_should = :should
  8
+        ::RSpec::Matchers.last_matcher = matcher
  9
+        return ::RSpec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?
10 10
 
11 11
         match = matcher.matches?(actual, &block)
12 12
         return match if match
@@ -16,18 +16,18 @@ def self.handle_matcher(actual, matcher, message=nil, &block)
16 16
                     matcher.failure_message
17 17
         
18 18
         if matcher.respond_to?(:diffable?) && matcher.diffable?
19  
-          ::Rspec::Expectations.fail_with message, matcher.expected.first, matcher.actual
  19
+          ::RSpec::Expectations.fail_with message, matcher.expected.first, matcher.actual
20 20
         else
21  
-          ::Rspec::Expectations.fail_with message
  21
+          ::RSpec::Expectations.fail_with message
22 22
         end
23 23
       end
24 24
     end
25 25
 
26 26
     class NegativeExpectationHandler
27 27
       def self.handle_matcher(actual, matcher, message=nil, &block)
28  
-        ::Rspec::Matchers.last_should = :should_not
29  
-        ::Rspec::Matchers.last_matcher = matcher
30  
-        return ::Rspec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
  28
+        ::RSpec::Matchers.last_should = :should_not
  29
+        ::RSpec::Matchers.last_matcher = matcher
  30
+        return ::RSpec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
31 31
         
32 32
         match = matcher.respond_to?(:does_not_match?) ?
33 33
                 !matcher.does_not_match?(actual, &block) :
@@ -39,9 +39,9 @@ def self.handle_matcher(actual, matcher, message=nil, &block)
39 39
                     matcher.negative_failure_message
40 40
 
41 41
         if matcher.respond_to?(:diffable?) && matcher.diffable?
42  
-          ::Rspec::Expectations.fail_with message, matcher.expected.first, matcher.actual
  42
+          ::RSpec::Expectations.fail_with message, matcher.expected.first, matcher.actual
43 43
         else
44  
-          ::Rspec::Expectations.fail_with message
  44
+          ::RSpec::Expectations.fail_with message
45 45
         end
46 46
       end
47 47
     end
2  lib/rspec/expectations/version.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec # :nodoc:
  1
+module RSpec # :nodoc:
2 2
   module Expectations # :nodoc:
3 3
     module Version # :nodoc:
4 4
       STRING = File.readlines(File.expand_path('../../../../VERSION', __FILE__)).first
15  lib/rspec/matchers.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   # RSpec ships with a number of useful Expression Matchers. An Expression Matcher
3 3
   # is any object that responds to the following methods:
4 4
   #
@@ -17,7 +17,7 @@ module Rspec
17 17
   #   failure_message          (use failure_message_for_should instead)
18 18
   #   negative_failure_message (use failure_message_for_should_not instead)
19 19
   #
20  
-  # See Rspec::Expectations to learn how to use these as Expectation Matchers.
  20
+  # See RSpec::Expectations to learn how to use these as Expectation Matchers.
21 21
   #
22 22
   # == Predicates
23 23
   #
@@ -78,7 +78,7 @@ module Rspec
78 78
   #
79 79
   # You can create such a matcher like so:
80 80
   #
81  
-  #   Rspec::Matchers.define :be_in_zone do |zone|
  81
+  #   RSpec::Matchers.define :be_in_zone do |zone|
82 82
   #     match do |player|
83 83
   #       player.in_zone?(zone)
84 84
   #     end
@@ -88,7 +88,7 @@ module Rspec
88 88
   # with logical default messages for failures. You can override the failure
89 89
   # messages and the generated description as follows:
90 90
   #
91  
-  #   Rspec::Matchers.define :be_in_zone do |zone|
  91
+  #   RSpec::Matchers.define :be_in_zone do |zone|
92 92
   #     match do |player|
93 93
   #       player.in_zone?(zone)
94 94
   #     end
@@ -157,13 +157,13 @@ module Rspec
157 157
   # or you can include in globally in a spec_helper.rb file <tt>require</tt>d
158 158
   # from your spec file(s):
159 159
   #
160  
-  #   Rspec::Runner.configure do |config|
  160
+  #   RSpec::Runner.configure do |config|
161 161
   #     config.include(CustomGameMatchers)
162 162
   #   end
163 163
   #
164 164
   module Matchers
165  
-    if Rspec.respond_to?(:configure)
166  
-      Rspec.configure {|c| c.include self}
  165
+    if RSpec.respond_to?(:configure)
  166
+      RSpec.configure {|c| c.include self}
167 167
     end
168 168
   end
169 169
 end
@@ -195,4 +195,3 @@ module Matchers
195 195
 require 'rspec/matchers/throw_symbol'
196 196
 require 'rspec/matchers/compatibility'
197 197
 require 'rspec/matchers/dsl'
198  
-
12  lib/rspec/matchers/be.rb
... ...
@@ -1,18 +1,18 @@
1 1
 require 'rspec/matchers/dsl'
2 2
 
3  
-Rspec::Matchers.define :be_true do
  3
+RSpec::Matchers.define :be_true do
4 4
   match do |actual|
5 5
     !!actual
6 6
   end
7 7
 end
8 8
 
9  
-Rspec::Matchers.define :be_false do
  9
+RSpec::Matchers.define :be_false do
10 10
   match do |actual|
11 11
     !actual
12 12
   end
13 13
 end
14 14
 
15  
-Rspec::Matchers.define :be_nil do
  15
+RSpec::Matchers.define :be_nil do
16 16
   match do |actual|
17 17
     actual.nil?
18 18
   end
@@ -26,11 +26,11 @@
26 26
   end
27 27
 end
28 28
 
29  
-module Rspec
  29
+module RSpec
30 30
   module Matchers
31 31
 
32 32
     class Be #:nodoc:
33  
-      include Rspec::Matchers::Pretty
  33
+      include RSpec::Matchers::Pretty
34 34
       
35 35
       def initialize(*args, &block)
36 36
         @args = args
@@ -216,7 +216,7 @@ def description
216 216
     # the caller should satisfy an if condition (to be or not to be). 
217 217
     #
218 218
     # Predicates are any Ruby method that ends in a "?" and returns true or false.
219  
-    # Given be_ followed by arbitrary_predicate (without the "?"), Rspec will match
  219
+    # Given be_ followed by arbitrary_predicate (without the "?"), RSpec will match
220 220
     # convert that into a query against the target object.
221 221
     #
222 222
     # The arbitrary_predicate feature will handle any predicate
2  lib/rspec/matchers/be_close.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should be_close(expected, delta)
2  lib/rspec/matchers/be_instance_of.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should be_instance_of(expected)
2  lib/rspec/matchers/be_kind_of.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should be_kind_of(expected)
2  lib/rspec/matchers/change.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     
4 4
     #Based on patch from Wilson Bilkovich
4  lib/rspec/matchers/compatibility.rb
... ...
@@ -1,5 +1,5 @@
1  
-Rspec::Matchers.constants.each do |c|
2  
-  if Class === (klass = Rspec::Matchers.const_get(c))
  1
+RSpec::Matchers.constants.each do |c|
  2
+  if Class === (klass = RSpec::Matchers.const_get(c))
3 3
     if klass.public_instance_methods.any? {|m| ['failure_message_for_should',:failure_message_for_should].include?(m)}
4 4
       klass.class_eval do
5 5
         alias_method :failure_message, :failure_message_for_should
8  lib/rspec/matchers/dsl.rb
... ...
@@ -1,15 +1,15 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     module DSL
4  
-      # See Rspec::Matchers
  4
+      # See RSpec::Matchers
5 5
       def define(name, &declarations)
6 6
         define_method name do |*expected|
7 7
           $matcher_execution_context = self
8  
-          Rspec::Matchers::Matcher.new name, *expected, &declarations
  8
+          RSpec::Matchers::Matcher.new name, *expected, &declarations
9 9
         end
10 10
       end
11 11
     end
12 12
   end
13 13
 end
14 14
 
15  
-Rspec::Matchers.extend Rspec::Matchers::DSL
  15
+RSpec::Matchers.extend RSpec::Matchers::DSL
2  lib/rspec/matchers/eq.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should eq(expected)
2  lib/rspec/matchers/eql.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should eql(expected)
2  lib/rspec/matchers/equal.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
 
4 4
     # :call-seq:
2  lib/rspec/matchers/errors.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     class MatcherError < StandardError; end
4 4
   end
2  lib/rspec/matchers/exist.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should exist
2  lib/rspec/matchers/extensions/instance_exec.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     module InstanceExec
4 4
       unless respond_to?(:instance_exec)
2  lib/rspec/matchers/generated_descriptions.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     class << self
4 4
       attr_accessor :last_matcher, :last_should # :nodoc:
2  lib/rspec/matchers/has.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     
4 4
     class Has
2  lib/rspec/matchers/have.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     class Have #:nodoc:
4 4
       def initialize(expected, relativity=:exactly)
2  lib/rspec/matchers/include.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should include(expected)
2  lib/rspec/matchers/match.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     # :call-seq:
4 4
     #   should match(pattern)
6  lib/rspec/matchers/match_array.rb
... ...
@@ -1,8 +1,8 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
 
4 4
     class MatchArray #:nodoc:
5  
-      include Rspec::Matchers::Pretty
  5
+      include RSpec::Matchers::Pretty
6 6
       
7 7
       def initialize(expected)
8 8
         @expected = expected
@@ -66,6 +66,6 @@ def difference_between_arrays(array_1, array_2)
66 66
     #   [1,2,3,4].should =~ [1,2,3]   # => would fail
67 67
     #   [1,2,2,3].should =~ [1,2,3]   # => would fail
68 68
     #   [1,2,3].should   =~ [1,2,3,4] # => would fail
69  
-    OperatorMatcher.register(Array, '=~', Rspec::Matchers::MatchArray)
  69
+    OperatorMatcher.register(Array, '=~', RSpec::Matchers::MatchArray)
70 70
   end
71 71
 end
26  lib/rspec/matchers/matcher.rb
... ...
@@ -1,9 +1,9 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     class Matcher
4  
-      include Rspec::Matchers::InstanceExec
5  
-      include Rspec::Matchers::Pretty
6  
-      include Rspec::Matchers
  4
+      include RSpec::Matchers::InstanceExec
  5
+      include RSpec::Matchers::Pretty
  6
+      include RSpec::Matchers
7 7
 
8 8
       attr_reader :expected, :actual
9 9
       def initialize(name, *expected, &declarations)
@@ -35,34 +35,34 @@ def matches?(actual)
35 35
         else
36 36
           begin
37 37
             instance_exec(actual, &@match_block)
38  
-          rescue Rspec::Expectations::ExpectationNotMetError
  38
+          rescue RSpec::Expectations::ExpectationNotMetError
39 39
             false
40 40
           end
41 41
         end
42 42
       end
43 43
 
44  
-      # See Rspec::Matchers
  44
+      # See RSpec::Matchers
45 45
       def match(&block)
46 46
         @match_block = block
47 47
       end
48 48
 
49  
-      # See Rspec::Matchers
  49
+      # See RSpec::Matchers
50 50
       def match_unless_raises(exception=Exception, &block)
51 51
         @expected_exception = exception
52 52
         match(&block)
53 53
       end
54 54
 
55  
-      # See Rspec::Matchers
  55
+      # See RSpec::Matchers
56 56
       def failure_message_for_should(&block)
57 57
         cache_or_call_cached(:failure_message_for_should, &block)
58 58
       end
59 59
 
60  
-      # See Rspec::Matchers
  60
+      # See RSpec::Matchers
61 61
       def failure_message_for_should_not(&block)
62 62
         cache_or_call_cached(:failure_message_for_should_not, &block)
63 63
       end
64 64
 
65  
-      # See Rspec::Matchers
  65
+      # See RSpec::Matchers
66 66
       def description(&block)
67 67
         cache_or_call_cached(:description, &block)
68 68
       end
@@ -72,12 +72,12 @@ def diffable?
72 72
         @diffable
73 73
       end
74 74
 
75  
-      # See Rspec::Matchers
  75
+      # See RSpec::Matchers
76 76
       def diffable
77 77
         @diffable = true
78 78
       end
79 79
       
80  
-      # See Rspec::Matchers
  80
+      # See RSpec::Matchers
81 81
       def chain(method, &block)
82 82
         self.class.class_eval do
83 83
           define_method method do |*args|
@@ -105,7 +105,7 @@ def making_declared_methods_public # :nodoc:
105 105
         #
106 106
         # Also, due some crazy scoping that I don't understand, these methods
107 107
         # are actually available in the specs (something about the matcher being
108  
-        # defined in the scope of Rspec::Matchers or within an example), so not
  108
+        # defined in the scope of RSpec::Matchers or within an example), so not
109 109
         # doing the following will not cause specs to fail, but they *will*
110 110
         # cause features to fail and that will make users unhappy. So don't.
111 111
         orig_private_methods = private_methods
2  lib/rspec/matchers/method_missing.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     def method_missing(sym, *args, &block) # :nodoc:
4 4
       return Matchers::BePredicate.new(sym, *args, &block) if sym.to_s =~ /^be_/
8  lib/rspec/matchers/operator_matcher.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
 
4 4
     class OperatorMatcher
@@ -24,7 +24,7 @@ def initialize(actual)
24 24
       def self.use_custom_matcher_or_delegate(operator)
25 25
         define_method(operator) do |expected|
26 26
           if matcher = OperatorMatcher.get(@actual.class, operator)
27  
-            @actual.send(::Rspec::Matchers.last_should, matcher.new(expected))
  27
+            @actual.send(::RSpec::Matchers.last_should, matcher.new(expected))
28 28
           else
29 29
             eval_match(@actual, operator, expected)
30 30
           end
@@ -36,7 +36,7 @@ def self.use_custom_matcher_or_delegate(operator)
36 36
       end
37 37
 
38 38
       def fail_with_message(message)
39  
-        Rspec::Expectations.fail_with(message, @expected, @actual)
  39
+        RSpec::Expectations.fail_with(message, @expected, @actual)
40 40
       end
41 41
 
42 42
       def description
@@ -46,7 +46,7 @@ def description
46 46
     private
47 47
       
48 48
       def eval_match(actual, operator, expected)
49  
-        ::Rspec::Matchers.last_matcher = self
  49
+        ::RSpec::Matchers.last_matcher = self
50 50
         @operator, @expected = operator, expected
51 51
         __delegate_operator(actual, operator, expected)
52 52
       end
2  lib/rspec/matchers/pretty.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     module Pretty
4 4
       def split_words(sym)
2  lib/rspec/matchers/raise_error.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     class RaiseError #:nodoc:
4 4
       def initialize(expected_error_or_message=Exception, expected_message=nil, &block)
2  lib/rspec/matchers/respond_to.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     
4 4
     class RespondTo #:nodoc:
2  lib/rspec/matchers/satisfy.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     
4 4
     class Satisfy #:nodoc:
2  lib/rspec/matchers/throw_symbol.rb
... ...
@@ -1,4 +1,4 @@
1  
-module Rspec
  1
+module RSpec
2 2
   module Matchers
3 3
     
4 4
     class ThrowSymbol #:nodoc:
3  rspec-expectations.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9 9
 
10 10
   s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11 11
   s.authors = ["David Chelimsky", "Chad Humphries"]
12  
-  s.date = %q{2010-04-27}
  12
+  s.date = %q{2010-05-16}
13 13
   s.description = %q{rspec expectations (should[_not] and matchers)}
14 14
   s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
15 15
   s.extra_rdoc_files = [
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35 35
      "features/matchers/expect_error.feature",
36 36
      "features/support/env.rb",
37 37
      "lib/rspec/expectations.rb",
  38
+     "lib/rspec/expectations/backward_compatibility.rb",
38 39
      "lib/rspec/expectations/differs/default.rb",
39 40
      "lib/rspec/expectations/differs/load-diff-lcs.rb",
40 41
      "lib/rspec/expectations/errors.rb",
14  spec/rspec/expectations/differs/default_spec.rb
... ...
@@ -1,7 +1,7 @@
1 1
 require 'spec_helper'
2 2
 require 'ostruct'
3 3
 
4  
-module Rspec
  4
+module RSpec
5 5
   module Fixtures
6 6
     class Animal
7 7
       def initialize(name,species)
@@ -23,7 +23,7 @@ def inspect
23 23
 describe "Diff" do
24 24
   before(:each) do
25 25
     @options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
26  
-    @differ = Rspec::Expectations::Differs::Default.new(@options)
  26
+    @differ = RSpec::Expectations::Differs::Default.new(@options)
27 27
   end
28 28
 
29 29
   it "should output unified diff of two strings" do
@@ -76,8 +76,8 @@ def inspect
76 76
   end
77 77
 
78 78
   it "should output unified diff message of two objects" do
79  
-    expected = Rspec::Fixtures::Animal.new "bob", "giraffe"
80  
-    actual   = Rspec::Fixtures::Animal.new "bob", "tortoise"
  79
+    expected = RSpec::Fixtures::Animal.new "bob", "giraffe"
  80
+    actual   = RSpec::Fixtures::Animal.new "bob", "tortoise"
81 81
 
82 82
     expected_diff = <<'EOD'
83 83
 
@@ -100,12 +100,12 @@ def inspect
100 100
   before(:each) do
101 101
     @options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
102 102
     @options.diff_format = :context
103  
-    @differ = Rspec::Expectations::Differs::Default.new(@options)
  103
+    @differ = RSpec::Expectations::Differs::Default.new(@options)
104 104
   end
105 105
 
106 106
   it "should output unified diff message of two objects" do
107  
-    expected = Rspec::Fixtures::Animal.new "bob", "giraffe"
108  
-    actual   = Rspec::Fixtures::Animal.new "bob", "tortoise"
  107
+    expected = RSpec::Fixtures::Animal.new "bob", "giraffe"
  108
+    actual   = RSpec::Fixtures::Animal.new "bob", "tortoise"
109 109
 
110 110
     expected_diff = <<'EOD'
111 111
 
40  spec/rspec/expectations/fail_with_spec.rb
... ...
@@ -1,52 +1,52 @@
1 1
 require 'spec_helper'
2 2
 
3  
-describe Rspec::Expectations, "#fail_with with no diff" do
  3
+describe RSpec::Expectations, "#fail_with with no diff" do
4 4
   before(:each) do
5  
-    @old_differ = Rspec::Expectations.differ
6  
-    Rspec::Expectations.differ = nil
  5
+    @old_differ = RSpec::Expectations.differ
  6
+    RSpec::Expectations.differ = nil
7 7
   end
8 8
   
9 9
   it "should handle just a message" do
10 10
     lambda {
11  
-      Rspec::Expectations.fail_with "the message"
  11
+      RSpec::Expectations.fail_with "the message"
12 12
     }.should fail_with("the message")
13 13
   end
14 14
   
15 15
   after(:each) do
16  
-    Rspec::Expectations.differ = @old_differ
  16
+    RSpec::Expectations.differ = @old_differ
17 17
   end
18 18
 end
19 19
 
20  
-describe Rspec::Expectations, "#fail_with with Array" do
  20
+describe RSpec::Expectations, "#fail_with with Array" do
21 21
   before(:each) do
22  
-    Rspec::Core.stub!(:warn)
  22
+    RSpec::Core.stub!(:warn)
23 23
   end
24 24
 end
25 25
 
26  
-describe Rspec::Expectations, "#fail_with with diff" do
  26
+describe RSpec::Expectations, "#fail_with with diff" do
27 27
   before(:each) do
28  
-    @old_differ = Rspec::Expectations.differ
  28
+    @old_differ = RSpec::Expectations.differ
29 29
     @differ = mock("differ")
30  
-    Rspec::Expectations.differ = @differ
  30
+    RSpec::Expectations.differ = @differ
31 31
   end
32 32
   
33 33
   it "should not call differ if no expected/actual" do
34 34
     lambda {
35  
-      Rspec::Expectations.fail_with "the message"
  35
+      RSpec::Expectations.fail_with "the message"
36 36
     }.should fail_with("the message")
37 37
   end
38 38
   
39 39
   it "should call differ if expected/actual are presented separately" do
40 40
     @differ.should_receive(:diff_as_string).and_return("diff")
41 41
     lambda {
42  
-      Rspec::Expectations.fail_with "the message", "expected", "actual"
  42
+      RSpec::Expectations.fail_with "the message", "expected", "actual"
43 43
     }.should fail_with("the message\nDiff:diff")
44 44
   end
45 45
   
46 46
   it "should call differ if expected/actual are not strings" do
47 47
     @differ.should_receive(:diff_as_object).and_return("diff")
48 48
     lambda {
49  
-      Rspec::Expectations.fail_with "the message", :expected, :actual
  49
+      RSpec::Expectations.fail_with "the message", :expected, :actual
50 50
     }.should fail_with("the message\nDiff:diff")
51 51
   end
52 52
   
@@ -54,28 +54,28 @@
54 54
     @differ.should_not_receive(:diff_as_string)
55 55
     @differ.should_not_receive(:diff_as_object)
56 56
     lambda {
57  
-      Rspec::Expectations.fail_with "the message", lambda {}, lambda {}
  57
+      RSpec::Expectations.fail_with "the message", lambda {}, lambda {}
58 58
     }.should fail_with("the message")
59 59
   end
60 60
 
61 61
   after(:each) do
62  
-    Rspec::Expectations.differ = @old_differ
  62
+    RSpec::Expectations.differ = @old_differ
63 63
   end
64 64
 end
65 65
 
66  
-describe Rspec::Expectations, "#fail_with with a nil message" do
  66
+describe RSpec::Expectations, "#fail_with with a nil message" do
67 67
   before(:each) do
68  
-    @old_differ = Rspec::Expectations.differ
69  
-    Rspec::Expectations.differ = nil
  68
+    @old_differ = RSpec::Expectations.differ
  69
+    RSpec::Expectations.differ = nil
70 70
   end
71 71
 
72 72
   it "should handle just a message" do
73 73
     lambda {
74  
-      Rspec::Expectations.fail_with nil
  74
+      RSpec::Expectations.fail_with nil
75 75
     }.should raise_error(ArgumentError, /Failure message is nil\. Does your matcher define the appropriate failure_message_for_\* method to return a string\?/)
76 76
   end
77 77
 
78 78
   after(:each) do
79  
-    Rspec::Expectations.differ = @old_differ
  79
+    RSpec::Expectations.differ = @old_differ
80 80
   end
81 81
 end
44  spec/rspec/expectations/handler_spec.rb
@@ -44,7 +44,7 @@ def positive_only_matcher(*args, &block)
44 44
   
45 45
 end
46 46
 
47  
-module Rspec
  47
+module RSpec
48 48
   module Expectations
49 49
     describe PositiveExpectationHandler do
50 50
       describe "#handle_matcher" do
@@ -52,23 +52,23 @@ module Expectations
52 52
           matcher = mock("matcher")
53 53
           actual = Object.new
54 54
           matcher.should_receive(:matches?).with(actual).and_return(true)
55  
-          Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
  55
+          RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
56 56
         end
57 57
       
58 58
         it "returns the match value" do
59 59
           matcher = mock("matcher")
60 60
           actual = Object.new
61 61
           matcher.should_receive(:matches?).with(actual).and_return(:this_value)
62  
-          Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher).should == :this_value
  62
+          RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher).should == :this_value
63 63
         end
64 64
         
65 65
         it "calls failure_message_for_should if the matcher implements it" do
66 66
           matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false)
67 67
           actual = Object.new
68 68
           
69  
-          ::Rspec::Expectations.should_receive(:fail_with).with("message")
  69
+          ::RSpec::Expectations.should_receive(:fail_with).with("message")
70 70
           
71  
-          Rspec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
  71
+          RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
72 72
         end
73 73
         
74 74
         it "calls fail if matcher.diffable?" do
@@ -81,18 +81,18 @@ module Expectations
81 81
           )
82