Class: Shoulda::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/test4requirements/shoulda.rb

Instance Method Summary collapse

Instance Method Details

#should(name_or_matcher, options = {}, &blk) ⇒ Object

Extend #should inside a context to support assignment to requirement.

Usage:

should 'fullfill request 1', requirement: :req1  do
  assert_equal(2,1+1)
end


74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/test4requirements/shoulda.rb', line 74

def should(name_or_matcher, options = {}, &blk)
  if options[:requirement]
    #testmethodname must fit self.name of the later test (TestCase#run_test)
    testmethodname = 'test: '
    testmethodname << self.name
    testmethodname << ' should '
    testmethodname << name_or_matcher
    testmethodname << '. '
    testmethodname << "(#{self.parent.name})"
    raise RuntimeError, "No requirements defined for #{self}" unless get_requirements
    get_requirements.assign_test(options[:requirement], testmethodname, Test4requirements::TestResults.new )
  end
  should_old(name_or_matcher, options = {}, &blk)
end

#should_oldObject

remember original definition.



65
# File 'lib/test4requirements/shoulda.rb', line 65

alias  :should_old :should