Sha256: eebad09303c4783c647c8319855b066d7a92535eb0b07e0f058bd8ce330b7ecb

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

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

describe ActsAsApi::Base do

  describe "renaming", :orm => :active_record do

    before(:each) do
      setup_models
    end

    after(:each) do
      clean_up
    end

    describe "an attribute in the api template" do

      before(:each) do
        @response = @luke.as_api_response(:rename_last_name)
      end

      it "returns a hash" do
        @response.should be_kind_of(Hash)
      end

      it "returns the correct number of fields" do
        @response.should have(1).key
      end

      it "returns all specified fields" do
        @response.keys.should include(:family_name)
      end

      it "returns the correct values for the specified fields" do
        @response.values.should include(@luke.last_name)
      end

    end

    describe "the node/key of a method in the api template" do

      before(:each) do
        @response = @luke.as_api_response(:rename_full_name)
      end

      it "returns a hash" do
        @response.should be_kind_of(Hash)
      end

      it "returns the correct number of fields" do
        @response.should have(1).key
      end

      it "returns all specified fields" do
        @response.keys.should include(:other_full_name)
      end

      it "returns the correct values for the specified fields" do
        @response.values.should include(@luke.full_name)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_api-0.3.5 spec/models/base/renaming_spec.rb
acts_as_api-0.3.4 spec/models/base/renaming_spec.rb
acts_as_api-0.3.3 spec/models/base/renaming_spec.rb