Sha256: 0d1cf6ab4e04c50d3190ff6c2cbaf69dab912c5b2bab6641ef845ebbc061dc1b

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

class TestContact
  include SchemaTools::Modules::Attributes
  has_schema_attrs :client
end

class Numbers
  include SchemaTools::Modules::Attributes
  has_schema_attrs :numbers, :schema => schema_as_ruby_object
end

describe SchemaTools::Modules::Attributes do

  context 'included' do
    subject { TestContact.new }

    it 'should add getter methods' do
      subject.should respond_to(:last_name)
    end

    it 'should add setter methods' do
      subject.should respond_to('first_name=')
    end

    it 'should not add setter for readonly properties' do
      subject.should_not respond_to('id=')
      subject.should_not respond_to('created_at=')
    end
  end

  context 'attributes from dynamic schema' do
    subject { Numbers.new }

    it 'should add getter methods' do
      subject.should respond_to(:numbers)
    end

    it 'should add setter methods' do
      subject.should respond_to('numbers=')
    end

    it 'should not add setter for readonly properties' do
      subject.should_not respond_to('id=')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_schema_tools-0.1.2 spec/schema_tools/modules/attributes_spec.rb