Sha256: 6b96d2a4b4dcaaed4bed78afa9bb981184481e613aed5add403234aee333c077

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Hyperdrive::Param do
  before do
    @param = default_param
  end

  it "has a name" do
    @param.name.must_equal 'id'
  end

  it "has a description" do
    @param.description.must_equal 'Identifier'
  end

  it "returns an array of HTTP methods it's required for" do
    @param.required.must_equal %w(PUT PATCH DELETE)
  end

 it "returns an array if only a single HTTP method is required" do
    Hyperdrive::Filter.new(:param, '', required: 'GET').required.must_equal ['GET']
  end

  it "returns true if the param is required for the given HTTP method" do
    @param.required?('PUT').must_equal true
  end

  it "returns false if the param is not required for the given HTTP method" do
    @param.required?('POST').must_equal false
  end

  it "converts itself to a hash" do
    constraints = { name: 'id', description: 'Identifier', type: 'String', constraints: 'Required for: PUT, PATCH, DELETE. Must be a valid BSON Object ID.' }
    @param.to_hash.must_equal constraints
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hyperdrive-0.0.25 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.24 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.23 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.22 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.21 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.20 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.19 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.18 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.17 spec/hyperdrive/param_spec.rb
hyperdrive-0.0.16 spec/hyperdrive/param_spec.rb