rspec 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/History.txt +12 -1
  2. data/Manifest.txt +3 -3
  3. data/Rakefile +0 -1
  4. data/TODO.txt +8 -0
  5. data/bin/autospec +0 -1
  6. data/examples/pure/autogenerated_docstrings_example.rb +4 -4
  7. data/lib/autotest/discover.rb +1 -1
  8. data/lib/spec/example/errors.rb +19 -4
  9. data/lib/spec/example/example_group.rb +8 -1
  10. data/lib/spec/example/example_group_methods.rb +26 -20
  11. data/lib/spec/example/example_methods.rb +2 -7
  12. data/lib/spec/matchers/be.rb +18 -18
  13. data/lib/spec/matchers/be_close.rb +5 -5
  14. data/lib/spec/matchers/eql.rb +6 -6
  15. data/lib/spec/matchers/equal.rb +6 -6
  16. data/lib/spec/matchers/exist.rb +10 -5
  17. data/lib/spec/matchers/has.rb +2 -2
  18. data/lib/spec/matchers/have.rb +8 -8
  19. data/lib/spec/matchers/include.rb +5 -5
  20. data/lib/spec/matchers/match.rb +9 -9
  21. data/lib/spec/matchers/operator_matcher.rb +17 -17
  22. data/lib/spec/matchers/raise_error.rb +17 -17
  23. data/lib/spec/matchers/respond_to.rb +5 -4
  24. data/lib/spec/matchers/satisfy.rb +5 -5
  25. data/lib/spec/matchers/simple_matcher.rb +8 -8
  26. data/lib/spec/matchers/throw_symbol.rb +3 -3
  27. data/lib/spec/mocks.rb +0 -11
  28. data/lib/spec/mocks/argument_constraints.rb +5 -25
  29. data/lib/spec/mocks/argument_expectation.rb +19 -41
  30. data/lib/spec/mocks/message_expectation.rb +1 -1
  31. data/lib/spec/story/runner.rb +1 -1
  32. data/lib/spec/version.rb +2 -2
  33. data/rspec.gemspec +6 -6
  34. data/spec/{autotest_helper.rb → autotest/autotest_helper.rb} +2 -2
  35. data/spec/{autotest_matchers.rb → autotest/autotest_matchers.rb} +0 -0
  36. data/spec/autotest/discover_spec.rb +1 -1
  37. data/spec/autotest/rspec_spec.rb +1 -1
  38. data/spec/rspec_suite.rb +0 -1
  39. data/spec/spec/example/example_methods_spec.rb +36 -3
  40. data/spec/spec/example/pending_module_spec.rb +76 -0
  41. data/spec/spec/matchers/respond_to_spec.rb +6 -6
  42. data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +0 -34
  43. data/spec/spec/mocks/mock_spec.rb +6 -0
  44. data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +0 -44
  45. data/spec/spec/runner/drb_command_line_spec.rb +1 -1
  46. data/spec/spec/{example → runner/formatter}/base_formatter_spec.rb +1 -1
  47. data/spec/spec/runner/option_parser_spec.rb +1 -1
  48. data/spec/spec/runner/reporter_spec.rb +1 -1
  49. data/spec/spec/story/runner/story_runner_spec.rb +3 -3
  50. data/spec/spec/story/world_spec.rb +7 -7
  51. metadata +7 -7
@@ -7,8 +7,8 @@ module Spec
7
7
  @args = args
8
8
  end
9
9
 
10
- def matches?(target)
11
- target.__send__(predicate, *@args)
10
+ def matches?(given)
11
+ given.__send__(predicate, *@args)
12
12
  end
13
13
 
14
14
  def failure_message
@@ -24,12 +24,12 @@ module Spec
24
24
  else
25
25
  collection_owner.__send__(@collection_name, *@args, &@block)
26
26
  end
27
- @actual = collection.size if collection.respond_to?(:size)
28
- @actual = collection.length if collection.respond_to?(:length)
29
- raise not_a_collection if @actual.nil?
30
- return @actual >= @expected if @relativity == :at_least
31
- return @actual <= @expected if @relativity == :at_most
32
- return @actual == @expected
27
+ @given = collection.size if collection.respond_to?(:size)
28
+ @given = collection.length if collection.respond_to?(:length)
29
+ raise not_a_collection if @given.nil?
30
+ return @given >= @expected if @relativity == :at_least
31
+ return @given <= @expected if @relativity == :at_most
32
+ return @given == @expected
33
33
  end
34
34
 
35
35
  def not_a_collection
@@ -37,12 +37,12 @@ module Spec
37
37
  end
38
38
 
39
39
  def failure_message
40
- "expected #{relative_expectation} #{@collection_name}, got #{@actual}"
40
+ "expected #{relative_expectation} #{@collection_name}, got #{@given}"
41
41
  end
42
42
 
43
43
  def negative_failure_message
44
44
  if @relativity == :exactly
45
- return "expected target not to have #{@expected} #{@collection_name}, got #{@actual}"
45
+ return "expected target not to have #{@expected} #{@collection_name}, got #{@given}"
46
46
  elsif @relativity == :at_most
47
47
  return <<-EOF
48
48
  Isn't life confusing enough?
@@ -7,10 +7,10 @@ module Spec
7
7
  @expecteds = expecteds
8
8
  end
9
9
 
10
- def matches?(actual)
11
- @actual = actual
10
+ def matches?(given)
11
+ @given = given
12
12
  @expecteds.each do |expected|
13
- return false unless actual.include?(expected)
13
+ return false unless given.include?(expected)
14
14
  end
15
15
  true
16
16
  end
@@ -29,7 +29,7 @@ module Spec
29
29
 
30
30
  private
31
31
  def _message(maybe_not="")
32
- "expected #{@actual.inspect} #{maybe_not}to include #{_pretty_print(@expecteds)}"
32
+ "expected #{@given.inspect} #{maybe_not}to include #{_pretty_print(@expecteds)}"
33
33
  end
34
34
 
35
35
  def _pretty_print(array)
@@ -51,7 +51,7 @@ module Spec
51
51
  # should include(expected)
52
52
  # should_not include(expected)
53
53
  #
54
- # Passes if actual includes expected. This works for
54
+ # Passes if given includes expected. This works for
55
55
  # collections and Strings. You can also pass in multiple args
56
56
  # and it will only pass if all args are found in collection.
57
57
  #
@@ -2,26 +2,26 @@ module Spec
2
2
  module Matchers
3
3
 
4
4
  class Match #:nodoc:
5
- def initialize(expected)
6
- @expected = expected
5
+ def initialize(regexp)
6
+ @regexp = regexp
7
7
  end
8
8
 
9
- def matches?(actual)
10
- @actual = actual
11
- return true if actual =~ @expected
9
+ def matches?(given)
10
+ @given = given
11
+ return true if given =~ @regexp
12
12
  return false
13
13
  end
14
14
 
15
15
  def failure_message
16
- return "expected #{@actual.inspect} to match #{@expected.inspect}", @expected, @actual
16
+ return "expected #{@given.inspect} to match #{@regexp.inspect}", @regexp, @given
17
17
  end
18
18
 
19
19
  def negative_failure_message
20
- return "expected #{@actual.inspect} not to match #{@expected.inspect}", @expected, @actual
20
+ return "expected #{@given.inspect} not to match #{@regexp.inspect}", @regexp, @given
21
21
  end
22
22
 
23
23
  def description
24
- "match #{@expected.inspect}"
24
+ "match #{@regexp.inspect}"
25
25
  end
26
26
  end
27
27
 
@@ -29,7 +29,7 @@ module Spec
29
29
  # should match(regexp)
30
30
  # should_not match(regexp)
31
31
  #
32
- # Given a Regexp, passes if actual =~ regexp
32
+ # Given a Regexp, passes if given =~ regexp
33
33
  #
34
34
  # == Examples
35
35
  #
@@ -3,47 +3,47 @@ module Spec
3
3
  class BaseOperatorMatcher
4
4
  attr_reader :generated_description
5
5
 
6
- def initialize(target)
7
- @target = target
6
+ def initialize(given)
7
+ @given = given
8
8
  end
9
9
 
10
10
  def ==(expected)
11
11
  @expected = expected
12
- __delegate_method_missing_to_target("==", expected)
12
+ __delegate_method_missing_to_given("==", expected)
13
13
  end
14
14
 
15
15
  def ===(expected)
16
16
  @expected = expected
17
- __delegate_method_missing_to_target("===", expected)
17
+ __delegate_method_missing_to_given("===", expected)
18
18
  end
19
19
 
20
20
  def =~(expected)
21
21
  @expected = expected
22
- __delegate_method_missing_to_target("=~", expected)
22
+ __delegate_method_missing_to_given("=~", expected)
23
23
  end
24
24
 
25
25
  def >(expected)
26
26
  @expected = expected
27
- __delegate_method_missing_to_target(">", expected)
27
+ __delegate_method_missing_to_given(">", expected)
28
28
  end
29
29
 
30
30
  def >=(expected)
31
31
  @expected = expected
32
- __delegate_method_missing_to_target(">=", expected)
32
+ __delegate_method_missing_to_given(">=", expected)
33
33
  end
34
34
 
35
35
  def <(expected)
36
36
  @expected = expected
37
- __delegate_method_missing_to_target("<", expected)
37
+ __delegate_method_missing_to_given("<", expected)
38
38
  end
39
39
 
40
40
  def <=(expected)
41
41
  @expected = expected
42
- __delegate_method_missing_to_target("<=", expected)
42
+ __delegate_method_missing_to_given("<=", expected)
43
43
  end
44
44
 
45
45
  def fail_with_message(message)
46
- Spec::Expectations.fail_with(message, @expected, @target)
46
+ Spec::Expectations.fail_with(message, @expected, @given)
47
47
  end
48
48
 
49
49
  def description
@@ -54,23 +54,23 @@ module Spec
54
54
 
55
55
  class PositiveOperatorMatcher < BaseOperatorMatcher #:nodoc:
56
56
 
57
- def __delegate_method_missing_to_target(operator, expected)
57
+ def __delegate_method_missing_to_given(operator, expected)
58
58
  @operator = operator
59
59
  ::Spec::Matchers.last_matcher = self
60
- return true if @target.__send__(operator, expected)
61
- return fail_with_message("expected: #{expected.inspect},\n got: #{@target.inspect} (using #{operator})") if ['==','===', '=~'].include?(operator)
62
- return fail_with_message("expected: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@target.inspect}")
60
+ return true if @given.__send__(operator, expected)
61
+ return fail_with_message("expected: #{expected.inspect},\n got: #{@given.inspect} (using #{operator})") if ['==','===', '=~'].include?(operator)
62
+ return fail_with_message("expected: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@given.inspect}")
63
63
  end
64
64
 
65
65
  end
66
66
 
67
67
  class NegativeOperatorMatcher < BaseOperatorMatcher #:nodoc:
68
68
 
69
- def __delegate_method_missing_to_target(operator, expected)
69
+ def __delegate_method_missing_to_given(operator, expected)
70
70
  @operator = operator
71
71
  ::Spec::Matchers.last_matcher = self
72
- return true unless @target.__send__(operator, expected)
73
- return fail_with_message("expected not: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@target.inspect}")
72
+ return true unless @given.__send__(operator, expected)
73
+ return fail_with_message("expected not: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@given.inspect}")
74
74
  end
75
75
 
76
76
  end
@@ -1,27 +1,27 @@
1
1
  module Spec
2
2
  module Matchers
3
3
  class RaiseError #:nodoc:
4
- def initialize(error_or_message=Exception, message=nil, &block)
4
+ def initialize(expected_error_or_message=Exception, expected_message=nil, &block)
5
5
  @block = block
6
- case error_or_message
6
+ case expected_error_or_message
7
7
  when String, Regexp
8
- @expected_error, @expected_message = Exception, error_or_message
8
+ @expected_error, @expected_message = Exception, expected_error_or_message
9
9
  else
10
- @expected_error, @expected_message = error_or_message, message
10
+ @expected_error, @expected_message = expected_error_or_message, expected_message
11
11
  end
12
12
  end
13
13
 
14
- def matches?(proc)
14
+ def matches?(given_proc)
15
15
  @raised_expected_error = false
16
16
  @with_expected_message = false
17
17
  @eval_block = false
18
18
  @eval_block_passed = false
19
19
  begin
20
- proc.call
21
- rescue @expected_error => @actual_error
20
+ given_proc.call
21
+ rescue @expected_error => @given_error
22
22
  @raised_expected_error = true
23
23
  @with_expected_message = verify_message
24
- rescue Exception => @actual_error
24
+ rescue Exception => @given_error
25
25
  # This clause should be empty, but rcov will not report it as covered
26
26
  # unless something (anything) is executed within the clause
27
27
  rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0"
@@ -37,10 +37,10 @@ module Spec
37
37
  def eval_block
38
38
  @eval_block = true
39
39
  begin
40
- @block[@actual_error]
40
+ @block[@given_error]
41
41
  @eval_block_passed = true
42
42
  rescue Exception => err
43
- @actual_error = err
43
+ @given_error = err
44
44
  end
45
45
  end
46
46
 
@@ -49,22 +49,22 @@ module Spec
49
49
  when nil
50
50
  return true
51
51
  when Regexp
52
- return @expected_message =~ @actual_error.message
52
+ return @expected_message =~ @given_error.message
53
53
  else
54
- return @expected_message == @actual_error.message
54
+ return @expected_message == @given_error.message
55
55
  end
56
56
  end
57
57
 
58
58
  def failure_message
59
59
  if @eval_block
60
- return @actual_error.message
60
+ return @given_error.message
61
61
  else
62
- return "expected #{expected_error}#{actual_error}"
62
+ return "expected #{expected_error}#{given_error}"
63
63
  end
64
64
  end
65
65
 
66
66
  def negative_failure_message
67
- "expected no #{expected_error}#{actual_error}"
67
+ "expected no #{expected_error}#{given_error}"
68
68
  end
69
69
 
70
70
  def description
@@ -83,8 +83,8 @@ module Spec
83
83
  end
84
84
  end
85
85
 
86
- def actual_error
87
- @actual_error.nil? ? " but nothing was raised" : ", got #{@actual_error.inspect}"
86
+ def given_error
87
+ @given_error.nil? ? " but nothing was raised" : ", got #{@given_error.inspect}"
88
88
  end
89
89
 
90
90
  def negative_expectation?
@@ -7,9 +7,10 @@ module Spec
7
7
  @names_not_responded_to = []
8
8
  end
9
9
 
10
- def matches?(target)
10
+ def matches?(given)
11
+ @given = given
11
12
  @names.each do |name|
12
- unless target.respond_to?(name)
13
+ unless given.respond_to?(name)
13
14
  @names_not_responded_to << name
14
15
  end
15
16
  end
@@ -17,11 +18,11 @@ module Spec
17
18
  end
18
19
 
19
20
  def failure_message
20
- "expected target to respond to #{@names_not_responded_to.collect {|name| name.inspect }.join(', ')}"
21
+ "expected #{@given.inspect} to respond to #{@names_not_responded_to.collect {|name| name.inspect }.join(', ')}"
21
22
  end
22
23
 
23
24
  def negative_failure_message
24
- "expected target not to respond to #{@names.collect {|name| name.inspect }.join(', ')}"
25
+ "expected #{@given.inspect} not to respond to #{@names.collect {|name| name.inspect }.join(', ')}"
25
26
  end
26
27
 
27
28
  def description
@@ -6,18 +6,18 @@ module Spec
6
6
  @block = block
7
7
  end
8
8
 
9
- def matches?(actual, &block)
9
+ def matches?(given, &block)
10
10
  @block = block if block
11
- @actual = actual
12
- @block.call(actual)
11
+ @given = given
12
+ @block.call(given)
13
13
  end
14
14
 
15
15
  def failure_message
16
- "expected #{@actual} to satisfy block"
16
+ "expected #{@given} to satisfy block"
17
17
  end
18
18
 
19
19
  def negative_failure_message
20
- "expected #{@actual} not to satisfy block"
20
+ "expected #{@given} not to satisfy block"
21
21
  end
22
22
  end
23
23
 
@@ -8,13 +8,13 @@ module Spec
8
8
  @match_block = match_block
9
9
  end
10
10
 
11
- def matches?(actual)
12
- @actual = actual
11
+ def matches?(given)
12
+ @given = given
13
13
  case @match_block.arity
14
14
  when 2
15
- @match_block.call(@actual, self)
15
+ @match_block.call(@given, self)
16
16
  else
17
- @match_block.call(@actual)
17
+ @match_block.call(@given)
18
18
  end
19
19
  end
20
20
 
@@ -23,11 +23,11 @@ module Spec
23
23
  end
24
24
 
25
25
  def failure_message
26
- @failure_message || (@description.nil? ? explanation : %[expected #{@description.inspect} but got #{@actual.inspect}])
26
+ @failure_message || (@description.nil? ? explanation : %[expected #{@description.inspect} but got #{@given.inspect}])
27
27
  end
28
28
 
29
29
  def negative_failure_message
30
- @negative_failure_message || (@description.nil? ? explanation : %[expected not to get #{@description.inspect}, but got #{@actual.inspect}])
30
+ @negative_failure_message || (@description.nil? ? explanation : %[expected not to get #{@description.inspect}, but got #{@given.inspect}])
31
31
  end
32
32
 
33
33
  def explanation
@@ -81,7 +81,7 @@ module Spec
81
81
  # simple_matcher("rhyme with #{expected.inspect}") do |given, matcher|
82
82
  # matcher.failure_message = "expected #{given.inspect} to rhyme with #{expected.inspect}"
83
83
  # matcher.negative_failure_message = "expected #{given.inspect} not to rhyme with #{expected.inspect}"
84
- # actual.rhymes_with? expected
84
+ # given.rhymes_with? expected
85
85
  # end
86
86
  # end
87
87
  #
@@ -92,7 +92,7 @@ module Spec
92
92
  # matcher.description = "rhyme with #{expected.inspect}"
93
93
  # matcher.failure_message = "expected #{given.inspect} to rhyme with #{expected.inspect}"
94
94
  # matcher.negative_failure_message = "expected #{given.inspect} not to rhyme with #{expected.inspect}"
95
- # actual.rhymes_with? expected
95
+ # given.rhymes_with? expected
96
96
  # end
97
97
  # end
98
98
  #
@@ -7,9 +7,9 @@ module Spec
7
7
  @actual = nil
8
8
  end
9
9
 
10
- def matches?(proc)
10
+ def matches?(given_proc)
11
11
  begin
12
- proc.call
12
+ given_proc.call
13
13
  rescue NameError => e
14
14
  raise e unless e.message =~ /uncaught throw/
15
15
  @actual = e.name.to_sym
@@ -56,7 +56,7 @@ module Spec
56
56
  # should_not throw_symbol()
57
57
  # should_not throw_symbol(:sym)
58
58
  #
59
- # Given a Symbol argument, matches if a proc throws the specified Symbol.
59
+ # Given a Symbol argument, matches if the given proc throws the specified Symbol.
60
60
  #
61
61
  # Given no argument, matches if a proc throws any Symbol.
62
62
  #
data/lib/spec/mocks.rb CHANGED
@@ -1,16 +1,5 @@
1
1
  require 'spec/mocks/framework'
2
- require 'spec/mocks/methods'
3
- require 'spec/mocks/argument_constraints'
4
- require 'spec/mocks/spec_methods'
5
- require 'spec/mocks/proxy'
6
- require 'spec/mocks/mock'
7
- require 'spec/mocks/argument_expectation'
8
- require 'spec/mocks/message_expectation'
9
- require 'spec/mocks/order_group'
10
- require 'spec/mocks/errors'
11
- require 'spec/mocks/error_generator'
12
2
  require 'spec/mocks/extensions/object'
13
- require 'spec/mocks/space'
14
3
 
15
4
  module Spec
16
5
  # == Mocks and Stubs
@@ -34,7 +34,7 @@ module Spec
34
34
  end
35
35
  end
36
36
 
37
- class RegexpArgConstraint
37
+ class RegexpConstraint
38
38
  def initialize(regexp)
39
39
  @regexp = regexp
40
40
  end
@@ -45,7 +45,7 @@ module Spec
45
45
  end
46
46
  end
47
47
 
48
- class BooleanArgConstraint
48
+ class BooleanConstraint
49
49
  def initialize(ignore)
50
50
  end
51
51
 
@@ -73,7 +73,7 @@ module Spec
73
73
  end
74
74
  end
75
75
 
76
- class DuckTypeArgConstraint
76
+ class DuckTypeConstraint
77
77
  def initialize(*methods_to_respond_to)
78
78
  @methods_to_respond_to = methods_to_respond_to
79
79
  end
@@ -103,26 +103,6 @@ module Spec
103
103
  end
104
104
  end
105
105
 
106
- module Deprecated
107
- class NumericArgConstraint
108
- def initialize(ignore)
109
- end
110
-
111
- def ==(value)
112
- value.is_a?(Numeric)
113
- end
114
- end
115
-
116
- class StringArgConstraint
117
- def initialize(ignore)
118
- end
119
-
120
- def ==(value)
121
- String === value
122
- end
123
- end
124
- end
125
-
126
106
  # :call-seq:
127
107
  # object.should_receive(:message).with(any_args())
128
108
  #
@@ -161,7 +141,7 @@ module Spec
161
141
  # display.should_receive(:present_names).with(duck_type(:length, :each))
162
142
  # => passes
163
143
  def duck_type(*args)
164
- DuckTypeArgConstraint.new(*args)
144
+ DuckTypeConstraint.new(*args)
165
145
  end
166
146
 
167
147
  # :call-seq:
@@ -169,7 +149,7 @@ module Spec
169
149
  #
170
150
  # Passes if the argument is boolean.
171
151
  def boolean
172
- BooleanArgConstraint.new(nil)
152
+ BooleanConstraint.new(nil)
173
153
  end
174
154
 
175
155
  # :call-seq: