Sha256: 2b86ae4544566b71bec7ff27186a641ee0ee63fa3fbf518ac302d140a4c8f9df

Contents?: true

Size: 1.38 KB

Versions: 11

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe OpenIDConnect::ResponseObject do
  class OpenIDConnect::ResponseObject::SubClass < OpenIDConnect::ResponseObject
    attr_required :required
    attr_optional :optional
  end

  let(:klass) { OpenIDConnect::ResponseObject::SubClass }
  subject { klass.new attributes }

  context 'when required attributes are given' do
    context 'when optional attributes are given' do
      let :attributes do
        {:required => 'Required', :optional => 'Optional'}
      end
      its(:required) { should == 'Required' }
      its(:optional) { should == 'Optional' }
    end

    context 'otherwise' do
      let :attributes do
        {:required => 'Required'}
      end
      its(:required) { should == 'Required' }
      its(:optional) { should == nil }
    end
  end

  context 'otherwise' do
    context 'when optional attributes are given' do
      let :attributes do
        {:optional => 'Optional'}
      end
      it do
        expect { klass.new attributes }.should raise_error AttrRequired::AttrMissing
      end
    end

    context 'otherwise' do
      it do
        expect { klass.new }.should raise_error AttrRequired::AttrMissing
      end
    end
  end

  describe '#as_json' do
    let :attributes do
      {:required => 'Required', :optional => 'Optional'}
    end
    its(:as_json) do
      should == {:required => 'Required', :optional => 'Optional'}
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
openid_connect-0.0.11 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.10 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.9 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.8 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.7 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.6 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.5 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.4 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.3 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.2 spec/openid_connect/response_object_spec.rb
openid_connect-0.0.1 spec/openid_connect/response_object_spec.rb