rspec 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANGES +90 -1
  2. data/EXAMPLES.rd +28 -6
  3. data/MIT-LICENSE +20 -0
  4. data/README +18 -12
  5. data/Rakefile +60 -54
  6. data/examples/custom_formatter.rb +4 -4
  7. data/examples/helper_method_example.rb +11 -0
  8. data/examples/mocking_example.rb +19 -2
  9. data/examples/partial_mock_example.rb +28 -0
  10. data/examples/stack_spec.rb +8 -8
  11. data/examples/stubbing_example.rb +50 -9
  12. data/examples/test_case_spec.rb +6 -6
  13. data/lib/spec.rb +1 -2
  14. data/lib/spec/callback.rb +0 -0
  15. data/lib/spec/expectations.rb +3 -6
  16. data/lib/spec/expectations/diff.rb +23 -47
  17. data/lib/spec/expectations/differs/default.rb +62 -0
  18. data/lib/spec/expectations/{exceptions.rb → errors.rb} +0 -0
  19. data/lib/spec/expectations/extensions.rb +4 -0
  20. data/lib/spec/expectations/extensions/inspect_for_expectation_not_met_error.rb +14 -0
  21. data/lib/spec/expectations/extensions/numeric.rb +5 -0
  22. data/lib/spec/expectations/{expectations.rb → extensions/object.rb} +3 -6
  23. data/lib/spec/expectations/extensions/symbol.rb +5 -0
  24. data/lib/spec/expectations/should.rb +4 -0
  25. data/lib/spec/expectations/should/base.rb +42 -0
  26. data/lib/spec/expectations/should/have.rb +79 -0
  27. data/lib/spec/expectations/should/not.rb +72 -0
  28. data/lib/spec/expectations/should/should.rb +83 -0
  29. data/lib/spec/expectations/sugar.rb +6 -25
  30. data/lib/spec/mocks.rb +5 -1
  31. data/lib/spec/mocks/argument_expectation.rb +15 -1
  32. data/lib/spec/mocks/error_generator.rb +72 -0
  33. data/lib/spec/mocks/{exceptions.rb → errors.rb} +0 -0
  34. data/lib/spec/mocks/extensions/object.rb +3 -0
  35. data/lib/spec/mocks/message_expectation.rb +80 -73
  36. data/lib/spec/mocks/mock.rb +4 -69
  37. data/lib/spec/mocks/mock_handler.rb +158 -0
  38. data/lib/spec/mocks/mock_methods.rb +44 -0
  39. data/lib/spec/mocks/order_group.rb +10 -2
  40. data/lib/spec/rake/spectask.rb +20 -18
  41. data/lib/spec/rake/{rcov_verify.rb → verify_rcov.rb} +2 -2
  42. data/lib/spec/runner.rb +3 -1
  43. data/lib/spec/runner/backtrace_tweaker.rb +2 -1
  44. data/lib/spec/runner/context.rb +10 -16
  45. data/lib/spec/runner/context_eval.rb +40 -40
  46. data/lib/spec/runner/execution_context.rb +1 -12
  47. data/lib/spec/runner/{kernel_ext.rb → extensions/kernel.rb} +2 -2
  48. data/lib/spec/runner/{instance_exec.rb → extensions/object.rb} +0 -0
  49. data/lib/spec/runner/formatter/base_text_formatter.rb +25 -18
  50. data/lib/spec/runner/formatter/html_formatter.rb +81 -101
  51. data/lib/spec/runner/formatter/progress_bar_formatter.rb +9 -9
  52. data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
  53. data/lib/spec/runner/formatter/specdoc_formatter.rb +7 -6
  54. data/lib/spec/runner/option_parser.rb +41 -5
  55. data/lib/spec/runner/reporter.rb +3 -15
  56. data/lib/spec/runner/spec_should_raise_handler.rb +74 -0
  57. data/lib/spec/runner/specification.rb +33 -14
  58. data/lib/spec/version.rb +6 -3
  59. data/vendor/watir/README.txt +1 -1
  60. metadata +34 -68
  61. data/bin/test2spec +0 -112
  62. data/examples/helper_method_spec.rb +0 -12
  63. data/lib/spec/expectations/have_helper.rb +0 -41
  64. data/lib/spec/expectations/helper.rb +0 -4
  65. data/lib/spec/expectations/should_base.rb +0 -52
  66. data/lib/spec/expectations/should_helper.rb +0 -93
  67. data/lib/spec/expectations/should_negator.rb +0 -71
  68. data/lib/spec/test_to_spec/ruby2ruby.rb +0 -492
  69. data/lib/spec/test_to_spec/sexp_transformer.rb +0 -196
  70. data/lib/spec/test_to_spec/test_case_ext.rb +0 -22
  71. data/lib/spec/test_to_spec/translation_test_runner.rb +0 -147
  72. data/test/spec/expectations/arbitrary_operator_test.rb +0 -55
  73. data/test/spec/expectations/arbitrary_predicate_test.rb +0 -163
  74. data/test/spec/expectations/containment_test.rb +0 -129
  75. data/test/spec/expectations/diff_test.rb +0 -62
  76. data/test/spec/expectations/identity_test.rb +0 -75
  77. data/test/spec/expectations/object_equality_test.rb +0 -65
  78. data/test/spec/expectations/raising_test.rb +0 -106
  79. data/test/spec/expectations/regex_matching_test.rb +0 -36
  80. data/test/spec/expectations/should_have_test.rb +0 -169
  81. data/test/spec/expectations/should_satisfy_test.rb +0 -37
  82. data/test/spec/expectations/sugar_test.rb +0 -93
  83. data/test/spec/expectations/supported_symbols_test.rb +0 -33
  84. data/test/spec/expectations/throwing_test.rb +0 -55
  85. data/test/spec/expectations/true_false_special_case_test.rb +0 -85
  86. data/test/spec/expectations/typing_test.rb +0 -108
  87. data/test/spec/mocks/mock_arg_constraints_test.rb +0 -113
  88. data/test/spec/mocks/mock_counts_test.rb +0 -431
  89. data/test/spec/mocks/mock_ordering_test.rb +0 -109
  90. data/test/spec/mocks/mock_test.rb +0 -220
  91. data/test/spec/mocks/null_object_test.rb +0 -37
  92. data/test/spec/runner/backtrace_tweaker_test.rb +0 -90
  93. data/test/spec/runner/context_matching_test.rb +0 -35
  94. data/test/spec/runner/context_runner_test.rb +0 -62
  95. data/test/spec/runner/context_test.rb +0 -191
  96. data/test/spec/runner/execution_context_test.rb +0 -45
  97. data/test/spec/runner/formatter/failure_dump_test.rb +0 -94
  98. data/test/spec/runner/formatter/html_formatter_test.rb +0 -48
  99. data/test/spec/runner/formatter/progress_bar_formatter_test.rb +0 -56
  100. data/test/spec/runner/formatter/rdoc_formatter_test.rb +0 -51
  101. data/test/spec/runner/formatter/specdoc_formatter_test.rb +0 -57
  102. data/test/spec/runner/kernel_ext_test.rb +0 -13
  103. data/test/spec/runner/option_parser_test.rb +0 -141
  104. data/test/spec/runner/reporter_test.rb +0 -128
  105. data/test/spec/runner/spec_matcher_test.rb +0 -47
  106. data/test/spec/runner/specification_test.rb +0 -121
  107. data/test/spec/test_to_spec/ruby_to_ruby_test.rb +0 -79
  108. data/test/spec/test_to_spec/sexp_transformer_assertion_test.rb +0 -207
  109. data/test/spec/test_to_spec/sexp_transformer_test.rb +0 -303
  110. data/test/spec/test_to_spec/test_case_ext_test.rb +0 -25
  111. data/test/spec/test_to_spec/testfiles/test_unit_api_spec.rb +0 -75
  112. data/test/spec/test_to_spec/testfiles/test_unit_api_test.rb +0 -70
  113. data/test/test_classes.rb +0 -102
  114. data/test/test_helper.rb +0 -32
@@ -1,102 +0,0 @@
1
- # This file contains various classes used by the tests.
2
- # They are kept in a separate file so that they can also
3
- # be accessed by the test2spec-translated specs
4
- module Spec
5
- module Expectations
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
15
- class ClassWithMultiWordPredicate
16
- def multi_word_predicate?
17
- true
18
- end
19
- end
20
-
21
- module Helper
22
- class CollectionWithSizeMethod
23
- def initialize; @list = []; end
24
- def size; @list.size; end
25
- def push(item); @list.push(item); end
26
- end
27
-
28
- class CollectionWithLengthMethod
29
- def initialize; @list = []; end
30
- def length; @list.size; end
31
- def push(item); @list.push(item); end
32
- end
33
-
34
- class CollectionOwner
35
- attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method
36
-
37
- def initialize
38
- @items_in_collection_with_size_method = CollectionWithSizeMethod.new
39
- @items_in_collection_with_length_method = CollectionWithLengthMethod.new
40
- end
41
-
42
- def add_to_collection_with_size_method(item)
43
- @items_in_collection_with_size_method.push(item)
44
- end
45
-
46
- def add_to_collection_with_length_method(item)
47
- @items_in_collection_with_length_method.push(item)
48
- end
49
-
50
- def items_for(arg)
51
- return [1, 2, 3] if arg == 'a'
52
- [1]
53
- end
54
-
55
- end
56
-
57
- class HandCodedMock
58
- def initialize(return_val)
59
- @return_val = return_val
60
- @funny_called = false
61
- end
62
-
63
- def funny?
64
- @funny_called = true
65
- @return_val
66
- end
67
-
68
- def hungry?(a, b, c)
69
- a.should_be 1
70
- b.should_be 2
71
- c.should_be 3
72
- @funny_called = true
73
- @return_val
74
- end
75
-
76
- def exists?
77
- @return_val
78
- end
79
-
80
- def multi_word_predicate?
81
- @return_val
82
- end
83
-
84
- def __verify
85
- @funny_called.should_be true
86
- end
87
- end
88
- class ClassWithUnqueriedPredicate
89
- attr_accessor :foo
90
- def initialize(foo)
91
- @foo = foo
92
- end
93
- end
94
- end
95
- end
96
- end
97
-
98
- module Custom
99
- class Formatter
100
- end
101
- end
102
-
@@ -1,32 +0,0 @@
1
- require 'test/unit'
2
- require 'stringio'
3
- $LOAD_PATH.push File.dirname(__FILE__) + '/../lib'
4
- $LOAD_PATH.push File.dirname(__FILE__) + '/../test'
5
- require 'spec'
6
- require 'test_classes'
7
- RSPEC_TESTING = true unless defined? RSPEC_TESTING # This causes the diff extension to not be loaded
8
- require 'spec/expectations/diff'
9
- $context_runner = ::Spec::Runner::OptionParser.create_context_runner(['test'], false, STDERR, STDOUT)
10
-
11
- # helpers for test_to_spec tests
12
-
13
- require 'pp'
14
- require 'stringio'
15
-
16
- def verify_sexp_equal(expected, actual)
17
- unless expected == actual
18
- raise "expected translation:\n" << my_pp(expected) << "actual translation:\n" << my_pp(actual)
19
- end
20
- end
21
-
22
- def my_pp(*args)
23
- old_out = $stdout
24
- begin
25
- s=StringIO.new
26
- $stdout=s
27
- pp(*args)
28
- ensure
29
- $stdout=old_out
30
- end
31
- s.string
32
- end