Sha256: 644e3cd84601a0e4f1f23714a4d96bbbaca0c64f3158e24aa02e515e35f30da0

Contents?: true

Size: 1.45 KB

Versions: 17

Compression:

Stored size: 1.45 KB

Contents

require "spec_helper"

describe Apipie::ResourceDescription do

  let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }

  describe "metadata" do

    it "should return nil when no metadata is provided" do
      resource = Apipie::ResourceDescription.new(ApplicationController, "dummy", dsl_data)
      resource.to_json[:metadata].should == nil
    end

    it "should return the metadata" do
      meta = {
        :lenght => 32,
        :weight => '830g'
      }
      resource = Apipie::ResourceDescription.new(ApplicationController, "dummy", dsl_data.update(:meta => meta))
      resource.to_json[:metadata].should == meta
    end

  end

  describe "methods descriptions" do

    before(:each) do
      @resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
      a = Apipie::MethodDescription.new(:a, @resource, dsl_data)
      b = Apipie::MethodDescription.new(:b, @resource, dsl_data)
      c = Apipie::MethodDescription.new(:c, @resource, dsl_data)
      @resource.add_method_description(a)
      @resource.add_method_description(b)
      @resource.add_method_description(c)
    end

    it "should be ordered" do
      @resource._methods.keys.should == [:a, :b, :c]
      @resource.to_json[:methods].map{|h| h[:name]}.should == ['a', 'b', 'c']
    end

    it "should be still ordered" do
      @resource._methods.keys.should == [:a, :b, :c]
      @resource.to_json[:methods].map{|h| h[:name]}.should == ['a', 'b', 'c']
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
apipie-rails-0.3.5 spec/lib/resource_description_spec.rb
apipie-rails-0.3.4 spec/lib/resource_description_spec.rb
apipie-rails-0.3.3 spec/lib/resource_description_spec.rb
apipie-rails-0.3.2 spec/lib/resource_description_spec.rb
apipie-rails-0.3.1 spec/lib/resource_description_spec.rb
apipie-rails-0.3.0 spec/lib/resource_description_spec.rb
apipie-rails-0.2.6 spec/lib/resource_description_spec.rb
apipie-rails-0.2.5 spec/lib/resource_description_spec.rb
apipie-rails-0.2.4 spec/lib/resource_description_spec.rb
apipie-rails-0.2.3 spec/lib/resource_description_spec.rb
apipie-rails-0.2.2 spec/lib/resource_description_spec.rb
apipie-rails-0.2.1 spec/lib/resource_description_spec.rb
apipie-rails-0.2.0 spec/lib/resource_description_spec.rb
apipie-rails-0.1.3 spec/lib/resource_description_spec.rb
apipie-rails-0.1.2 spec/lib/resource_description_spec.rb
apipie-rails-0.1.1 spec/lib/resource_description_spec.rb
apipie-rails-0.1.0 spec/lib/resource_description_spec.rb