Sha256: d7acd7a98f347b1b8941131d661d7c6fafb13153de0e55e8d3bce57ae05e5d92

Contents?: true

Size: 968 Bytes

Versions: 4

Compression:

Stored size: 968 Bytes

Contents

require 'rubygems'
require 'rack/cors'
require 'shoulda'


class DSLTest < Test::Unit::TestCase
  should 'support explicit config object dsl mode' do
    cors = Rack::Cors.new(Proc.new {}) do |cfg|
      cfg.allow do |allow|
        allow.origins 'localhost:3000', '127.0.0.1:3000'
        allow.resource '/get-only', :methods => :get
        allow.resource '/', :headers => :any
      end
    end
    resources = cors.send :all_resources
    assert_equal 1, resources.length
    assert resources.first.allow_origin?('http://localhost:3000')
  end

  should 'support implicit config object dsl mode' do
    cors = Rack::Cors.new(Proc.new {}) do
      allow do
        origins 'localhost:3000', '127.0.0.1:3000'
        resource '/get-only', :methods => :get
        resource '/', :headers => :any
      end
    end
    resources = cors.send :all_resources
    assert_equal 1, resources.length
    assert resources.first.allow_origin?('http://localhost:3000')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rack-cors-0.2.7 test/unit/dsl_test.rb
rack-cors-0.2.6 test/unit/dsl_test.rb
rack-cors-0.2.5 test/dsl_test.rb
rack-cors-0.2.4 test/dsl_test.rb