rspec 0.5.16 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/CHANGES +12 -0
  2. data/EXAMPLES.rd +2 -2
  3. data/examples/custom_method_spec.rb +2 -2
  4. data/examples/mocking_spec.rb +2 -2
  5. data/lib/spec/api/helper.rb +0 -6
  6. data/lib/spec/api/helper/diff.rb +1 -0
  7. data/lib/spec/api/helper/have_helper.rb +7 -23
  8. data/lib/spec/api/helper/should_helper.rb +23 -19
  9. data/lib/spec/api/helper/should_negator.rb +10 -18
  10. data/lib/spec/api/mocks/argument_expectation.rb +2 -2
  11. data/lib/spec/api/mocks/message_expectation.rb +28 -53
  12. data/lib/spec/api/mocks/mock.rb +4 -5
  13. data/lib/spec/api/sugar.rb +6 -23
  14. data/lib/spec/runner/instance_exec.rb +11 -5
  15. data/lib/spec/version.rb +2 -2
  16. data/test/spec/api/helper/arbitrary_predicate_test.rb +16 -16
  17. data/test/spec/api/helper/containment_test.rb +16 -16
  18. data/test/spec/api/helper/identity_test.rb +8 -8
  19. data/test/spec/api/helper/object_equality_test.rb +13 -13
  20. data/test/spec/api/helper/raising_test.rb +14 -14
  21. data/test/spec/api/helper/regex_matching_test.rb +4 -4
  22. data/test/spec/api/helper/should_have_test.rb +26 -20
  23. data/test/spec/api/helper/should_satisfy_test.rb +5 -5
  24. data/test/spec/api/helper/throwing_test.rb +7 -7
  25. data/test/spec/api/helper/true_false_special_case_test.rb +12 -12
  26. data/test/spec/api/helper/typing_test.rb +14 -14
  27. data/test/spec/api/mocks/mock_arg_constraints_test.rb +26 -20
  28. data/test/spec/api/mocks/mock_counts_test.rb +431 -0
  29. data/test/spec/api/mocks/mock_ordering_test.rb +61 -42
  30. data/test/spec/api/mocks/mock_test.rb +68 -230
  31. data/test/spec/api/sugar_test.rb +1 -1
  32. data/test/spec/runner/backtrace_tweaker_test.rb +2 -2
  33. data/test/spec/runner/context_runner_test.rb +4 -4
  34. data/test/spec/runner/context_test.rb +22 -22
  35. data/test/spec/runner/execution_context_test.rb +1 -1
  36. data/test/spec/runner/reporter_test.rb +6 -6
  37. data/test/spec/runner/specification_test.rb +30 -30
  38. data/test/test_classes.rb +13 -4
  39. metadata +6 -11
  40. data/lib/spec/api/helper/instance_helper.rb +0 -15
  41. data/lib/spec/api/helper/instance_negator.rb +0 -15
  42. data/lib/spec/api/helper/kind_helper.rb +0 -15
  43. data/lib/spec/api/helper/kind_negator.rb +0 -15
  44. data/lib/spec/api/helper/respond_helper.rb +0 -15
  45. data/lib/spec/api/helper/respond_negator.rb +0 -15
  46. data/test/spec/api/duck_type_test.rb +0 -19
@@ -40,7 +40,7 @@ module Spec
40
40
 
41
41
  def test_should_allow_underscored_anys_on_mocks
42
42
  sweetener = Mock.new "sweetener"
43
- sweetener.should_receive(:natural?).once_and_return(false)
43
+ sweetener.should_receive(:natural?).once.and_return(false)
44
44
  natural = sweetener.natural?
45
45
  natural.should_be false
46
46
  sweetener.__verify
@@ -8,7 +8,7 @@ module Spec
8
8
  end
9
9
 
10
10
  def test_should_not_barf_on_nil_backtrace
11
- proc { @tweaker.tweak_backtrace @error, 'spec name' }.should.not.raise
11
+ proc { @tweaker.tweak_backtrace @error, 'spec name' }.should_not_raise
12
12
  end
13
13
 
14
14
  def test_should_replace___instance_exec_with_spec_name
@@ -44,7 +44,7 @@ module Spec
44
44
  end
45
45
 
46
46
  def test_should_not_barf_on_nil_backtrace
47
- proc { @tweaker.tweak_backtrace @error, 'spec name' }.should.not.raise
47
+ proc { @tweaker.tweak_backtrace @error, 'spec name' }.should_not_raise
48
48
  end
49
49
 
50
50
  def test_should_replace___instance_exec_with_spec_name
@@ -7,10 +7,10 @@ module Spec
7
7
  def test_should_call_run_on_context
8
8
  context1 = Api::Mock.new "context1", :null_object=>true
9
9
  context2 = Api::Mock.new "context2", :null_object=>true
10
- context1.should.receive(:run)
11
- context1.should.receive(:number_of_specs).and.return(0)
12
- context2.should.receive(:run)
13
- context2.should.receive(:number_of_specs).and.return(0)
10
+ context1.should_receive(:run)
11
+ context1.should_receive(:number_of_specs).and_return(0)
12
+ context2.should_receive(:run)
13
+ context2.should_receive(:number_of_specs).and_return(0)
14
14
 
15
15
  reporter = Api::Mock.new 'reporter'
16
16
  reporter.should_receive(:start).with(0)
@@ -14,14 +14,14 @@ module Spec
14
14
  end
15
15
 
16
16
  def test_should_add_itself_to_formatter_on_run
17
- @formatter.should.receive(:add_context).with "context"
17
+ @formatter.should_receive(:add_context).with "context"
18
18
  @context.run(@formatter)
19
19
  end
20
20
 
21
21
  def test_should_run_spec
22
- @formatter.should.receive(:add_context).with :any_args
23
- @formatter.should.receive(:spec_started).with "test"
24
- @formatter.should.receive(:spec_finished).with "test", :anything, :anything
22
+ @formatter.should_receive(:add_context).with :any_args
23
+ @formatter.should_receive(:spec_started).with "test"
24
+ @formatter.should_receive(:spec_finished).with "test", :anything, :anything
25
25
  $spec_ran = false
26
26
  @context.specify("test") {$spec_ran = true}
27
27
  @context.run(@formatter)
@@ -29,9 +29,9 @@ module Spec
29
29
  end
30
30
 
31
31
  def test_should_run_spec_dry
32
- @formatter.should.receive(:add_context).with :any_args
33
- @formatter.should.receive(:spec_started).with "test"
34
- @formatter.should.receive(:spec_finished).with "test"
32
+ @formatter.should_receive(:add_context).with :any_args
33
+ @formatter.should_receive(:spec_started).with "test"
34
+ @formatter.should_receive(:spec_finished).with "test"
35
35
  $spec_ran = false
36
36
  @context.specify("test") {$spec_ran = true}
37
37
  @context.run(@formatter, true)
@@ -39,9 +39,9 @@ module Spec
39
39
  end
40
40
 
41
41
  def test_setup
42
- @formatter.should.receive(:add_context).with :any_args
43
- @formatter.should.receive(:spec_started).with "test"
44
- @formatter.should.receive(:spec_finished).with :any_args
42
+ @formatter.should_receive(:add_context).with :any_args
43
+ @formatter.should_receive(:spec_started).with "test"
44
+ @formatter.should_receive(:spec_finished).with :any_args
45
45
 
46
46
  super_class_setup_ran = false
47
47
  super_class = Class.new do
@@ -60,9 +60,9 @@ module Spec
60
60
  end
61
61
 
62
62
  def test_setup__should_allow_method_definitions
63
- @formatter.should.receive(:add_context).with :any_args
64
- @formatter.should.receive(:spec_started).with "test"
65
- @formatter.should.receive(:spec_finished).with :any_args
63
+ @formatter.should_receive(:add_context).with :any_args
64
+ @formatter.should_receive(:spec_started).with "test"
65
+ @formatter.should_receive(:spec_finished).with :any_args
66
66
 
67
67
  $method_in_setup_called = false
68
68
  @context.setup do
@@ -78,9 +78,9 @@ module Spec
78
78
  end
79
79
 
80
80
  def test_teardown
81
- @formatter.should.receive(:add_context).with :any_args
82
- @formatter.should.receive(:spec_started).with "test"
83
- @formatter.should.receive(:spec_finished).with :any_args
81
+ @formatter.should_receive(:add_context).with :any_args
82
+ @formatter.should_receive(:spec_started).with "test"
83
+ @formatter.should_receive(:spec_finished).with :any_args
84
84
 
85
85
  super_class_teardown_ran = false
86
86
  super_class = Class.new do
@@ -100,9 +100,9 @@ module Spec
100
100
  end
101
101
 
102
102
  def test_inherit__superclass_methods_should_be_accessible
103
- @formatter.should.receive(:add_context).with :any_args
104
- @formatter.should.receive(:spec_started).with "test"
105
- @formatter.should.receive(:spec_finished).with :any_args
103
+ @formatter.should_receive(:add_context).with :any_args
104
+ @formatter.should_receive(:spec_started).with "test"
105
+ @formatter.should_receive(:spec_finished).with :any_args
106
106
 
107
107
  helper_method_ran = false
108
108
  super_class = Class.new do
@@ -144,9 +144,9 @@ module Spec
144
144
  end
145
145
 
146
146
  def test_include
147
- @formatter.should.receive(:add_context).with :any_args
148
- @formatter.should.receive(:spec_started).with "test"
149
- @formatter.should.receive(:spec_finished).with :any_args
147
+ @formatter.should_receive(:add_context).with :any_args
148
+ @formatter.should_receive(:spec_started).with "test"
149
+ @formatter.should_receive(:spec_finished).with :any_args
150
150
 
151
151
  mod1_method_called = false
152
152
  mod1 = Module.new do
@@ -6,7 +6,7 @@ module Spec
6
6
 
7
7
  def test_should_add_new_mock_to_spec_when_mock_message_received
8
8
  spec = Api::Mock.new "spec"
9
- spec.should.receive(:add_mock) {|mock| mock.instance_of? Api::Mock}
9
+ spec.should_receive(:add_mock) {|mock| mock.instance_of? Api::Mock}
10
10
  ec = ExecutionContext.new spec
11
11
  mock = ec.mock("a mock", :null_object=>true)
12
12
  end
@@ -55,7 +55,7 @@ module Spec
55
55
  @formatter.should_receive(:start_dump)
56
56
  @formatter.should_receive(:dump_failure).with(1, :anything)
57
57
  @formatter.should_receive(:dump_summary).with(:anything, 1, 1)
58
- @backtrace_tweaker.should.receive(:tweak_backtrace)
58
+ @backtrace_tweaker.should_receive(:tweak_backtrace)
59
59
  @reporter.add_context "context"
60
60
  @reporter.spec_started "spec"
61
61
  @reporter.spec_finished "spec", RuntimeError.new
@@ -64,8 +64,8 @@ module Spec
64
64
 
65
65
  def test_should_handle_multiple_contexts_with_same_name
66
66
  @formatter.should_receive(:add_context).exactly(3).times
67
- @formatter.should.receive(:spec_started).exactly(3).times
68
- @formatter.should.receive(:spec_passed).exactly(3).times
67
+ @formatter.should_receive(:spec_started).exactly(3).times
68
+ @formatter.should_receive(:spec_passed).exactly(3).times
69
69
  @formatter.should_receive(:start_dump)
70
70
  @formatter.should_receive(:dump_summary).with(:anything, 3, 0)
71
71
  @reporter.add_context "context"
@@ -83,14 +83,14 @@ module Spec
83
83
  def test_should_handle_multiple_specs_same_name
84
84
  error = RuntimeError.new
85
85
  @formatter.should_receive(:add_context).exactly(2).times
86
- @formatter.should.receive(:spec_started).with("spec").exactly(4).times
86
+ @formatter.should_receive(:spec_started).with("spec").exactly(4).times
87
87
  @formatter.should_receive(:spec_passed).with("spec").exactly(2).times
88
88
  @formatter.should_receive(:spec_failed).with("spec", 1, failure)
89
89
  @formatter.should_receive(:spec_failed).with("spec", 2, failure)
90
90
  @formatter.should_receive(:dump_failure).exactly(2).times
91
91
  @formatter.should_receive(:start_dump)
92
92
  @formatter.should_receive(:dump_summary).with(:anything, 4, 2)
93
- @backtrace_tweaker.should.receive(:tweak_backtrace)
93
+ @backtrace_tweaker.should_receive(:tweak_backtrace)
94
94
  @reporter.add_context "context"
95
95
 
96
96
  @reporter.spec_started "spec"
@@ -113,7 +113,7 @@ module Spec
113
113
  def test_should_delegate_to_backtrace_tweaker
114
114
  @formatter.should_receive(:add_context)
115
115
  @formatter.should_receive(:spec_failed)
116
- @backtrace_tweaker.should.receive(:tweak_backtrace)
116
+ @backtrace_tweaker.should_receive(:tweak_backtrace)
117
117
  @reporter.add_context "context"
118
118
  @reporter.spec_finished "spec", RuntimeError.new
119
119
  @backtrace_tweaker.__verify
@@ -9,45 +9,45 @@ module Spec
9
9
 
10
10
  def test_should_run_spec_in_scope_of_execution_context
11
11
  spec = Specification.new("should pass") do
12
- self.should.not.be.instance_of Specification
13
- self.should.be.instance_of ExecutionContext
12
+ self.should_not_be_an_instance_of Specification
13
+ self.should_be_an_instance_of ExecutionContext
14
14
  end
15
- @reporter.should.receive(:spec_started).with "should pass"
16
- @reporter.should.receive(:spec_finished).with "should pass", nil, nil
15
+ @reporter.should_receive(:spec_started).with "should pass"
16
+ @reporter.should_receive(:spec_finished).with "should pass", nil, nil
17
17
  spec.run @reporter
18
18
  end
19
19
 
20
20
  def test_should_add_itself_to_reporter_when_passes
21
21
  spec = Specification.new("spec") {}
22
- @reporter.should.receive(:spec_started).with "spec"
23
- @reporter.should.receive(:spec_finished).with "spec", nil, nil
22
+ @reporter.should_receive(:spec_started).with "spec"
23
+ @reporter.should_receive(:spec_finished).with "spec", nil, nil
24
24
  spec.run(@reporter)
25
25
  end
26
26
 
27
27
  def test_should_add_itself_to_reporter_when_fails
28
28
  error = RuntimeError.new
29
29
  spec = Specification.new("spec") { raise error }
30
- @reporter.should.receive(:spec_started).with "spec"
31
- @reporter.should.receive(:spec_finished).with "spec", error, "spec"
30
+ @reporter.should_receive(:spec_started).with "spec"
31
+ @reporter.should_receive(:spec_finished).with "spec", error, "spec"
32
32
  spec.run(@reporter)
33
33
  end
34
34
 
35
35
  def test_should_add_itself_to_reporter_when_calling_run_dry
36
36
  spec = Specification.new("spec") {}
37
- @reporter.should.receive(:spec_started).with "spec"
38
- @reporter.should.receive(:spec_finished).with "spec"
37
+ @reporter.should_receive(:spec_started).with "spec"
38
+ @reporter.should_receive(:spec_finished).with "spec"
39
39
  spec.run(@reporter, nil, nil, true)
40
40
  end
41
41
 
42
42
  def test_should_verify_mocks_after_teardown
43
43
  spec = Specification.new("spec") do
44
44
  mock = mock("a mock")
45
- mock.should.receive(:poke)
45
+ mock.should_receive(:poke)
46
46
  end
47
- @reporter.should.receive(:spec_started).with "spec"
48
- @reporter.should.receive(:spec_finished) do |spec_name, error|
49
- spec_name.should.equal "spec"
50
- error.message.should.match /expected 'poke' once, but received it 0 times/
47
+ @reporter.should_receive(:spec_started).with "spec"
48
+ @reporter.should_receive(:spec_finished) do |spec_name, error|
49
+ spec_name.should_equal "spec"
50
+ error.message.should_match /expected 'poke' once, but received it 0 times/
51
51
  end
52
52
  spec.run @reporter
53
53
  end
@@ -59,11 +59,11 @@ module Spec
59
59
  teardown = lambda do
60
60
  raise "in teardown"
61
61
  end
62
- @reporter.should.receive(:spec_started).with "spec"
63
- @reporter.should.receive(:spec_finished) do |spec, error, location|
64
- spec.should.equal "spec"
65
- location.should.equal "spec"
66
- error.message.should.equal "in body"
62
+ @reporter.should_receive(:spec_started).with "spec"
63
+ @reporter.should_receive(:spec_finished) do |spec, error, location|
64
+ spec.should_equal "spec"
65
+ location.should_equal "spec"
66
+ error.message.should_equal "in body"
67
67
  end
68
68
  spec.run @reporter, nil, teardown
69
69
  end
@@ -74,11 +74,11 @@ module Spec
74
74
  setup = lambda do
75
75
  raise "in setup"
76
76
  end
77
- @reporter.should.receive(:spec_started).with "spec"
78
- @reporter.should.receive(:spec_finished) do |name, error, location|
79
- name.should.equal "spec"
80
- error.message.should.equal "in setup"
81
- location.should.equal "setup"
77
+ @reporter.should_receive(:spec_started).with "spec"
78
+ @reporter.should_receive(:spec_finished) do |name, error, location|
79
+ name.should_equal "spec"
80
+ error.message.should_equal "in setup"
81
+ location.should_equal "setup"
82
82
  end
83
83
  spec.run @reporter, setup
84
84
  end
@@ -89,11 +89,11 @@ module Spec
89
89
  teardown = lambda do
90
90
  raise "in teardown"
91
91
  end
92
- @reporter.should.receive(:spec_started).with "spec"
93
- @reporter.should.receive(:spec_finished) do |name, error, location|
94
- name.should.equal "spec"
95
- error.message.should.equal "in teardown"
96
- location.should.equal "teardown"
92
+ @reporter.should_receive(:spec_started).with "spec"
93
+ @reporter.should_receive(:spec_finished) do |name, error, location|
94
+ name.should_equal "spec"
95
+ error.message.should_equal "in teardown"
96
+ location.should_equal "teardown"
97
97
  end
98
98
  spec.run @reporter, nil, teardown
99
99
  end
@@ -3,6 +3,15 @@
3
3
  # be accessed by the test2spec-translated specs
4
4
  module Spec
5
5
  module Api
6
+ class Person
7
+ attr_reader :name
8
+ def initialize name
9
+ @name = name
10
+ end
11
+ def == other
12
+ return @name == other.name
13
+ end
14
+ end
6
15
  class ClassWithMultiWordPredicate
7
16
  def multi_word_predicate?
8
17
  true
@@ -51,15 +60,15 @@ module Spec
51
60
  end
52
61
 
53
62
  def hungry?(a, b, c)
54
- a.should.be 1
55
- b.should.be 2
56
- c.should.be 3
63
+ a.should_be 1
64
+ b.should_be 2
65
+ c.should_be 3
57
66
  @funny_called = true
58
67
  @return_val
59
68
  end
60
69
 
61
70
  def __verify
62
- @funny_called.should.be true
71
+ @funny_called.should_be true
63
72
  end
64
73
  end
65
74
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rspec
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.16
7
- date: 2006-07-31 00:00:00 -05:00
8
- summary: RSpec-0.5.16 - BDD for Ruby http://rspec.rubyforge.org/
6
+ version: 0.6.0
7
+ date: 2006-08-09 00:00:00 -05:00
8
+ summary: RSpec-0.6.0 - BDD for Ruby http://rspec.rubyforge.org/
9
9
  require_paths:
10
10
  - lib
11
11
  email: rspec-devel@rubyforge.org
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Steven Baker, Aslak Hellesoy, Dave Astels, David Chelimsky
30
31
  files:
@@ -42,12 +43,6 @@ files:
42
43
  - lib/spec/api/sugar.rb
43
44
  - lib/spec/api/helper/diff.rb
44
45
  - lib/spec/api/helper/have_helper.rb
45
- - lib/spec/api/helper/instance_helper.rb
46
- - lib/spec/api/helper/instance_negator.rb
47
- - lib/spec/api/helper/kind_helper.rb
48
- - lib/spec/api/helper/kind_negator.rb
49
- - lib/spec/api/helper/respond_helper.rb
50
- - lib/spec/api/helper/respond_negator.rb
51
46
  - lib/spec/api/helper/should_base.rb
52
47
  - lib/spec/api/helper/should_helper.rb
53
48
  - lib/spec/api/helper/should_negator.rb
@@ -80,7 +75,6 @@ files:
80
75
  - lib/spec/test_to_spec/translation_test_runner.rb
81
76
  - test/test_classes.rb
82
77
  - test/test_helper.rb
83
- - test/spec/api/duck_type_test.rb
84
78
  - test/spec/api/sugar_test.rb
85
79
  - test/spec/api/helper/arbitrary_predicate_test.rb
86
80
  - test/spec/api/helper/containment_test.rb
@@ -95,6 +89,7 @@ files:
95
89
  - test/spec/api/helper/true_false_special_case_test.rb
96
90
  - test/spec/api/helper/typing_test.rb
97
91
  - test/spec/api/mocks/mock_arg_constraints_test.rb
92
+ - test/spec/api/mocks/mock_counts_test.rb
98
93
  - test/spec/api/mocks/mock_ordering_test.rb
99
94
  - test/spec/api/mocks/mock_test.rb
100
95
  - test/spec/api/mocks/null_object_test.rb
@@ -1,15 +0,0 @@
1
- module Spec
2
-
3
- class InstanceHelper < ShouldBase
4
-
5
- def initialize(target)
6
- @target = target
7
- end
8
-
9
- def of(expected_class)
10
- fail_with_message(default_message("should be an instance of", expected_class)) unless @target.instance_of? expected_class
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module Spec
2
-
3
- class InstanceNegator < ShouldBase
4
-
5
- def initialize(target)
6
- @target = target
7
- end
8
-
9
- def of(expected_class)
10
- fail_with_message(default_message("should not be an instance of", expected_class)) if @target.instance_of? expected_class
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module Spec
2
-
3
- class KindHelper < ShouldBase
4
-
5
- def initialize(target)
6
- @target = target
7
- end
8
-
9
- def of(expected_class)
10
- fail_with_message(default_message("should be a kind of", expected_class)) unless @target.kind_of? expected_class
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module Spec
2
-
3
- class KindNegator < ShouldBase
4
-
5
- def initialize(target)
6
- @target = target
7
- end
8
-
9
- def of(expected_class)
10
- fail_with_message(default_message("should not be a kind of", expected_class)) if @target.kind_of? expected_class
11
- end
12
-
13
- end
14
-
15
- end