Sha256: 535ae5b7f16d033271c293548cadc3b3a9219461b37b86e116ac4008148d22c2
Contents?: true
Size: 1.24 KB
Versions: 10
Compression:
Stored size: 1.24 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Hyperdrive::DSL::Resource do before do hyperdrive do resource(:thing) do name 'Thing Resource' description 'Thing Description' param :name, 'Thing Name' filter :parent_id, "Parent ID" request(:get) do 'ok' end end end end after do hyperdrive.send(:reset!) end it "sets the name of the resource" do hyperdrive.resources[:thing].name.must_equal 'Thing Resource' end it "sets the description of the resource" do hyperdrive.resources[:thing].description.must_equal 'Thing Description' end it "registers a param for the resource" do hyperdrive.resources[:thing].params[:name].description.must_equal "Thing Name" end it "registers a filter for the resource" do hyperdrive.resources[:thing].filters[:parent_id].description.must_equal "Parent ID" end it "defines how requests are handled" do hyperdrive.resources[:thing].request_handlers[:get]['v1'].must_be :===, Proc end it "throws an error if request method is unknown" do bad_resource = -> { hyperdrive { resource(:thing) { request(:verb) } } } bad_resource.must_raise Hyperdrive::Errors::DSL::UnknownArgument end end
Version data entries
10 entries across 10 versions & 1 rubygems