rspec 0.5.0 → 0.5.1

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 (57) hide show
  1. data/CHANGES +9 -5
  2. data/Rakefile +35 -29
  3. data/bin/spec +0 -5
  4. data/doc/README +5 -0
  5. data/doc/config.yaml +2 -0
  6. data/doc/plugin/syntax.rb +38 -0
  7. data/doc/reference/rspec reference.page +0 -0
  8. data/doc/src/community.page +8 -0
  9. data/doc/src/default.css +198 -0
  10. data/doc/src/default.template +34 -0
  11. data/doc/src/documentation/api.page +251 -0
  12. data/doc/src/documentation/index.page +8 -0
  13. data/doc/src/documentation/mocks.page +207 -0
  14. data/doc/src/documentation/specs.page +20 -0
  15. data/doc/src/download.page +8 -0
  16. data/doc/src/examples.page +9 -0
  17. data/doc/src/images/ul.gif +0 -0
  18. data/doc/src/index.page +8 -0
  19. data/doc/src/tools/index.page +8 -0
  20. data/doc/src/tools/rails.page +8 -0
  21. data/doc/src/tools/rake.page +8 -0
  22. data/doc/src/tools/rcov.page +8 -0
  23. data/doc/src/tools/spec_runner.page +8 -0
  24. data/doc/src/tools/specdoc.page +8 -0
  25. data/doc/src/tools/test2rspec.page +8 -0
  26. data/doc/src/ul.gif +0 -0
  27. data/doc/src/why_rspec.page +8 -0
  28. data/examples/mocking_spec.rb +2 -2
  29. data/examples/spec_framework_spec.rb +4 -4
  30. data/lib/spec/api/helper/have_helper.rb +55 -55
  31. data/lib/spec/api/mock.rb +111 -38
  32. data/lib/spec/runner/backtrace_tweaker.rb +4 -4
  33. data/lib/spec/runner/context.rb +2 -1
  34. data/lib/spec/runner/context_runner.rb +3 -3
  35. data/lib/spec/runner/option_parser.rb +8 -4
  36. data/lib/spec/runner/simple_text_reporter.rb +29 -19
  37. data/lib/spec/runner/specification.rb +2 -1
  38. data/lib/spec/version.rb +1 -1
  39. data/test/rake/rcov_testtask.rb +45 -0
  40. data/test/spec/api/helper/arbitrary_predicate_test.rb +39 -24
  41. data/test/spec/api/helper/equality_test.rb +19 -0
  42. data/test/spec/api/helper/should_have_test.rb +183 -0
  43. data/test/spec/api/mock_arg_constraints_test.rb +90 -0
  44. data/test/spec/api/mock_test.rb +101 -21
  45. data/test/spec/runner/context_runner_test.rb +3 -3
  46. data/test/spec/runner/context_test.rb +2 -5
  47. data/test/spec/runner/execution_context_test.rb +1 -1
  48. data/test/spec/runner/option_parser_test.rb +16 -8
  49. data/test/spec/runner/simple_text_reporter_test.rb +57 -33
  50. data/test/spec/runner/specification_test.rb +7 -7
  51. data/test/spec/tool/command_line_test.rb +4 -4
  52. data/test/test_helper.rb +2 -2
  53. metadata +37 -8
  54. data/README +0 -38
  55. data/TODO +0 -9
  56. data/TUTORIAL +0 -259
  57. data/WHY_RSPEC +0 -115
data/WHY_RSPEC DELETED
@@ -1,115 +0,0 @@
1
- == Why RSpec
2
-
3
- === Readability
4
- RSpec specifications read better than Test::Unit tests. Compare this:
5
-
6
- class TemperatureCoverterTest < Test::Unit::TestCase
7
- def test_converts_0C_to_32F
8
- c = TemperatureCoverter.new
9
- assert_equal(32.0, c.convert_from_c_to_f(0.0)
10
- end
11
-
12
- def test_converts_100C_to_100F
13
- c = TemperatureCoverter.new
14
- assert_equal(212.0, c.convert_from_c_to_f(100.0)
15
- end
16
- end
17
-
18
- to this:
19
-
20
- context "TemperatureCoverter"
21
- specify "Converts 0C to 32F"
22
- c = TemperatureCoverter.new
23
- c.convert_from_c_to_f(0.0).should.equal 32.0
24
- end
25
-
26
- specify "Converts 100C to 212F"
27
- c = TemperatureCoverter.new
28
- c.convert_from_c_to_f(100.0).should.equal 212.0
29
- end
30
- end
31
-
32
- === Built-in mocks
33
- ....
34
-
35
- === Self-documenting
36
- RSpec specifications are self documenting. If run with the --rspec-report option,
37
- it will produce the following report:
38
-
39
- == TemperatureCoverter
40
- * Converts 0C to 32F
41
- * Converts 100C to 212F
42
-
43
- RSpec reports gives a high-level overview of how the classes
44
- in the system should behave. Of course, the developers have to
45
- name their specifications appropriately.
46
-
47
- By making RSpec reports visible as part of the API documentation,
48
- developers are likely to put a little effort into making the RSpec
49
- report make sense. Consider this example (translated from an
50
- imaginary Test::Unit test):
51
-
52
- context "TemperatureCoverter"
53
- specify "Convert"
54
- c = TemperatureCoverter.new
55
- c.convert_from_c_to_f(0.0).should.equal 32.0
56
- c.convert_from_c_to_f(100.0).should.equal 212.0
57
- end
58
- end
59
-
60
- And the generated report:
61
-
62
- == TemperatureCoverter
63
- * Convert
64
-
65
- This specification was translated from a Test::Unit file that has one test method,
66
- <tt>test_onvert</tt>. It doesn't read so well, and it doesn't convey much high-leve
67
- information about how the TemperatureCoverter class is supposed to behave. RSpec
68
- encourages developers to give specifications a name that conveys the intent of the
69
- specification. This in turn has several subtle benefits:
70
-
71
- * Specifications tend to become smaller
72
- * It tends to higlight too coupled code (specification names become complex)
73
-
74
- It is the developers' responsibility to make sure that the name of each specification
75
- represent at a high level what is being assumed in the specification body.
76
-
77
- == What about my existing Test::Unit tests?
78
- RSpec comes with a migration tool that will translate all of your existing
79
- Test::Unit tests to RSpec specifications.
80
-
81
- == How do I run RSpec specifications?
82
-
83
- There are several ways to do this.
84
-
85
- === Just run the ruby file
86
- Any RSpec specification is stand-alone and can be run with:
87
-
88
- ruby path/to/my/spec.rb
89
-
90
- This will run your spec and output the results to stdout. You can use command line options
91
- to tell RSpec to output documentation to a specific file too:
92
-
93
- ruby path/to/my/spec.rb --rspec-report doc/rspec_report.rd
94
-
95
- === Use the spec commandline
96
- You can run several specifications with:
97
-
98
- spec path/to/my/directory
99
-
100
- or
101
-
102
- spec path/to/my/directory --rspec-report doc/rspec_report.rd
103
-
104
- === Use Rake
105
- RSpec ships with a task similar that lets you run RSpec specifications
106
- from Rake. Just upt the following in your Rakefile:
107
-
108
- Rake::RSpecTask.new
109
-
110
- This will create a task called <tt>spec</tt> task that you can run like this:
111
-
112
- rake spec
113
-
114
- By default this will run all the specifications under the spec directory. See
115
- the Rake::RSpecTask documentation for details on how to override the defaults.