Sha256: 24d7356e5ac1efa19a6d883c87b6a6ce87c0c7c2fe5a2b7b2ee18027c3c91af8

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Hyperdrive::DSL::Resource do

  it "sets the name of the endpoint" do
    hyperdrive do
      resource(:thing) do
        name "Thing Resource"
      end
    end.resources[:thing].name.must_equal 'Thing Resource'
  end

  it "describes the endpoint" do
    hyperdrive do
      resource(:thing) do
        desc "Thing Description"
      end
    end.resources[:thing].desc.must_equal 'Thing Description'
  end

  it "registers an allowed param on a resource" do
    hyperdrive do
      resource(:thing) do
        param :name, "Thing's Name"
      end
    end.resources[:thing].allowed_params[:name][:desc].must_equal "Thing's Name"
  end

  it "registers an allowed param on a resource" do
    hyperdrive do
      resource(:thing) do
        filter :parent_id, "Thing's Parent ID"
      end
    end.resources[:thing].filters[:parent_id][:desc].must_equal "Thing's Parent ID"
  end

  it "defines how requests are handled" do
    hyperdrive do
      resource(:thing) do
        request(:get) do
          'ok'
        end
      end
    end.resources[:thing].request_handlers[:get].call.must_equal 'ok'
  end

  it "raises an exception if request method argument is unknown" do
    proc do
      hyperdrive do
        resource(:thing) do
          request(:verb)
        end
      end
    end.must_raise Hyperdrive::Errors::DSL::UnknownArgument
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyperdrive-0.0.5 spec/hyperdrive/dsl/resource_spec.rb
hyperdrive-0.0.4 spec/hyperdrive/dsl/resource_spec.rb