test/module_test.rb in attribute_predicates-0.2.0 vs test/module_test.rb in attribute_predicates-0.2.1
- old
+ new
@@ -14,22 +14,22 @@
end
def test_should_create_predicate_for_readonly_attr
@module.attr(:foo)
%w(foo foo?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
%w(foo=).each do |method|
- assert !@module.instance_methods.include?(method), "#{method} exists"
+ assert !@module.method_defined?(method), "#{method} exists"
end
end
def test_should_create_predicate_for_readwrite_attr
@module.attr(:foo, true)
%w(foo foo= foo?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
end
end
class ModuleAttrReaderTest < Test::Unit::TestCase
@@ -38,26 +38,26 @@
end
def test_should_create_predicate
@module.attr_reader(:foo)
%w(foo foo?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
%w(foo=).each do |method|
- assert !@module.instance_methods.include?(method), "#{method} exists"
+ assert !@module.method_defined?(method), "#{method} exists"
end
end
def test_should_create_predicate_for_multiple_attributes
@module.attr_reader(:foo, :bar)
%w(foo foo? bar bar?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
%w(foo= bar=).each do |method|
- assert !@module.instance_methods.include?(method), "#{method} exists"
+ assert !@module.method_defined?(method), "#{method} exists"
end
end
end
class ModuleAttrAccessorTest < Test::Unit::TestCase
@@ -66,18 +66,18 @@
end
def test_should_create_predicate
@module.attr_accessor(:foo)
%w(foo foo= foo?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
end
def test_should_create_predicate_for_multiple_attributes
@module.attr_accessor(:foo, :bar)
%w(foo foo= foo? bar bar= bar?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
end
end
class ModuleAttrWriterTest < Test::Unit::TestCase
@@ -86,26 +86,26 @@
end
def test_should_create_predicate
@module.attr_writer(:foo)
%w(foo= foo?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
%w(foo).each do |method|
- assert !@module.instance_methods.include?(method), "#{method} exists"
+ assert !@module.method_defined?(method), "#{method} exists"
end
end
def test_should_create_predicate_for_multiple_attributes
@module.attr_writer(:foo, :bar)
%w(foo= foo? bar= bar?).each do |method|
- assert @module.instance_methods.include?(method), "#{method} does not exist"
+ assert @module.method_defined?(method), "#{method} does not exist"
end
%w(foo bar).each do |method|
- assert !@module.instance_methods.include?(method), "#{method} exists"
+ assert !@module.method_defined?(method), "#{method} exists"
end
end
end
class ModuleAttrPredicateTest < Test::Unit::TestCase
@@ -113,10 +113,10 @@
@module = Module.new
end
def test_should_create_predicate
@module.attr_predicate(:foo)
- assert @module.instance_methods.include?('foo?'), 'foo? does not exist'
+ assert @module.method_defined?('foo?'), 'foo? does not exist'
end
end
class ModuleTest < Test::Unit::TestCase
def setup