Sha256: 4fd1ac10dd382faa72e0c8d9d503e7dde351033fe93e41c88b51bb4d650cf85d

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Praxis::Trait do

  subject(:trait) do
    Praxis::Trait.new do
      description 'my awesome trait'

      routing do
        prefix '/:app_name'
      end

      response :something
      response :nothing

      params do
        attribute :app_name, String
        attribute :order, String,
          description: "Field to sort by."
      end

      headers do
        header "Authorization"
        key "Header2", String, required: true
      end

    end
  end

  context 'describe' do
    subject(:describe) { trait.describe }

    its([:description]) { should eq('my awesome trait') }

    its([:responses, :something]) { should eq Hash.new }
    its([:responses, :nothing]) { should eq Hash.new }

    its([:params, :app_name, :type, :name]) { should eq 'String' }
    its([:params, :order, :type, :name]) { should eq 'String' }
    its([:routing, :prefix]) { should eq '/:app_name'}

    its([:headers, "Header2"]) { should include({required: true}) }
    context 'using the special DSL syntax for headers' do
      subject(:dsl_header) { describe[:headers]["Authorization"] }
      its([:required]){ should be(true) }
      its([:type]){ should eq( { :id=>"Attributor-String", :name=>"String", :family=>"string"} )}
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
praxis-0.20.1 spec/praxis/trait_spec.rb
praxis-0.20.0 spec/praxis/trait_spec.rb
praxis-0.19.0 spec/praxis/trait_spec.rb
praxis-0.18.1 spec/praxis/trait_spec.rb
praxis-0.18.0 spec/praxis/trait_spec.rb
praxis-0.17.1 spec/praxis/trait_spec.rb
praxis-0.17.0 spec/praxis/trait_spec.rb
praxis-0.16.1 spec/praxis/trait_spec.rb