public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
commit  c7c69e8f6a0bce3a1a4ccce13d334fafd6e24685
tree    6d638e77478822ec3e7f34eb71b5e05d6ffaf6ed
parent  cf690d2521cdfa1d549bbf9ac8d051ed3c2f9140
merb-core / spec / private / router / behavior_spec.rb
100644 44 lines (34 sloc) 0.933 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require File.dirname(__FILE__) + '/../../spec_helper'
require 'ostruct'
require 'rack/mock'
require 'stringio'
Merb.start :environment => 'test',
           :merb_root => File.dirname(__FILE__) / 'fixture'
 
 
class SimpleRequest < OpenStruct
  def method
    @table[:method]
  end
 
  def params
    @table
  end
end
 
def match_for(path, args = {}, protocol = "http://")
  Merb::Router.match(SimpleRequest.new({:protocol => protocol, :path => path}.merge(args)))
end
 
def matched_route_for(*args)
  # get route index
  idx = match_for(*args)[0]
 
  Merb::Router.routes[idx]
end
 
describe Merb::Router::Behavior, "#redirect" do
  predicate_matchers[:redirect] = :redirects?
 
  before :each do
    Merb::Router.prepare do |r|
      r.match('/old/location').redirect("/new/location", true)
    end
  end
 
  it "makes route redirecting" do
    @behavior = matched_route_for("/old/location").behavior
    @behavior.should redirect
  end
end