Module: Useful::ShouldaMacros::TestUnit::Classes
- Defined in:
- lib/useful/shoulda_macros/test_unit/classes.rb
Instance Method Summary collapse
- #should_have_accessors(*accessors) ⇒ Object
-
#should_have_class_methods(*methods) ⇒ Object
Ripped from Shoulda::ActiveRecord::Macros.
-
#should_have_instance_methods(*methods) ⇒ Object
Ripped from Shoulda::ActiveRecord::Macros.
- #should_have_readers(*readers) ⇒ Object
- #should_have_writers(*writers) ⇒ Object
Instance Method Details
#should_have_accessors(*accessors) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/useful/shoulda_macros/test_unit/classes.rb', line 54 def should_have_accessors(*accessors) (accessors) klass = described_type accessors.each do |accessor| should_have_instance_methods accessor, "#{accessor}=" end end |
#should_have_class_methods(*methods) ⇒ Object
Ripped from Shoulda::ActiveRecord::Macros
28 29 30 31 32 33 34 35 36 |
# File 'lib/useful/shoulda_macros/test_unit/classes.rb', line 28 def should_have_class_methods(*methods) (methods) klass = described_type methods.each do |method| should "respond to class method ##{method}" do assert_respond_to klass, method, "#{klass.name} does not have class method #{method}" end end end |
#should_have_instance_methods(*methods) ⇒ Object
Ripped from Shoulda::ActiveRecord::Macros
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/useful/shoulda_macros/test_unit/classes.rb', line 12 def should_have_instance_methods(*methods) (methods) klass = described_type methods.each do |method| should "respond to instance method ##{method}" do the_subject = begin klass.new rescue Exception => err subject end assert_respond_to(the_subject, method, "#{klass.name} does not have instance method #{method}") end end end |
#should_have_readers(*readers) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/useful/shoulda_macros/test_unit/classes.rb', line 38 def should_have_readers(*readers) (readers) klass = described_type readers.each do |reader| should_have_instance_methods reader end end |
#should_have_writers(*writers) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/useful/shoulda_macros/test_unit/classes.rb', line 46 def should_have_writers(*writers) (writers) klass = described_type writers.each do |writer| should_have_instance_methods "#{writer}=" end end |