public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
James Smith (author)
Thu May 08 10:50:32 -0700 2008
commit  0ca6f9a34bc9e23cd1f882426d29b887a59b6be9
tree    081d3688967b32533a3e020a7025f8b4ee44e096
parent  9072b487bf45c5e41e33c66b32d94aea84732d1b
mephisto / spec / filters / absolute_url_spec.rb
100644 57 lines (45 sloc) 1.596 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
45
46
47
48
49
50
51
52
53
54
55
56
57
require File.dirname(__FILE__) + '/../spec_helper'
 
describe Mephisto::Liquid::UrlMethods, "#absolute_url" do
  it "has root absolute url" do
    absolute_url.should == '/'
  end
  
  it "joins url pieces" do
    absolute_url(:foo).should == '/foo'
    absolute_url(:foo, :bar).should == '/foo/bar'
    absolute_url(:foo, :bar, 'baz.html').should == '/foo/bar/baz.html'
  end
  
  it "joins relative path" do
    absolute_url('foo/bar/baz.html').should == '/foo/bar/baz.html'
  end
  
  it "joins absolute path" do
    absolute_url('/foo/bar/baz.html').should == '/foo/bar/baz.html'
  end
  
  it "joins path ending with a slash" do
    absolute_url('foo/bar/baz/').should == '/foo/bar/baz'
  end
end
 
describe Mephisto::Liquid::UrlMethods, "#absolute_url (with custom url root)" do
  class << self
    attr_accessor :relative_url_root
  end
  
  before do
    stub!(:relative_url_root).and_return("/blog")
  end
 
  it "has root absolute url" do
    absolute_url.should == '/blog/'
  end
  
  it "joins url pieces" do
    absolute_url(:foo).should == '/blog/foo'
    absolute_url(:foo, :bar).should == '/blog/foo/bar'
    absolute_url(:foo, :bar, 'baz.html').should == '/blog/foo/bar/baz.html'
  end
  
  it "joins relative path" do
    absolute_url('foo/bar/baz.html').should == '/blog/foo/bar/baz.html'
  end
  
  it "joins absolute path" do
    absolute_url('/foo/bar/baz.html').should == '/foo/bar/baz.html'
  end
  
  it "joins path ending with a slash" do
    absolute_url('foo/bar/baz/').should == '/blog/foo/bar/baz'
  end
end