exemplor 2010.2.0 → 3000.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.md +221 -0
  2. data/Rakefile +8 -4
  3. data/TODO +13 -6
  4. data/VERSION +1 -1
  5. data/examples.rb +62 -51
  6. data/examples/assertion_failure.rb +3 -5
  7. data/examples/assertion_success.rb +2 -3
  8. data/examples/assertion_success_and_failure.rb +8 -12
  9. data/examples/assertion_success_and_info.rb +8 -11
  10. data/examples/check_parsing.rb +8 -17
  11. data/examples/checking_nil.rb +6 -5
  12. data/examples/failure_halts_execution.rb +3 -5
  13. data/examples/foobar.rb +9 -0
  14. data/examples/helpers.rb +1 -1
  15. data/examples/{with_checks.rb → multi_show.rb} +3 -3
  16. data/examples/no_checks_non_string.rb +1 -1
  17. data/examples/{check_with_disambiguation.rb → show_with_disambiguation.rb} +2 -2
  18. data/examples/{dumping_classes.rb → showing_classes.rb} +1 -1
  19. data/examples/simple_show.rb +15 -0
  20. data/examples/ten_percent_failures.rb +10 -10
  21. data/examples/with_setup.rb +5 -7
  22. data/lib/checker.rb +30 -10
  23. data/lib/environment.rb +32 -23
  24. data/lib/examples.rb +2 -1
  25. data/lib/exemplor.rb +2 -1
  26. data/lib/result_printer.rb +40 -21
  27. data/vendor/orderedhash-0.0.6/gemspec.rb +37 -0
  28. data/vendor/orderedhash-0.0.6/install.rb +213 -0
  29. data/vendor/orderedhash-0.0.6/lib/orderedautohash.rb +25 -0
  30. data/vendor/orderedhash-0.0.6/lib/orderedhash.rb +200 -0
  31. data/vendor/term-ansicolor-1.0.5/CHANGES +28 -0
  32. data/vendor/term-ansicolor-1.0.5/COPYING +340 -0
  33. data/vendor/term-ansicolor-1.0.5/README +137 -0
  34. data/vendor/term-ansicolor-1.0.5/Rakefile +88 -0
  35. data/vendor/term-ansicolor-1.0.5/VERSION +1 -0
  36. data/vendor/term-ansicolor-1.0.5/bin/cdiff +19 -0
  37. data/vendor/term-ansicolor-1.0.5/bin/decolor +12 -0
  38. data/vendor/term-ansicolor-1.0.5/examples/example.rb +90 -0
  39. data/vendor/term-ansicolor-1.0.5/install.rb +15 -0
  40. data/vendor/term-ansicolor-1.0.5/lib/term/ansicolor.rb +102 -0
  41. data/vendor/term-ansicolor-1.0.5/lib/term/ansicolor/version.rb +10 -0
  42. data/vendor/term-ansicolor-1.0.5/tests/ansicolor_test.rb +66 -0
  43. metadata +34 -41
  44. data/README +0 -152
data/README DELETED
@@ -1,152 +0,0 @@
1
- Exemplor (the exemplar)
2
- =======================
3
-
4
- An example-based test framework inspired by [testy](http://github.com/ahoward/testy).
5
-
6
- Simpler that BDD/TDD, fancier than a file with a bunch of print statements.
7
-
8
- Very tiny api. Here it is
9
-
10
- eg.helpers do
11
- ... your helpers ...
12
- end
13
-
14
- eg.setup { ... setup codez ... }
15
-
16
- eg "an example" do
17
- ... example code ...
18
- end
19
-
20
- eg "another example" do
21
- ... etc ...
22
- end
23
-
24
- The output is both human readable and machine parsable, which means you can test your tests.
25
-
26
- Writing Examples
27
- ----------------
28
-
29
- See `examples.rb` and `/examples` for more examples.
30
-
31
- The simplest possible example:
32
-
33
- eg 'An example block without any checks prints the value of the block' do
34
- "foo"
35
- end
36
-
37
- #=>
38
-
39
- (i) An example block without any checks prints the value of the block: foo
40
-
41
- The 'i' stands for 'info' which means the example ran without error.
42
-
43
- Inspecting a few values, by default `Check` prints its argument and the value of the argument:
44
-
45
- eg 'Accessing different parts of an array' do
46
- list = [1, 2, 3]
47
- Check(list.first)
48
- Check(list[1])
49
- Check(list.last)
50
- end
51
-
52
- #=>
53
-
54
- (I) Accessing different parts of an array:
55
- (i) list.first: 1
56
- (i) list[1]: 2
57
- (i) list.last: 3
58
-
59
- The capital 'I' means all checks were 'info' checks.
60
-
61
- Calls to `Check` with the same argument can be disambiguated with `[]`:
62
-
63
- eg 'Array appending' do
64
- list = [1, 42]
65
- Check(list.last)["before append"]
66
- list << 2
67
- Check(list.last)["after append"]
68
- end
69
-
70
- #=>
71
-
72
- (I) Array appending:
73
- (i) list.last before append: 42
74
- (i) list.last after append: 2
75
-
76
- Errors are caught and reported nicely:
77
-
78
- eg 'Raising an error' do
79
- raise "boom!"
80
- end
81
-
82
- #=>
83
-
84
- (e) Raising an error:
85
- class: RuntimeError
86
- message: boom!
87
- backtrace:
88
- - examples/an_error.rb:4
89
- # ... more backtrace lines
90
-
91
- Once you're happy with how your code is running you can make some assertions about its behaviour by adding `is()` calls after your `Check()` statements:
92
-
93
-
94
- eg 'Asserting first is first' do
95
- list = [1, 2, 3]
96
- Check(list.first).is(1)
97
- end
98
-
99
- #=>
100
-
101
- (s) Asserting first is first:
102
- (s) list.first: 1
103
-
104
- 's' stands for 'success' and 'f' for failure:
105
-
106
- eg 'Assertion failure' do
107
- list = [1, 2, 3]
108
- Check(list.first).is(2)
109
- end
110
-
111
- #=>
112
-
113
- (f) Assertion failure:
114
- (f) list.first:
115
- expected: 2
116
- actual: 1
117
-
118
-
119
- Running Examples
120
- ----------------
121
-
122
- Running with `--list` or `-l` lists all examples:
123
-
124
- $> ruby examples.rb -l
125
- - errors are caught and nicely displayed
126
- - check_output_matches_expected_for :no_checks
127
- - check_output_matches_expected_for :oneliner
128
- - check_output_matches_expected_for :no_checks_non_string
129
- - check_output_matches_expected_for :with_checks
130
- - check_output_matches_expected_for :check_with_disambiguation
131
- - check_output_matches_expected_for :assertion_success
132
- - check_output_matches_expected_for :assertion_failure
133
- - check_output_matches_expected_for :assertion_success_and_failure
134
- - check_output_matches_expected_for :helpers
135
- - check_output_matches_expected_for :with_setup
136
- - called with --list arg
137
- - called with --l arg
138
- - called with some other arg (always interpreted as a regex)
139
-
140
- Otherwise the first argument is taken as a regex and only examples whose titles match are run:
141
-
142
- $> ruby examples.rb called
143
- (s) called with --list arg:
144
- (s) list:
145
- - Modified env
146
- - Unmodified env
147
- (s) called with --l arg:
148
- (s) list:
149
- - Modified env
150
- - Unmodified env
151
- (s) called with some other arg (always interpreted as a regex):
152
- (s) tests_run: 1