Sha256: ac50c0eeeee31acf707550d3e69a092cbcee9d0411bc528467303198e1367a98

Contents?: true

Size: 1.75 KB

Versions: 10

Compression:

Stored size: 1.75 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Hyperdrive::DSL do
  before do
    hyperdrive do
      name 'Example'
      description 'Example Description'
      vendor 'example'
      media_types %w(json)
      cors({ origins: '*', allow_headers: %w(Accept), test: 'test'})
      resource(:thing) {}
      per_page '0'
      ssl true
      instrumenter Hyperdrive::Instrumenters::Memory.new
    end
  end

  after do
    hyperdrive.send(:reset!)
  end

  it "has a name" do
    hyperdrive.config[:name].must_equal 'Example'
  end

  it "has a description" do
    hyperdrive.config[:description].must_equal 'Example Description'
  end

  it "has a vendor" do
    hyperdrive.config[:vendor].must_equal 'example'
  end

  it "has media types" do
    hyperdrive.config[:media_types].must_equal ['json']
  end

  it "registers a resource" do
    hyperdrive.resources[:thing].must_be_instance_of ::Hyperdrive::Resource
  end

  it "configures cors options" do
    hyperdrive.config[:cors][:allow_headers].must_equal ['Accept']
  end

  it "ensures missing options have default values" do
    hyperdrive.config[:cors][:credentials].must_equal 'false'
  end

  it "removes unsupported cors options" do
    hyperdrive.config[:cors].key?(:test).must_equal false
  end

  it "configures the default per_page option" do
    hyperdrive.config[:per_page].must_equal 20
  end

  it "configures ssl option" do
    hyperdrive.config[:ssl].must_equal true
  end

  it "configures instrumenter option" do
    hyperdrive.config[:instrumenter].must_be_instance_of Hyperdrive::Instrumenters::Memory
  end

  it "can call the instrumenter" do
    hyperdrive.instrument('instrumentation', 'measurement') { |payload| payload + '1' }
    hyperdrive.config[:instrumenter].events.size.must_be :>, 0
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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