Sha256: 6aec583afb29014ea268c2d7205a5af4d53f9576cd11e3b7c00d3c1ad3cd1fcc

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Isomer::Parameter do
  describe '#default' do
    it 'is set from the initializer' do
      parameter = Isomer::Parameter.new(:foo, {default: 'my default'})
      parameter.default.should == 'my default'
    end
  end

  describe '#name' do
    context 'when there is no from option' do
      it 'returns the id as a string' do
        parameter = Isomer::Parameter.new(:foo, {})
        parameter.name.should == 'foo'
      end
    end

    context 'when there is a from option' do
      it 'returns the from value as a string' do
        parameter = Isomer::Parameter.new(:bar, {name: :baz})
        parameter.name.should == 'baz'
      end
    end
  end

  describe '#required?' do
    it 'returns true when required is set to true' do
      parameter = Isomer::Parameter.new(anything, {required: true})
      parameter.required?.should == true
    end

    it 'returns false when required is set to anything other than true' do
      parameter = Isomer::Parameter.new(anything, {required: 'blarg'})
      parameter.required?.should == false
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
isomer-0.1.4 spec/isomer/parameter_spec.rb
isomer-0.1.3 spec/isomer/parameter_spec.rb
isomer-0.1.2 spec/isomer/parameter_spec.rb
isomer-0.1.1 spec/isomer/parameter_spec.rb
isomer-0.1.0 spec/isomer/parameter_spec.rb