Sha256: 334bb4f3a184582d1fd25ff816f7b5644781a5ab9de2fa57021dc13ec35c758f

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

require 'spec_helper'

#
# Test resonse to /_api GET
#
describe Nagira do

  set :environment, ENV['RACK_ENV'] || :test

  include Rack::Test::Methods

  def app
    @app ||= Nagira
  end



  context "API data" do
    before :all do
      get "/_api.json"
      @data = JSON.parse last_response.body
    end

    it "should be array" do
      expect(@data).to be_a_kind_of Hash
    end

    METHODS = %w{ GET PUT POST DELETE}

    context "routes" do

      METHODS.each do |method|

        context method do
          it "routes should be an Array" do
            expect(@data[method]).to be_a_kind_of Array if @data[method]
          end

          it "should star with slash" do
            if @data[method]
              @data[method].each do |path|
                expect(path).to match( /^\//)
              end
            end
          end

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nagira-0.4.0 spec/01_data_format/03_api_spec.rb