Permalink
Browse files

reindent

[git-p4: depot-paths = "//src/minitest/dev/": change = 8290]
  • Loading branch information...
1 parent 06b9ce3 commit 9523805e3bb33297497bee1f502286dfa3ca800d @zenspider zenspider committed Mar 7, 2013
Showing with 129 additions and 129 deletions.
  1. +129 −129 lib/minitest/spec.rb
View
@@ -86,167 +86,167 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
# Oh look! A MiniTest::Spec::DSL module! Eat your heart out DHH.
module DSL
- ##
- # Contains pairs of matchers and Spec classes to be used to
- # calculate the superclass of a top-level describe. This allows for
- # automatically customizable spec types.
- #
- # See: register_spec_type and spec_type
-
- TYPES = [[//, MiniTest::Spec]]
-
- ##
- # Register a new type of spec that matches the spec's description.
- # This method can take either a Regexp and a spec class or a spec
- # class and a block that takes the description and returns true if
- # it matches.
- #
- # Eg:
- #
- # register_spec_type(/Controller$/, MiniTest::Spec::Rails)
- #
- # or:
- #
- # register_spec_type(MiniTest::Spec::RailsModel) do |desc|
- # desc.superclass == ActiveRecord::Base
- # end
-
- def register_spec_type(*args, &block)
- if block then
- matcher, klass = block, args.first
- else
- matcher, klass = *args
- end
- TYPES.unshift [matcher, klass]
- end
-
- ##
- # Figure out the spec class to use based on a spec's description. Eg:
- #
- # spec_type("BlahController") # => MiniTest::Spec::Rails
-
- def spec_type desc
- TYPES.find { |matcher, klass|
- if matcher.respond_to? :call then
- matcher.call desc
+ ##
+ # Contains pairs of matchers and Spec classes to be used to
+ # calculate the superclass of a top-level describe. This allows for
+ # automatically customizable spec types.
+ #
+ # See: register_spec_type and spec_type
+
+ TYPES = [[//, MiniTest::Spec]]
+
+ ##
+ # Register a new type of spec that matches the spec's description.
+ # This method can take either a Regexp and a spec class or a spec
+ # class and a block that takes the description and returns true if
+ # it matches.
+ #
+ # Eg:
+ #
+ # register_spec_type(/Controller$/, MiniTest::Spec::Rails)
+ #
+ # or:
+ #
+ # register_spec_type(MiniTest::Spec::RailsModel) do |desc|
+ # desc.superclass == ActiveRecord::Base
+ # end
+
+ def register_spec_type(*args, &block)
+ if block then
+ matcher, klass = block, args.first
else
- matcher === desc.to_s
+ matcher, klass = *args
end
- }.last
- end
-
- @@describe_stack = []
- def describe_stack # :nodoc:
- @@describe_stack
- end
+ TYPES.unshift [matcher, klass]
+ end
- ##
- # Returns the children of this spec.
+ ##
+ # Figure out the spec class to use based on a spec's description. Eg:
+ #
+ # spec_type("BlahController") # => MiniTest::Spec::Rails
- def children
- @children ||= []
- end
+ def spec_type desc
+ TYPES.find { |matcher, klass|
+ if matcher.respond_to? :call then
+ matcher.call desc
+ else
+ matcher === desc.to_s
+ end
+ }.last
+ end
- def nuke_test_methods! # :nodoc:
- self.public_instance_methods.grep(/^test_/).each do |name|
- self.send :undef_method, name
+ @@describe_stack = []
+ def describe_stack # :nodoc:
+ @@describe_stack
end
- end
- ##
- # Define a 'before' action. Inherits the way normal methods should.
- #
- # NOTE: +type+ is ignored and is only there to make porting easier.
- #
- # Equivalent to MiniTest::Unit::TestCase#setup.
+ ##
+ # Returns the children of this spec.
- def before type = nil, &block
- define_method :setup do
- super()
- self.instance_eval(&block)
+ def children
+ @children ||= []
end
- end
-
- ##
- # Define an 'after' action. Inherits the way normal methods should.
- #
- # NOTE: +type+ is ignored and is only there to make porting easier.
- #
- # Equivalent to MiniTest::Unit::TestCase#teardown.
- def after type = nil, &block
- define_method :teardown do
- self.instance_eval(&block)
- super()
+ def nuke_test_methods! # :nodoc:
+ self.public_instance_methods.grep(/^test_/).each do |name|
+ self.send :undef_method, name
+ end
end
- end
- ##
- # Define an expectation with name +desc+. Name gets morphed to a
- # proper test method name. For some freakish reason, people who
- # write specs don't like class inheritance, so this goes way out of
- # its way to make sure that expectations aren't inherited.
- #
- # This is also aliased to #specify and doesn't require a +desc+ arg.
- #
- # Hint: If you _do_ want inheritence, use minitest/unit. You can mix
- # and match between assertions and expectations as much as you want.
+ ##
+ # Define a 'before' action. Inherits the way normal methods should.
+ #
+ # NOTE: +type+ is ignored and is only there to make porting easier.
+ #
+ # Equivalent to MiniTest::Unit::TestCase#setup.
+
+ def before type = nil, &block
+ define_method :setup do
+ super()
+ self.instance_eval(&block)
+ end
+ end
- def it desc = "anonymous", &block
- block ||= proc { skip "(no tests defined)" }
+ ##
+ # Define an 'after' action. Inherits the way normal methods should.
+ #
+ # NOTE: +type+ is ignored and is only there to make porting easier.
+ #
+ # Equivalent to MiniTest::Unit::TestCase#teardown.
+
+ def after type = nil, &block
+ define_method :teardown do
+ self.instance_eval(&block)
+ super()
+ end
+ end
- @specs ||= 0
- @specs += 1
+ ##
+ # Define an expectation with name +desc+. Name gets morphed to a
+ # proper test method name. For some freakish reason, people who
+ # write specs don't like class inheritance, so this goes way out of
+ # its way to make sure that expectations aren't inherited.
+ #
+ # This is also aliased to #specify and doesn't require a +desc+ arg.
+ #
+ # Hint: If you _do_ want inheritence, use minitest/unit. You can mix
+ # and match between assertions and expectations as much as you want.
- name = "test_%04d_%s" % [ @specs, desc ]
+ def it desc = "anonymous", &block
+ block ||= proc { skip "(no tests defined)" }
- define_method name, &block
+ @specs ||= 0
+ @specs += 1
- self.children.each do |mod|
- mod.send :undef_method, name if mod.public_method_defined? name
- end
+ name = "test_%04d_%s" % [ @specs, desc ]
- name
- end
+ define_method name, &block
- ##
- # Essentially, define an accessor for +name+ with +block+.
- #
- # Why use let instead of def? I honestly don't know.
+ self.children.each do |mod|
+ mod.send :undef_method, name if mod.public_method_defined? name
+ end
- def let name, &block
- define_method name do
- @_memoized ||= {}
- @_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
+ name
end
- end
- ##
- # Another lazy man's accessor generator. Made even more lazy by
- # setting the name for you to +subject+.
+ ##
+ # Essentially, define an accessor for +name+ with +block+.
+ #
+ # Why use let instead of def? I honestly don't know.
- def subject &block
- let :subject, &block
- end
+ def let name, &block
+ define_method name do
+ @_memoized ||= {}
+ @_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
+ end
+ end
- def create name, desc # :nodoc:
- cls = Class.new(self) do
- @name = name
- @desc = desc
+ ##
+ # Another lazy man's accessor generator. Made even more lazy by
+ # setting the name for you to +subject+.
- nuke_test_methods!
+ def subject &block
+ let :subject, &block
end
- children << cls
+ def create name, desc # :nodoc:
+ cls = Class.new(self) do
+ @name = name
+ @desc = desc
- cls
- end
+ nuke_test_methods!
+ end
+
+ children << cls
+
+ cls
+ end
- # :stopdoc:
+ # :stopdoc:
attr_reader :desc
alias :specify :it
alias :name :to_s
- # :startdoc:
+ # :startdoc:
end
extend DSL

0 comments on commit 9523805

Please sign in to comment.