Last active
August 29, 2015 14:02
-
-
Save blowmage/a2b12948e2628baa9efb to your computer and use it in GitHub Desktop.
Updated Minitest::Spec doco
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
diff --git a/lib/minitest/spec.rb b/lib/minitest/spec.rb | |
index 40b5e6a..c5b334d 100644 | |
--- a/lib/minitest/spec.rb | |
+++ b/lib/minitest/spec.rb | |
@@ -22,6 +22,25 @@ module Kernel # :nodoc: | |
## | |
# Describe a series of expectations for a given target +desc+. | |
# | |
+ # You can describe your test by passing the object under test: | |
+ # | |
+ # describe FooWidget do | |
+ # it "creates a bar" do | |
+ # # ...and here | |
+ # end | |
+ # end | |
+ # | |
+ # You can also pass additional context to <tt>describe</tt>: | |
+ # | |
+ # describe FooWidget, :bar do | |
+ # it "creates a bar" do | |
+ # # test bar is created | |
+ # end | |
+ # it "updates a bar" do | |
+ # # test bar is update | |
+ # end | |
+ # end | |
+ # | |
# Defines a test class subclassing from either Minitest::Spec or | |
# from the surrounding describe's class. The surrounding class may | |
# subclass Minitest::Spec manually in order to easily share code: | |
@@ -110,13 +129,21 @@ class Minitest::Spec < Minitest::Test | |
# | |
# Eg: | |
# | |
- # register_spec_type(/Controller$/, Minitest::Spec::Rails) | |
+ # register_spec_type(/Widget$/, DummmyProject::WidgetTest) | |
# | |
# or: | |
# | |
- # register_spec_type(Minitest::Spec::RailsModel) do |desc| | |
- # desc.superclass == ActiveRecord::Base | |
+ # register_spec_type(DummmyProject::WidgetTest) do |desc| | |
+ # desc.superclass == DummmyProject::Widget | |
# end | |
+ # | |
+ # or: | |
+ # | |
+ # register_spec_type(DummmyProject::WidgetTest) do |desc, *addl_desc| | |
+ # addl_desc.include? :widget | |
+ # end | |
+ # | |
+ # See: spec_type | |
def register_spec_type(*args, &block) | |
if block then | |
@@ -128,9 +155,21 @@ class Minitest::Spec < Minitest::Test | |
end | |
## | |
- # Figure out the spec class to use based on a spec's description. Eg: | |
+ # Figure out the spec class to use based on a spec's description. | |
# | |
- # spec_type("BlahController") # => Minitest::Spec::Rails | |
+ # Eg: | |
+ # | |
+ # spec_type("FooWidget") # => DummmyProject::WidgetTest | |
+ # | |
+ # or: | |
+ # | |
+ # spec_type(FooWidget) # => DummmyProject::WidgetTest | |
+ # | |
+ # or: | |
+ # | |
+ # spec_type("Creates a widget", :widget) # => DummmyProject::WidgetTest | |
+ # | |
+ # See: register_spec_type | |
def spec_type desc, *additional | |
TYPES.find { |matcher, klass| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment