Sha256: 93f2983fd3ef5f383ac0e05329320c8a2c641ff4cd679888a209fefe878b8d7f

Contents?: true

Size: 1.25 KB

Versions: 12

Compression:

Stored size: 1.25 KB

Contents

shared_examples_for "calling a closure in the api template" do

  describe "i.e. a proc (the record is passed as only parameter)" do

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

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

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

    it "returns all specified fields" do
      @response.keys.sort_by(&:to_s).should eql([:all_caps_name, :without_param])
    end

    it "returns the correct values for the specified fields" do
      @response.values.sort.should eql(["LUKE SKYWALKER", "Time"])
    end
  end

  describe "i.e. a lambda (the record is passed as only parameter)" do

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

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

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

    it "returns all specified fields" do
      @response.keys.sort_by(&:to_s).should eql([:all_caps_name, :without_param])
    end

    it "returns the correct values for the specified fields" do
      @response.values.sort.should eql(["LUKE SKYWALKER", "Time"])
    end

  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
acts_as_api-0.4.4 spec/support/model_examples/closures.rb
acts_as_api-0.4.3 spec/support/model_examples/closures.rb
acts_as_api_sequel-0.0.1 spec/support/model_examples/closures.rb
acts_as_api-0.4.2 spec/support/model_examples/closures.rb
acts_as_api-0.4.1 spec/support/model_examples/closures.rb
acts_as_api-0.4 spec/support/model_examples/closures.rb
acts_as_api-0.3.11 spec/support/model_examples/closures.rb
acts_as_api-0.3.10 spec/support/model_examples/closures.rb
acts_as_api-0.3.9 spec/support/model_examples/closures.rb
acts_as_api-0.3.8 spec/support/model_examples/closures.rb
acts_as_api-0.3.7 spec/support/model_examples/closures.rb
acts_as_api-0.3.6 spec/support/model_examples/closures.rb