rspec 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
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
data/History.txt CHANGED
@@ -1,4 +1,15 @@
1
- === Version 1.1.5
1
+ === Version 1.1.6 / 2008-10-02
2
+
3
+ * 2 bug fixes
4
+
5
+ * fixed bug where negative message expectations following stubs resulted in false (negative) positives (Pat Maddox). Closes #548.
6
+ * fixed bug where Not Yet Implemented examples report incorrect caller (Scott Taylor). Closes #547.
7
+
8
+ * 1 minor enhancement
9
+
10
+ * removed deprecated mock argument constraint symbols
11
+
12
+ === Version 1.1.5 / 2008-09-28
2
13
 
3
14
  IMPORTANT: use the new 'autospec' command instead of 'autotest'. We changed
4
15
  the way autotest discovers rspec so the autotest executable won't
data/Manifest.txt CHANGED
@@ -204,15 +204,14 @@ rake_tasks/failing_examples_with_html.rake
204
204
  rake_tasks/verify_rcov.rake
205
205
  rspec.gemspec
206
206
  spec/README.jruby
207
+ spec/autotest/autotest_helper.rb
208
+ spec/autotest/autotest_matchers.rb
207
209
  spec/autotest/discover_spec.rb
208
210
  spec/autotest/rspec_spec.rb
209
- spec/autotest_helper.rb
210
- spec/autotest_matchers.rb
211
211
  spec/rspec_suite.rb
212
212
  spec/ruby_forker.rb
213
213
  spec/spec.opts
214
214
  spec/spec/adapters/ruby_engine_spec.rb
215
- spec/spec/example/base_formatter_spec.rb
216
215
  spec/spec/example/configuration_spec.rb
217
216
  spec/spec/example/example_group/described_module_spec.rb
218
217
  spec/spec/example/example_group/warning_messages_spec.rb
@@ -300,6 +299,7 @@ spec/spec/runner/drb_command_line_spec.rb
300
299
  spec/spec/runner/empty_file.txt
301
300
  spec/spec/runner/examples.txt
302
301
  spec/spec/runner/failed.txt
302
+ spec/spec/runner/formatter/base_formatter_spec.rb
303
303
  spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb
304
304
  spec/spec/runner/formatter/failing_examples_formatter_spec.rb
305
305
  spec/spec/runner/formatter/html_formatted-1.8.4.html
data/Rakefile CHANGED
@@ -19,7 +19,6 @@ Hoe.new('rspec', Spec::VERSION::STRING) do |p|
19
19
  p.description = "Behaviour Driven Development for Ruby."
20
20
  p.rubyforge_name = 'rspec'
21
21
  p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
22
- p.spec_extras = { :to_ruby => lambda { |str| File.open("rspec.gemspec", "w+"){ |f| f.puts str } } }
23
22
  end
24
23
 
25
24
  ['audit','test','test_deps','default','publish_docs','post_blog'].each do |task|
data/TODO.txt CHANGED
@@ -1 +1,9 @@
1
+ == 1.1.6
1
2
 
3
+ * resolve windows tty/colorization issue
4
+
5
+ == Future
6
+
7
+ * do SOMETHING with the website
8
+ * extract spec/story to rspec-stories (new gem)
9
+ * remove the ruby engine adapter unless Rubinius team plans to use it
data/bin/autospec CHANGED
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  ENV['RSPEC'] = 'true'
3
- ENV['AUTOTEST'] = 'true'
4
3
  system("autotest", *ARGV)
@@ -5,15 +5,15 @@ require File.dirname(__FILE__) + '/spec_helper'
5
5
  describe "Examples with no descriptions" do
6
6
 
7
7
  # description is auto-generated as "should equal(5)" based on the last #should
8
- it do
8
+ specify do
9
9
  3.should equal(3)
10
10
  5.should equal(5)
11
11
  end
12
12
 
13
- it { 3.should be < 5 }
13
+ specify { 3.should be < 5 }
14
14
 
15
- it { ["a"].should include("a") }
15
+ specify { ["a"].should include("a") }
16
16
 
17
- it { [1,2,3].should respond_to(:size) }
17
+ specify { [1,2,3].should respond_to(:size) }
18
18
 
19
19
  end
@@ -1,3 +1,3 @@
1
1
  Autotest.add_discovery do
2
- "rspec" if File.exist?('spec') && ENV['RSPEC']
2
+ "rspec" if File.directory?('spec') && ENV['RSPEC']
3
3
  end
@@ -1,15 +1,30 @@
1
1
  module Spec
2
2
  module Example
3
3
  class ExamplePendingError < StandardError
4
- def initialize(a_message=nil)
4
+ attr_reader :pending_caller
5
+
6
+ def initialize(message=nil)
5
7
  super
6
8
  @pending_caller = caller[2]
7
9
  end
10
+ end
11
+
12
+ class NotYetImplementedError < ExamplePendingError
13
+ MESSAGE = "Not Yet Implemented"
14
+ RSPEC_ROOT_LIB = File.expand_path(File.dirname(__FILE__) + "/../..")
8
15
 
9
- attr_reader :pending_caller
16
+ def initialize(backtrace)
17
+ super(MESSAGE)
18
+ @pending_caller = pending_caller_from(backtrace)
19
+ end
20
+
21
+ private
22
+
23
+ def pending_caller_from(backtrace)
24
+ backtrace.detect {|line| !line.include?(RSPEC_ROOT_LIB) }
25
+ end
10
26
  end
11
27
 
12
- class PendingExampleFixedError < StandardError
13
- end
28
+ class PendingExampleFixedError < StandardError; end
14
29
  end
15
30
  end
@@ -8,7 +8,14 @@ module Spec
8
8
 
9
9
  def initialize(defined_description, &implementation)
10
10
  @_defined_description = defined_description
11
- @_implementation = implementation
11
+ @_implementation = implementation || pending_implementation
12
+ end
13
+
14
+ private
15
+
16
+ def pending_implementation
17
+ error = NotYetImplementedError.new(caller)
18
+ lambda { raise(error) }
12
19
  end
13
20
  end
14
21
  end
@@ -38,24 +38,30 @@ module Spec
38
38
  def describe(*args, &example_group_block)
39
39
  args << {} unless Hash === args.last
40
40
  if example_group_block
41
- params = args.last
42
- params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path]
43
- if params[:shared]
44
- SharedExampleGroup.new(*args, &example_group_block)
41
+ options = args.last
42
+ options[:spec_path] = eval("caller(0)[1]", example_group_block) unless options[:spec_path]
43
+ if options[:shared]
44
+ create_shared_example_group(args, example_group_block)
45
45
  else
46
- self.subclass("Subclass") do
47
- describe(*args)
48
- module_eval(&example_group_block)
49
- end
46
+ create_nested_example_group(args, example_group_block)
50
47
  end
51
48
  else
52
49
  set_description(*args)
53
- before_eval
54
- self
55
50
  end
56
51
  end
57
52
  alias :context :describe
58
-
53
+
54
+ def create_shared_example_group(args, example_group_block)
55
+ SharedExampleGroup.new(*args, &example_group_block)
56
+ end
57
+
58
+ def create_nested_example_group(args, example_group_block)
59
+ self.subclass("Subclass") do
60
+ describe(*args)
61
+ module_eval(&example_group_block)
62
+ end
63
+ end
64
+
59
65
  # Use this to pull in examples from shared example groups.
60
66
  # See Spec::Runner for information about shared example groups.
61
67
  def it_should_behave_like(shared_example_group)
@@ -103,21 +109,24 @@ module Spec
103
109
  @predicate_matchers ||= {:an_instance_of => :is_a?}
104
110
  end
105
111
 
106
- # Creates an instance of Spec::Example::Example and adds
107
- # it to a collection of examples of the current example group.
108
- def it(description=nil, &implementation)
112
+ # Creates an instance of the current example group class and adds it to
113
+ # a collection of examples of the current example group.
114
+ def example(description=nil, &implementation)
109
115
  e = new(description, &implementation)
110
116
  example_objects << e
111
117
  e
112
118
  end
113
119
 
114
- alias_method :specify, :it
120
+ alias_method :it, :example
121
+ alias_method :specify, :example
115
122
 
116
123
  # Use this to temporarily disable an example.
117
- def xit(description=nil, opts={}, &block)
124
+ def xexample(description=nil, opts={}, &block)
118
125
  Kernel.warn("Example disabled: #{description}")
119
126
  end
120
- alias_method :xspecify, :xit
127
+
128
+ alias_method :xit, :xexample
129
+ alias_method :xspecify, :xexample
121
130
 
122
131
  def run
123
132
  examples = examples_to_run
@@ -410,9 +419,6 @@ module Spec
410
419
  end
411
420
  end
412
421
 
413
- def before_eval
414
- end
415
-
416
422
  def add_method_examples(examples)
417
423
  instance_methods.sort.each do |method_name|
418
424
  if example_method?(method_name)
@@ -5,11 +5,6 @@ module Spec
5
5
  extend ModuleReopeningFix
6
6
  include ModuleInclusionWarnings
7
7
 
8
-
9
- PENDING_EXAMPLE_BLOCK = lambda {
10
- raise Spec::Example::ExamplePendingError.new("Not Yet Implemented")
11
- }
12
-
13
8
  def execute(options, instance_variables)
14
9
  options.reporter.example_started(self)
15
10
  set_instance_variables_from_hash(instance_variables)
@@ -80,7 +75,7 @@ module Spec
80
75
  end
81
76
 
82
77
  def eval_block
83
- return instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK))
78
+ instance_eval(&@_implementation)
84
79
  end
85
80
 
86
81
  def implementation_backtrace
@@ -104,4 +99,4 @@ module Spec
104
99
  end
105
100
  end
106
101
  end
107
- end
102
+ end
@@ -12,11 +12,11 @@ module Spec
12
12
  @comparison = ""
13
13
  end
14
14
 
15
- def matches?(actual)
16
- @actual = actual
15
+ def matches?(given)
16
+ @given = given
17
17
  if handling_predicate?
18
18
  begin
19
- return @result = actual.__send__(predicate, *@args)
19
+ return @result = given.__send__(predicate, *@args)
20
20
  rescue => predicate_error
21
21
  # This clause should be empty, but rcov will not report it as covered
22
22
  # unless something (anything) is executed within the clause
@@ -24,7 +24,7 @@ module Spec
24
24
  end
25
25
 
26
26
  begin
27
- return @result = actual.__send__(present_tense_predicate, *@args)
27
+ return @result = given.__send__(present_tense_predicate, *@args)
28
28
  rescue
29
29
  raise predicate_error
30
30
  end
@@ -34,12 +34,12 @@ module Spec
34
34
  end
35
35
 
36
36
  def failure_message
37
- return "expected #{@comparison}#{expected}, got #{@actual.inspect}" unless handling_predicate?
37
+ return "expected #{@comparison}#{expected}, got #{@given.inspect}" unless handling_predicate?
38
38
  return "expected #{predicate}#{args_to_s} to return true, got #{@result.inspect}"
39
39
  end
40
40
 
41
41
  def negative_failure_message
42
- return "expected not #{expected}, got #{@actual.inspect}" unless handling_predicate?
42
+ return "expected not #{expected}, got #{@given.inspect}" unless handling_predicate?
43
43
  return "expected #{predicate}#{args_to_s} to return false, got #{@result.inspect}"
44
44
  end
45
45
 
@@ -52,17 +52,17 @@ module Spec
52
52
  end
53
53
 
54
54
  def match_or_compare
55
- return @actual ? true : false if @expected == :satisfy_if
56
- return @actual == true if @expected == :true
57
- return @actual == false if @expected == :false
58
- return @actual.nil? if @expected == :nil
59
- return @actual < @expected if @less_than
60
- return @actual <= @expected if @less_than_or_equal
61
- return @actual >= @expected if @greater_than_or_equal
62
- return @actual > @expected if @greater_than
63
- return @actual == @expected if @double_equal
64
- return @actual === @expected if @triple_equal
65
- return @actual.equal?(@expected)
55
+ return @given ? true : false if @expected == :satisfy_if
56
+ return @given == true if @expected == :true
57
+ return @given == false if @expected == :false
58
+ return @given.nil? if @expected == :nil
59
+ return @given < @expected if @less_than
60
+ return @given <= @expected if @less_than_or_equal
61
+ return @given >= @expected if @greater_than_or_equal
62
+ return @given > @expected if @greater_than
63
+ return @given == @expected if @double_equal
64
+ return @given === @expected if @triple_equal
65
+ return @given.equal?(@expected)
66
66
  end
67
67
 
68
68
  def ==(expected)
@@ -189,7 +189,7 @@ module Spec
189
189
  # should_not be_nil
190
190
  # should_not be_arbitrary_predicate(*args)
191
191
  #
192
- # Given true, false, or nil, will pass if actual is
192
+ # Given true, false, or nil, will pass if given value is
193
193
  # true, false or nil (respectively). Given no args means
194
194
  # the caller should satisfy an if condition (to be or not to be).
195
195
  #
@@ -7,13 +7,13 @@ module Spec
7
7
  @delta = delta
8
8
  end
9
9
 
10
- def matches?(actual)
11
- @actual = actual
12
- (@actual - @expected).abs < @delta
10
+ def matches?(given)
11
+ @given = given
12
+ (@given - @expected).abs < @delta
13
13
  end
14
14
 
15
15
  def failure_message
16
- "expected #{@expected} +/- (< #{@delta}), got #{@actual}"
16
+ "expected #{@expected} +/- (< #{@delta}), got #{@given}"
17
17
  end
18
18
 
19
19
  def description
@@ -25,7 +25,7 @@ module Spec
25
25
  # should be_close(expected, delta)
26
26
  # should_not be_close(expected, delta)
27
27
  #
28
- # Passes if actual == expected +/- delta
28
+ # Passes if given == expected +/- delta
29
29
  #
30
30
  # == Example
31
31
  #
@@ -6,17 +6,17 @@ module Spec
6
6
  @expected = expected
7
7
  end
8
8
 
9
- def matches?(actual)
10
- @actual = actual
11
- @actual.eql?(@expected)
9
+ def matches?(given)
10
+ @given = given
11
+ @given.eql?(@expected)
12
12
  end
13
13
 
14
14
  def failure_message
15
- return "expected #{@expected.inspect}, got #{@actual.inspect} (using .eql?)", @expected, @actual
15
+ return "expected #{@expected.inspect}, got #{@given.inspect} (using .eql?)", @expected, @given
16
16
  end
17
17
 
18
18
  def negative_failure_message
19
- return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .eql?)", @expected, @actual
19
+ return "expected #{@given.inspect} not to equal #{@expected.inspect} (using .eql?)", @expected, @given
20
20
  end
21
21
 
22
22
  def description
@@ -28,7 +28,7 @@ module Spec
28
28
  # should eql(expected)
29
29
  # should_not eql(expected)
30
30
  #
31
- # Passes if actual and expected are of equal value, but not necessarily the same object.
31
+ # Passes if given and expected are of equal value, but not necessarily the same object.
32
32
  #
33
33
  # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
34
34
  #
@@ -6,17 +6,17 @@ module Spec
6
6
  @expected = expected
7
7
  end
8
8
 
9
- def matches?(actual)
10
- @actual = actual
11
- @actual.equal?(@expected)
9
+ def matches?(given)
10
+ @given = given
11
+ @given.equal?(@expected)
12
12
  end
13
13
 
14
14
  def failure_message
15
- return "expected #{@expected.inspect}, got #{@actual.inspect} (using .equal?)", @expected, @actual
15
+ return "expected #{@expected.inspect}, got #{@given.inspect} (using .equal?)", @expected, @given
16
16
  end
17
17
 
18
18
  def negative_failure_message
19
- return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .equal?)", @expected, @actual
19
+ return "expected #{@given.inspect} not to equal #{@expected.inspect} (using .equal?)", @expected, @given
20
20
  end
21
21
 
22
22
  def description
@@ -28,7 +28,7 @@ module Spec
28
28
  # should equal(expected)
29
29
  # should_not equal(expected)
30
30
  #
31
- # Passes if actual and expected are the same object (object identity).
31
+ # Passes if given and expected are the same object (object identity).
32
32
  #
33
33
  # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
34
34
  #
@@ -1,17 +1,22 @@
1
1
  module Spec
2
2
  module Matchers
3
3
  class Exist
4
- def matches? actual
5
- @actual = actual
6
- @actual.exist?
4
+ def matches?(given)
5
+ @given = given
6
+ @given.exist?
7
7
  end
8
8
  def failure_message
9
- "expected #{@actual.inspect} to exist, but it doesn't."
9
+ "expected #{@given.inspect} to exist, but it doesn't."
10
10
  end
11
11
  def negative_failure_message
12
- "expected #{@actual.inspect} to not exist, but it does."
12
+ "expected #{@given.inspect} to not exist, but it does."
13
13
  end
14
14
  end
15
+ # :call-seq:
16
+ # should exist
17
+ # should_not exist
18
+ #
19
+ # Passes if given.exist?
15
20
  def exist; Exist.new; end
16
21
  end
17
22
  end