lib/lemon/test/case.rb in lemon-0.6 vs lib/lemon/test/case.rb in lemon-0.7.0
- old
+ new
@@ -48,12 +48,13 @@
def include(*mods)
extend *mods
end
# Define a new test concern for this case.
- def Concern(*description)
- concern = Concern.new(self, description)
+ # TODO: Probably will deprecate the &setup procedure (YAGNI).
+ def Concern(*description, &setup)
+ concern = Concern.new(self, description, &setup)
@concerns << concern
end
alias_method :concern, :Concern
@@ -72,46 +73,67 @@
# Define a unit test for this case.
def Unit(*targets, &block)
targets_hash = Hash===targets.last ? targets.pop : {}
targets_hash.each do |target_method, target_concern|
- @testunits << Unit.new(current_concern, target_method, target_concern, &block)
+ @testunits << Unit.new(current_concern, target_method, :aspect=>target_concern, &block)
end
targets.each do |target_method|
@testunits << Unit.new(current_concern, target_method, &block)
end
end
alias_method :unit, :Unit
+ # Define a meta-method unit test for this case.
+ def MetaUnit(*targets, &block)
+ targets_hash = Hash===targets.last ? targets.pop : {}
+ targets_hash.each do |target_method, target_concern|
+ @testunits << Unit.new(current_concern, target_method, :aspect=>target_concern, :metaclass=>true, &block)
+ end
+ targets.each do |target_method|
+ @testunits << Unit.new(current_concern, target_method, :metaclass=>true, &block)
+ end
+ end
+ alias_method :metaunit, :MetaUnit
+
# Define a before procedure for this case.
- def Before(match=nil, &block)
- @before_clauses[match] = block #<< Advice.new(match, &block)
+ def Before(*matches, &block)
+ matches == [nil] if matches.empty?
+ matches.each do |match|
+ @before_clauses[match] = block #<< Advice.new(match, &block)
+ end
end
+
alias_method :before, :Before
# Define an after procedure for this case.
- def After(match=nil, &block)
- @after_clauses[match] = block #<< Advice.new(match, &block)
+ def After(*matches, &block)
+ matches == [nil] if matches.empty?
+ matches.each do |match|
+ @after_clauses[match] = block #<< Advice.new(match, &block)
+ end
end
+
alias_method :after, :After
# Define a concern procedure to apply case-wide.
def When(match=nil, &block)
@when_clauses[match] = block #<< Advice.new(match, &block)
end
#
- def pending
- raise PendingAssertion
- end
+ #def pending
+ # raise Pending
+ #end
#
def to_s
target.to_s.sub(/^\#\<.*?\>::/, '')
end
end
end
-class PendingAssertion < Assertion
+class Pending < Assertion
+ def self.to_proc; lambda{ raise self }; end
end