Sha256: b1c0941d8decf69e69a81a907b809a76f6775bbf71d1bde227bf1a507faa89ef

Contents?: true

Size: 874 Bytes

Versions: 8

Compression:

Stored size: 874 Bytes

Contents

require File.dirname(__FILE__) + '/test_helper'

class DefineInstanceMethodTest < Test::Unit::TestCase
  class Item
    dsl_accessor :primary_key, "code", :instance=>true
  end

  class OtherClass
  end

  def test_dsl_accessor_doesnt_affect_other_classes
    assert !OtherClass.respond_to?(:primary_key)
  end

  def test_dsl_accessor_doesnt_affect_other_instances
    assert !OtherClass.new.respond_to?(:primary_key)
  end

  def test_class_method
    assert Item.respond_to?(:primary_key)
    assert_nothing_raised do
      Item.primary_key
    end
  end

  def test_class_method_value
    assert_equal "code", Item.primary_key
  end

  def test_instance_method
    assert Item.new.respond_to?(:primary_key)
    assert_nothing_raised do
      Item.new.primary_key
    end
  end

  def test_instance_method_value
    assert_equal "code", Item.new.primary_key
  end
end



Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
maiha-dsl_accessor-0.2.1 test/instance_test.rb
maiha-dsl_accessor-0.2.2 test/instance_test.rb
maiha-dsl_accessor-0.2 test/instance_test.rb
maiha-dsl_accessor-0.3.0 test/instance_test.rb
maiha-dsl_accessor-0.3.1 test/instance_test.rb
maiha-dsl_accessor-0.3.2 test/instance_test.rb
maiha-dsl_accessor-0.3.3 test/instance_test.rb
dsl_accessor-0.3.3 test/instance_test.rb