Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FormulaMonks/contest
Write more readable tests in Test::Unit with this tiny script.
https://github.com/FormulaMonks/contest
Last synced: 3 months ago
JSON representation
Write more readable tests in Test::Unit with this tiny script.
- Host: GitHub
- URL: https://github.com/FormulaMonks/contest
- Owner: FormulaMonks
- License: mit
- Created: 2009-03-16T18:05:09.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2016-09-05T22:41:34.000Z (about 8 years ago)
- Last Synced: 2024-04-12T22:24:53.056Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 128 KB
- Stars: 142
- Watchers: 3
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
Contest
=======Contexts for Test::Unit.
Description
-----------Write declarative tests using nested contexts without performance penalties. Contest is less than 100 lines of code and gets the job done.
Usage
-----Declare your tests as you would in RSpec or Shoulda:
require 'contest'
class SomeTest < Test::Unit::TestCase
setup do
@value = 1
endteardown do
@value = nil
endtest "sample test" do
assert_equal 1, @value
endcontext "a context" do
setup do
@value += 1
endtest "more tests" do
assert_equal 2, @value
endcontext "a nested context" do
setup do
@value += 1
endtest "yet more tests" do
assert_equal 3, @value
end
end
end
endFor your convenience, `context` is aliased as `describe` and `test` is aliased as `should`, so this is valid:
class SomeTest < Test::Unit::TestCase
setup do
@value = 1
enddescribe "something" do
setup do
@value += 1
endshould "equal 2" do
assert_equal 2, @value
end
end
endYou can run it normally, it's Test::Unit after all. If you want to run a particular test, say "yet more tests", try this:
$ testrb my_test.rb -n test_yet_more_tests
Or with a regular expression:
$ testrb my_test.rb -n /yet_more_tests/
Installation
------------$ sudo gem install contest
If you want to use it with Rails, add this to config/environment.rb:
config.gem "contest"
Then you can vendor the gem:
rake gems:install
rake gems:unpackLicense
-------Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.## About Citrusbyte
![Citrusbyte](http://i.imgur.com/W6eISI3.png)
Contest is lovingly maintained and funded by Citrusbyte.
At Citrusbyte, we specialize in solving difficult computer science problems for startups and the enterprise.At Citrusbyte we believe in and support open source software.
* Check out more of our open source software at Citrusbyte Labs.
* Learn more about [our work](https://citrusbyte.com/portfolio).
* [Hire us](https://citrusbyte.com/contact) to work on your project.
* [Want to join the team?](http://careers.citrusbyte.com)*Citrusbyte and the Citrusbyte logo are trademarks or registered trademarks of Citrusbyte, LLC.*