assert 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +16 -4
  2. data/{CHANGELOG.rdoc → CHANGELOG.md} +14 -3
  3. data/LICENSE +22 -0
  4. data/README.md +261 -0
  5. data/Rakefile +1 -1
  6. data/assert.gemspec +2 -1
  7. data/lib/assert/assertions.rb +16 -0
  8. data/lib/assert/autorun.rb +11 -7
  9. data/lib/assert/macros/methods.rb +49 -3
  10. data/lib/assert/rake_tasks.rb +13 -7
  11. data/lib/assert/rake_tasks/irb.rb +1 -1
  12. data/lib/assert/rake_tasks/scope.rb +55 -28
  13. data/lib/assert/rake_tasks/test_task.rb +4 -1
  14. data/lib/assert/result.rb +7 -9
  15. data/lib/assert/result_set.rb +7 -4
  16. data/lib/assert/runner.rb +10 -10
  17. data/lib/assert/setup/helpers.rb +5 -3
  18. data/lib/assert/setup/runner.rb +2 -3
  19. data/lib/assert/setup/suite.rb +2 -5
  20. data/lib/assert/setup/view.rb +26 -3
  21. data/lib/assert/test.rb +56 -37
  22. data/lib/assert/version.rb +1 -1
  23. data/lib/assert/view/base.rb +75 -0
  24. data/lib/assert/view/default_view.rb +75 -0
  25. data/lib/assert/view/helpers/ansi_styles.rb +25 -0
  26. data/lib/assert/view/helpers/capture_output.rb +23 -0
  27. data/lib/assert/view/helpers/common.rb +154 -0
  28. data/test/assertions/assert_file_exists_test.rb +43 -0
  29. data/test/assertions/assert_not_file_exists_test.rb +43 -0
  30. data/test/assertions_test.rb +4 -1
  31. data/test/macro_test.rb +25 -0
  32. data/test/rake_tasks/irb_test.rb +2 -2
  33. data/test/rake_tasks/scope_test.rb +9 -9
  34. data/test/result_set_test.rb +13 -23
  35. data/test/runner_test.rb +1 -1
  36. data/test/test/{running_test.rb → running_tests.rb} +14 -14
  37. data/test/view/base_tests.rb +65 -0
  38. metadata +29 -18
  39. data/Gemfile.lock +0 -23
  40. data/README.rdoc +0 -183
@@ -1,23 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- assert (0.7.3)
5
- assert-view (~> 0.5)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- ansi (1.4.1)
11
- assert-view (0.5.0)
12
- ansi (~> 1.3)
13
- undies (~> 2.0)
14
- rake (0.9.2)
15
- undies (2.0.0)
16
-
17
- PLATFORMS
18
- ruby
19
-
20
- DEPENDENCIES
21
- assert!
22
- bundler (~> 1.0)
23
- rake (~> 0.9.2)
@@ -1,183 +0,0 @@
1
- = Assert
2
-
3
- Test::Unit style testing framework, just better than Test::Unit.
4
-
5
- == What Assert is
6
-
7
- * *Framework*: you define tests and the context they run in - Assert runs them. Everything is pure ruby so use any 3rd party testing tools you like. Create 3rd party tools that extend Assert behavior.
8
- * *First* *Class*: everything is a first class object and can be extended to your liking (and should be)
9
- * *MVC*: tests and how they are defined (M) and executed (C) are distinct from how you view the test results (V).
10
- * *Backwards* *compatible*: (assuming a few minor tweaks) with Test::Unit test suites
11
-
12
- == What Assert is not
13
-
14
- * *Rspec*
15
- * *Unit/Functional/Integration/etc*: Assert is agnostic - you define whatever kinds of tests you like (one or more of the above) and assert runs them in context.
16
- * *Mock/Spec/BDD/Factories/etc*: Assert is the framework and there are a variety of 3rd party tools to do such things - feel free to use whatever you like.
17
-
18
-
19
-
20
- == Description
21
-
22
- Assert is a Test::Unit style testing framework. This means you can write tests in Assert the same way you would with Test::Unit. In addition, Assert adds some helpers and syntax sugar to enhance the way tests are written - most taken from ideas in Shoulda and Leftright. Assert uses class-based contexts so if you want to nest your contexts, use good old inheritance.
23
-
24
- Assert is tested using itself. The tests are a pretty good place to look for examples and usage patterns. In addition (TODO) check out the wiki and ./examples in the source.
25
-
26
-
27
-
28
- == Installation
29
-
30
- gem install assert
31
-
32
-
33
-
34
- == Usage
35
-
36
- require 'assert'
37
-
38
- class MyTests < Assert::Context
39
-
40
- def test_something
41
- assert_equal 1, 1
42
- end
43
-
44
- end
45
-
46
-
47
-
48
- == Models
49
- Assert models exist to define, collect, structure, and report on Assert test data.
50
-
51
- === Context
52
- Context defines the scope that tests are run in. When tests are run, a new instance of the test context is created and the test code is evaluated within scope of this context instance. Context provides methods for defining tests and test callbacks and for generating test results in running tests. Subclass context classes to achieve nested context behavior
53
-
54
- === Suite
55
- Suite is reponsible for collecting and structuring tests and defines the set of tests to run be the test runner. Tests are grouped within the suite by their context. Suite provides access to the contexts, test, and test results to both test runners and views. In addition, the Suite model provides some stats readers (ie. run_time, runnner_seed, etc...) for use by the test runner and views.
56
-
57
- === Test
58
- Test defines the test code that needs to be run and the results generated by that test code. Tests are aware of their context and are responsible for running their code in context.
59
-
60
- === Result
61
- Result defines the data related to a test result. There are a few kinds of test results available:
62
- * Pass
63
- * Fail
64
- * Error
65
- * Skip
66
- * Ignore
67
-
68
- Tests produce results as they are executed. Every assert statement produces a result. Some results, like Error and Skip, will halt execution. Pass and Ignore results do not halt execution. Fail results, by default, halt execution but there is an option to have them not halt execution. Therefore, tests can have many results of varying types.
69
-
70
- === Macro
71
- Macros are procs that define sets of test code and make it available for easy reuse. Macros work nicely with the 'should' and 'test' context methods.
72
-
73
-
74
-
75
- == User Options and Helpers
76
- Assert provides ways for setting user-specfic options and helpers. When Assert is setting itself up, the last setup step is to look for and require the file ~/.assert/options.rb. This file is essentially a user level test helper file. Use it to set options, configure assert extensions, setup or define how to view test results, etc.
77
-
78
-
79
-
80
- == Running Tests
81
- Assert uses a Runner object to run tests. Any runner object should take the test suite and view as arguments and should provide a 'run' method that runs the tests and renders the view.
82
-
83
- === Default Runner
84
- Assert provides a default Runner object for running test suites (https://github.com/teaminsight/assert/blob/master/lib/assert/runner.rb). The default provides methods for running the tests, randomizing test order, and benchmarking test run time. Feel free to extend this runner as you see fit.
85
-
86
- === Test Order
87
- The default Runner object runs tests in random order and the default Terminal view will display the seed value. If you want to run tests in a consistant order, set a 'runner_seed' environment variable. Here's an example running tests with rake:
88
-
89
- $ rake test # run tests in random order
90
- $ rake test runner_seed=1234 # run tests seeding with '1234'
91
-
92
- === Failure Handling
93
- Assert, by default, will halt test execution when a test produces a Fail result. However, Assert provides an option to not halt when Fail results are produced. You can control how assert handles fails by either setting an option (in your user .assert/options.rb file) or by setting an env variable:
94
-
95
- Assert::Test.options.halt_on_fail false # force not halting on fail results
96
-
97
- $ rake test halt_on_fail=true # force halt on failure using an env var
98
-
99
-
100
- === Rake Tasks
101
- Assert provides some rake task helpers that will scan your test folder and recursively generate rake tasks for each one of your test folders or files ending in '_test'. Use this as an alternative to running ruby on each one of your test files individually.
102
-
103
- As an example, say your test folder has a file structure like so:
104
-
105
- - test
106
- | - basic_test.rb
107
- | - helper.rb
108
- | - complex
109
- | | - fast_tests.rb
110
- | | - slow_tests.rb
111
-
112
- Add the following to your Rakefile to generate the test tasks:
113
-
114
- require 'assert/rake_tasks'
115
- Assert::RakeTasks.for(:test)
116
-
117
- This would generate following rake tasks:
118
-
119
- $ rake -T
120
- rake test # Run all tests
121
- rake test:basic # Run tests for basic
122
- rake test:complex # Run all tests for assertions
123
- rake test:complex:fast # Run tests for assertions:assert_block
124
- rake test:complex:slow # Run tests for assertions:assert_empty
125
-
126
- By default, the rake tasks do not show which test files are being loaded. If you want to see this output from the rake tasks, set a "show_loaded_files" environment variable at the rake command line:
127
-
128
- $ rake test show_loaded_files=true # run the tests showing which files were loaded
129
-
130
- === IRB with your environment loaded
131
- Assert provides a rake task for running irb with your test environment loaded. Create an irb.rb file in your test file directory and have it require 'assert/setup'. See https://github.com/teaminsight/assert/blob/master/test/irb.rb for an example. Here's how you could use it:
132
-
133
- $ rake irb
134
- > Assert
135
- => Assert
136
- >
137
-
138
- == The Assert family of testing tools
139
-
140
- These are all tools that use and extend Assert. If you write your own, share it with us and we will post it here.
141
-
142
- === assert-view
143
- Assert::View (https://github.com/teaminsight/assert-view) is a collection of views that can be used with Assert. Specify what view you want to use in your ~/.assert/options.rb settings file, ie:
144
-
145
- # default is Assert::View::DefaultView on $stdout
146
- Assert.options.view Assert::View::SuperCoolView.new($stdout)
147
-
148
-
149
-
150
- == Contributing
151
-
152
- The source code is hosted on Github. It's clean, modular, and easy to understand. Feel free to submit pull requests and file bugs on the issues tracker.
153
-
154
- One note, however: please respect that Assert itself is intended to be the flexible, base-level type logic that should change little if at all. Pull requests for niche functionality or personal testing philosphy stuff will likely not be accepted.
155
-
156
- If you wish to extend Assert for your niche purpose/desire/philosophy, please do so in it's own gem (named 'assert-<whatever>') that uses Assert as a dependency. When you do, tell us about it and we'll add to the Family of tools.
157
-
158
-
159
-
160
- == License
161
-
162
- Copyright (c) 2011 Kelly Redding, Collin Redding, and Team Insight
163
-
164
- Permission is hereby granted, free of charge, to any person
165
- obtaining a copy of this software and associated documentation
166
- files (the "Software"), to deal in the Software without
167
- restriction, including without limitation the rights to use,
168
- copy, modify, merge, publish, distribute, sublicense, and/or sell
169
- copies of the Software, and to permit persons to whom the
170
- Software is furnished to do so, subject to the following
171
- conditions:
172
-
173
- The above copyright notice and this permission notice shall be
174
- included in all copies or substantial portions of the Software.
175
-
176
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
177
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
178
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
179
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
180
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
181
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
182
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
183
- OTHER DEALINGS IN THE SOFTWARE.