https://github.com/tansengming/yaml_test
Creates unit tests out of YAML files
https://github.com/tansengming/yaml_test
Last synced: 3 months ago
JSON representation
Creates unit tests out of YAML files
- Host: GitHub
- URL: https://github.com/tansengming/yaml_test
- Owner: tansengming
- License: mit
- Created: 2011-05-30T03:38:20.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2011-05-30T04:14:44.000Z (about 14 years ago)
- Last Synced: 2025-03-11T20:15:25.706Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 97.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE.txt
Awesome Lists containing this project
README
= yaml_test
I build this to make it easier to build unit tests for text processing objects. I.e. instead of typing
# assuming PhoneParser#parse exists.
assert_equal '515-222-1234', PhoneParser.new('You can call me at 515-222-1234').parse
assert_not_equal '515', PhoneParser.new('I live in room 515 but you can call me at 515-222-1234').parseYou'd write a YAML file:
-
text: > You can call me at 515-222-1234
expected: > 515-222-1234
method: parse
-
text: > I live in room 515 but you can call me at 515-222-1234
expected: > 515
method: parse
assertion: assert_not_equalWhich may seem like a waste of keystrokes but generally makes the tests a lot more readable. To include it in your unit tests just include the module and pass in the class you are testing together with the YAML path. Like so:
class TestYamlTest < Test::Unit::TestCase
include YAMLTest
yaml_test ObjectToTest, 'path_to_yaml_file.yml'
endSee tests/test_yaml_test.rb for a working example of how to do this.
== Contributing to yaml_test
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.== Copyright
Copyright (c) 2011 SengMing Tan. See LICENSE.txt for
further details.