test/module_test.rb in attribute_predicates-0.1.0 vs test/module_test.rb in attribute_predicates-0.1.1

- old
+ new

@@ -13,22 +13,22 @@ @module = Module.new end def test_should_create_predicate_for_readonly_attr @module.attr(:foo) - ['foo', 'foo?'].each do |method| + %w(foo foo?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end - ['foo='].each do |method| + %w(foo=).each do |method| assert !@module.instance_methods.include?(method), "#{method} exists" end end def test_should_create_predicate_for_readwrite_attr @module.attr(:foo, true) - ['foo', 'foo=', 'foo?'].each do |method| + %w(foo foo= foo?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end end end @@ -37,26 +37,26 @@ @module = Module.new end def test_should_create_predicate @module.attr_reader(:foo) - ['foo', 'foo?'].each do |method| + %w(foo foo?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end - ['foo='].each do |method| + %w(foo=).each do |method| assert !@module.instance_methods.include?(method), "#{method} exists" end end def test_should_create_predicate_for_multiple_attributes @module.attr_reader(:foo, :bar) - ['foo', 'foo?', 'bar', 'bar?'].each do |method| + %w(foo foo? bar bar?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end - ['foo=', 'bar='].each do |method| + %w(foo= bar=).each do |method| assert !@module.instance_methods.include?(method), "#{method} exists" end end end @@ -65,18 +65,18 @@ @module = Module.new end def test_should_create_predicate @module.attr_accessor(:foo) - ['foo', 'foo=', 'foo?'].each do |method| + %w(foo foo= foo?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end end def test_should_create_predicate_for_multiple_attributes @module.attr_accessor(:foo, :bar) - ['foo', 'foo=', 'foo?', 'bar', 'bar=', 'bar?'].each do |method| + %w(foo foo= foo? bar bar= bar?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end end end @@ -85,26 +85,26 @@ @module = Module.new end def test_should_create_predicate @module.attr_writer(:foo) - ['foo=', 'foo?'].each do |method| + %w(foo= foo?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end - ['foo'].each do |method| + %w(foo).each do |method| assert !@module.instance_methods.include?(method), "#{method} exists" end end def test_should_create_predicate_for_multiple_attributes @module.attr_writer(:foo, :bar) - ['foo=', 'foo?', 'bar=', 'bar?'].each do |method| + %w(foo= foo? bar= bar?).each do |method| assert @module.instance_methods.include?(method), "#{method} does not exist" end - ['foo', 'bar'].each do |method| + %w(foo bar).each do |method| assert !@module.instance_methods.include?(method), "#{method} exists" end end end @@ -129,9 +129,10 @@ end def test_should_evaluate_false_values_for_predicate @klass.attr_accessor(:foo) + # *Note* ' ' is only false when ActiveSupport is being used [nil, '', ' ', {}, []].each do |value| assert_equal false, @klass.new(value).foo?, "#{value.inspect} is true" end end