Module: Assert::Macros::Methods::ClassMethods

Defined in:
lib/assert/macros/methods.rb

Instance Method Summary collapse

Instance Method Details

#have_accessor(*methods) ⇒ Object Also known as: have_accessors



44
45
46
# File 'lib/assert/macros/methods.rb', line 44

def have_accessor(*methods)
  have_instance_methods(*methods.collect{|m| [m, "#{m}="]}.flatten)
end

#have_class_method(*methods) ⇒ Object Also known as: have_class_methods



23
24
25
26
27
28
29
30
31
# File 'lib/assert/macros/methods.rb', line 23

def have_class_method(*methods)
  Assert::Macro.new do
    methods.each do |method|
      should "respond to class method ##{method}" do
        assert_respond_to method, subject.class, "#{subject.class.name} does not have class method ##{method}"
      end
    end
  end
end

#have_instance_method(*methods) ⇒ Object Also known as: have_instance_methods



12
13
14
15
16
17
18
19
20
# File 'lib/assert/macros/methods.rb', line 12

def have_instance_method(*methods)
  Assert::Macro.new do
    methods.each do |method|
      should "respond to instance method ##{method}" do
        assert_respond_to method, subject, "#{subject.class.name} does not have instance method ##{method}"
      end
    end
  end
end

#have_reader(*methods) ⇒ Object Also known as: have_readers



34
35
36
# File 'lib/assert/macros/methods.rb', line 34

def have_reader(*methods)
  have_instance_methods(*methods)
end

#have_writer(*methods) ⇒ Object Also known as: have_writers



39
40
41
# File 'lib/assert/macros/methods.rb', line 39

def have_writer(*methods)
  have_instance_methods(*methods.collect{|m| "#{m}="})
end