Sha256: efc6252c59b8c996ee21391a9ddee328409ccf93ff88d4a4b3b11416c0b62287

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

module JSON
  module Generator
    describe BasicAttribute do
      describe '#generate' do
        context 'with default value' do
          let(:properties) { {'default' => stub('default')} }

          it 'should return the default value' do
            described_class.new(properties).generate.should == properties['default']
          end
        end
      end

      describe '#required?' do
        context 'when required property is true' do
          let(:properties) { {'required' => true} }

          it 'should be required' do
            described_class.new(properties).should be_required
          end
        end

        context 'when required property is false' do
          let(:properties) { {'required' => false} }

          it 'should not be required' do
            described_class.new(properties).should_not be_required
          end
        end

        context 'when required property is not defined' do
          let(:properties) { {} }

          it 'should not be required' do
            described_class.new(properties).should_not be_required
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
json-generator-0.0.1 spec/json/generator/basic_attribute_spec.rb
contracts_api_test-0.0.1 spec/json/generator/basic_attribute_spec.rb