Sha256: 82f20937ece4f8086a0428fa7b8cac8d0a6d3648269ad60dd57a6ead7f82ba87
Contents?: true
Size: 1.67 KB
Versions: 20
Compression:
Stored size: 1.67 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 # Double params to test "additive behavior" params do attribute :app_name, String end params do 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 context 'apply!' do let(:target) { double("Target") } it 'does' do expect(target).to receive(:routing).once expect(target).to receive(:response).twice expect(target).to receive(:params).twice expect(target).to receive(:headers).once subject.apply!(target) end end end
Version data entries
20 entries across 20 versions & 1 rubygems