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
Search Repo:
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
add first specs

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@3051 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Fri Nov 23 18:06:05 -0800 2007
commit  fa95f30d1e74cc5af558fe9767e6fe133730e343
tree    9dc8e414698939a96529390e68697ee5f72670c5
parent  989dbfc3b82caa64f0d92ce39707a0a646e689d6
...
12
13
14
 
15
16
 
 
17
18
19
...
12
13
14
15
16
 
17
18
19
20
21
0
@@ -12,8 +12,10 @@
0
 
0
       def absolute_url(*path)
0
         return "#{relative_url_root}/" if path.empty?
0
+ is_absolute = path.first.to_s[/(^\/)/]
0
         path.collect! { |p| p.to_s.gsub /(^\/)|(\/$)/, '' }
0
- path.empty? ? "#{relative_url_root}/" : path.unshift(relative_url_root).join('/')
0
+ path.unshift(is_absolute ? '' : relative_url_root)
0
+ path * '/'
0
       end
0
     end
0
   end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -1 +1,58 @@
0
+require File.dirname(__FILE__) + '/../spec_helper'
0
+
0
+describe Mephisto::Liquid::UrlMethods, "#absolute_url" do
0
+ it "has root absolute url" do
0
+ absolute_url.should == '/'
0
+ end
0
+
0
+ it "joins url pieces" do
0
+ absolute_url(:foo).should == '/foo'
0
+ absolute_url(:foo, :bar).should == '/foo/bar'
0
+ absolute_url(:foo, :bar, 'baz.html').should == '/foo/bar/baz.html'
0
+ end
0
+
0
+ it "joins relative path" do
0
+ absolute_url('foo/bar/baz.html').should == '/foo/bar/baz.html'
0
+ end
0
+
0
+ it "joins absolute path" do
0
+ absolute_url('/foo/bar/baz.html').should == '/foo/bar/baz.html'
0
+ end
0
+
0
+ it "joins path ending with a slash" do
0
+ absolute_url('foo/bar/baz/').should == '/foo/bar/baz'
0
+ end
0
+end
0
+
0
+describe Mephisto::Liquid::UrlMethods, "#absolute_url (with custom url root)" do
0
+ class << self
0
+ attr_accessor :relative_url_root
0
+ end
0
+
0
+ before do
0
+ stub!(:relative_url_root).and_return("/blog")
0
+ end
0
+
0
+ it "has root absolute url" do
0
+ absolute_url.should == '/blog/'
0
+ end
0
+
0
+ it "joins url pieces" do
0
+ absolute_url(:foo).should == '/blog/foo'
0
+ absolute_url(:foo, :bar).should == '/blog/foo/bar'
0
+ absolute_url(:foo, :bar, 'baz.html').should == '/blog/foo/bar/baz.html'
0
+ end
0
+
0
+ it "joins relative path" do
0
+ absolute_url('foo/bar/baz.html').should == '/blog/foo/bar/baz.html'
0
+ end
0
+
0
+ it "joins absolute path" do
0
+ absolute_url('/foo/bar/baz.html').should == '/foo/bar/baz.html'
0
+ end
0
+
0
+ it "joins path ending with a slash" do
0
+ absolute_url('foo/bar/baz/').should == '/blog/foo/bar/baz'
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
0
@@ -1 +1,9 @@
0
+ModelStubbing.define_models do
0
+ # only put minimal, core models in here if specs require interaction
0
+ # with lots of models
0
+
0
+ # model Article do
0
+ # stub :title => 'foobar'
0
+ # end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1 +1,15 @@
0
+ENV["RAILS_ENV"] = "test"
0
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
0
+require 'spec'
0
+require 'spec/rails'
0
+require 'ruby-debug'
0
+require 'model_stubbing/spec'
0
+require File.join(File.dirname(__FILE__), 'model_stubs')
0
+
0
+Spec::Runner.configure do |config|
0
+ config.use_transactional_fixtures = true
0
+ config.use_instantiated_fixtures = false
0
+end
0
+
0
+Debugger.start
...
22
23
24
25
 
26
27
28
29
...
49
50
51
52
 
53
54
55
56
 
57
58
...
22
23
24
 
25
26
27
28
29
...
49
50
51
 
52
53
54
55
 
56
57
58
0
@@ -22,7 +22,7 @@
0
   end
0
   
0
   specify "should join path ending with a slash" do
0
- assert_equal '/foo/bar/baz', absolute_url('/foo/bar/baz/')
0
+ assert_equal '/foo/bar/baz', absolute_url('foo/bar/baz/')
0
   end
0
 end
0
 
0
0
@@ -49,11 +49,11 @@
0
   end
0
   
0
   specify "should join absolute path" do
0
- assert_equal '/blog/foo/bar/baz.html', absolute_url('/foo/bar/baz.html')
0
+ assert_equal '//foo/bar/baz.html', absolute_url('/foo/bar/baz.html')
0
   end
0
   
0
   specify "should join path ending with a slash" do
0
- assert_equal '/blog/foo/bar/baz', absolute_url('/foo/bar/baz/')
0
+ assert_equal '/blog/foo/bar/baz', absolute_url('foo/bar/baz/')
0
   end
0
 end

Comments

    No one has commented yet.