Sha256: c05af0a48be440b9ca0d8080af33db22a5fe0cf9985f3cf06af7a7ddc6b3083f

Contents?: true

Size: 1.48 KB

Versions: 35

Compression:

Stored size: 1.48 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)
      expect(resource.to_json[:metadata]).to eq(nil)
    end

    it "should return the metadata" do
      meta = {
        :lenght => 32,
        :weight => '830g'
      }
      resource = Apipie::ResourceDescription.new(ApplicationController, "dummy", dsl_data.update(:meta => meta))
      expect(resource.to_json[:metadata]).to eq(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
      expect(@resource._methods.keys).to eq([:a, :b, :c])
      expect(@resource.to_json[:methods].map{|h| h[:name]}).to eq(['a', 'b', 'c'])
    end

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

  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
apipie-rails-0.9.2 spec/lib/resource_description_spec.rb
apipie-rails-0.9.1 spec/lib/resource_description_spec.rb
apipie-rails-0.9.0 spec/lib/resource_description_spec.rb
apipie-rails-0.8.2 spec/lib/resource_description_spec.rb
apipie-rails-0.8.1 spec/lib/resource_description_spec.rb
apipie-rails-0.8.0 spec/lib/resource_description_spec.rb
apipie-rails-0.7.2 spec/lib/resource_description_spec.rb
apipie-rails-0.7.1 spec/lib/resource_description_spec.rb
apipie-rails-0.7.0 spec/lib/resource_description_spec.rb
apipie-rails-0.6.0 spec/lib/resource_description_spec.rb
apipie-rails-0.5.20 spec/lib/resource_description_spec.rb
apipie-rails-0.5.19 spec/lib/resource_description_spec.rb
apipie-rails-0.5.18 spec/lib/resource_description_spec.rb
apipie-rails-0.5.17 spec/lib/resource_description_spec.rb
apipie-rails-0.5.16 spec/lib/resource_description_spec.rb
apipierails3-0.0.1 spec/lib/resource_description_spec.rb
apipie-rails-0.5.15 spec/lib/resource_description_spec.rb
apipie-rails-0.5.14 spec/lib/resource_description_spec.rb
apipie-rails-0.5.13 spec/lib/resource_description_spec.rb
apipie-rails-0.5.12 spec/lib/resource_description_spec.rb