Sha256: 693d771b9bb6e2a6aaa05d09e5c69247056e44c9f86ecc7334618f3e95299a00

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 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

    it 'should add schema_name to class' do
      subject.class.schema_name.should == :client
    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

4 entries across 4 versions & 1 rubygems

Version Path
json_schema_tools-0.2.3 spec/schema_tools/modules/attributes_spec.rb
json_schema_tools-0.2.2 spec/schema_tools/modules/attributes_spec.rb
json_schema_tools-0.2.1 spec/schema_tools/modules/attributes_spec.rb
json_schema_tools-0.2.0 spec/schema_tools/modules/attributes_spec.rb