Sha256: 8c0aec2b192eff3c5229a3a5a1f203b8b0f14b8b948d9aff692179187eb4e50e

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

IMPLEMENTED = {
  top:            %w{ _api _status _objects _config _runtime},
  output:         %w{ _list _state _full }, # Type of requests as in varaible @output
  hosts:          %w{ archive tv },
  status:         %w{ _services _servicecomments _hostcomments },
  objects:        %w{ timeperiod command contactgroup hostgroup contact host service }
}

#
# Specs for implemetned API endpoints. Only check response: OK or 404.
#

shared_examples_for :fail_on_random_url do |base|
  RANDOM.each do |url|
    ep = "#{base}/#{url}"
    it "fails on '#{ep}' string" do
      get ep
      last_response.status.should be 404
    end
  end
end

shared_examples_for :respond_to_valid_url do |base, urls, custom_regex|

  case urls
    when Array
    urls.each do |url|
      ep = "#{base}/#{url}"
      it "responds to #{ep}" do
        get ep
        last_response.should be_ok
      end
    end
    when nil
      ep = "#{base}"
      it "responds to #{ep}" do
        get ep
        last_response.should be_ok
      end
  end
end

shared_examples_for :fail_on_bad_url do |url|
  before {  get url }
  it "fails on #{url}" do
    last_response.status.should be 404
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nagira-0.5.2 spec/get/get_helper.rb
nagira-0.5.1 spec/get/get_helper.rb
nagira-0.5.0 spec/get/get_helper.rb
nagira-0.4.2 spec/get/get_helper.rb
nagira-0.4.1 spec/get/get_helper.rb