-
-
Save elle/4710618 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Minitest examples | |
# wishful | |
describe Person do | |
describe 'indirect' do | |
subject { Person.new({pet: true}) } | |
it { must_be :pet? } | |
end | |
end | |
# current | |
# Example 1: using valid_attributes [3] | |
describe Person do | |
context 'should have validations' do | |
subject { Person.new } | |
it { must have_valid(:name).when(sentence) } | |
it { wont have_valid(:name).when(nil, '') } | |
end | |
end | |
# Example 2 | |
describe Person do | |
let(:person) { Person.new({pet: true}) } | |
it 'has a pet' do | |
assert person.pet? | |
end | |
end | |
# Example 3 | |
describe Person do | |
subject { Person.new("Yukihiro", "Matsumoto") } | |
it "has a full name" do | |
subject.full_name.must_equal "Yukihiro Matsumoto" | |
end | |
end | |
And | |
# Example 4 | |
describe Person do | |
subject { Person.new } | |
specify { subject.posts.must_be_empty } | |
end | |
Links: | |
[1] http://blog.arvidandersson.se/2012/03/28/minimalicous-testing-in-ruby-1-9 | |
[2] https://github.com/zenspider/minitest-matchers | |
[3] https://github.com/wojtekmach/valid_attribute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment