Sha256: 15105404a61ea49ed677221494b636d54a3edc976c381e852bbd725fb0fa878f

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require "#{File.dirname(__FILE__)}/../../test/helpers.rb"
require 'foundations/compact'

describe "Matching Query Parameters" do
    
  before do
    Test = Module.new { include Waves::Foundations::Compact }
    Waves << Test
  end
  
  after do
    Waves.applications.clear
    Object.instance_eval { remove_const(:Test) if const_defined?(:Test) }
  end
    
  feature "Test for a query parameter using true" do 
    Test::Resources::Map.on( :get, true, :query => { :bar => true }) {}
    get("/foo?bar=baz").status.should == 200
    get("/foo").status.should == 404
  end
  
  feature "Test that a query parameter matches a regexp" do 
    Test::Resources::Map.on( :get, true, :query => { :bar => /\d+/ }) {}
    get("/foo?bar=123").status.should == 200
    get("/foo?bar=baz").status.should == 404
  end

  feature "Test that a query parameter matches a string" do 
    Test::Resources::Map.on( :get, true, :query => { :bar => '123' }) {}
    get("/foo?bar=123").status.should == 200
    get("/foo?bar=baz").status.should == 404
  end

  feature "Test that a query parameter satisfies a lambda condition" do 
    Test::Resources::Map.on( :get, true, :query => { :bar => lambda { |x| x == '123' } }) {}
    get("/foo?bar=123").status.should == 200
    get("/foo?bar=baz").status.should == 404
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves-edge-2009.03.10.13.14 test/match/query.rb