Created
February 4, 2013 07:19
-
-
Save anonymous/4705398 to your computer and use it in GitHub Desktop.
What a minitest would look like if the test case object passed bare matcher methods in an "it" block to a "subject" in scope. Like RSpec :)
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
require 'minitest/autorun' | |
describe Person do | |
describe 'direct' do | |
subject { Person.new({pet: true}).pet? } | |
it { must_be true } | |
end | |
describe 'indirect' do | |
subject { Person.new({pet: true}) } | |
it { must_be :pet? } | |
end | |
end |
Actually I think what you are looking for is covered here: http://blog.arvidandersson.se/2012/03/28/minimalicous-testing-in-ruby-1-9
describe Person do
subject { Person.new("Yukihiro", "Matsumoto") }
it "has a full name" do
subject.full_name.must_equal "Yukihiro Matsumoto"
end
end
And
describe Person do
subject { Person.new }
specify { subject.posts.must_be_empty }
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is using: https://github.com/wojtekmach/valid_attribute
The
context
is defined in mytest_helper.rb
as:Also have a look at: https://github.com/zenspider/minitest-matchers
And one more option: