Sha256: 759589dfe9802dfc0619b910cd776bb2fd31f06c1fa0c94da7f26d70772e31cc

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# -*- encoding: utf-8 -*-
require 'spec_helper'

module Happy
  module Helpers
    describe Html do
      include Html

      describe "#url_for" do
        it "generates a url from an array of strings" do
          url_for('foo', 'bar', '123').should == '/foo/bar/123'
        end

        it "removes duplicate dashes" do
          url_for('/foo/', 'bar').should == '/foo/bar'
        end

        it "removes leading dashes" do
          url_for('foo/').should == '/foo'
        end

        it "returns just a slash if no parameters are given" do
          url_for().should == '/'
        end

        it "doesn't take nil into account" do
          url_for('foo', nil, 'bar').should == '/foo/bar'
        end

        it "also accepts symbols" do
          url_for(:foo, 'bar').should == '/foo/bar'
        end

        it "generates RESTful URLs from objects" do
          url_for(mock(:class => 'thingy', :to_param => '1')).should == '/thingies/1'
        end

        it "is can be cascaded" do
          url_for(url_for(:foo, :bar), '123', url_for('woop')).should == '/foo/bar/123/woop'
        end

        it "doesn't modify strings containing complete URLs" do
          url_for('http://www.test.com').should == 'http://www.test.com'
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
happy-0.1.0 spec/helpers/html_spec.rb
happy-0.1.0.pre28 spec/helpers/html_spec.rb
happy-0.1.0.pre27 spec/helpers/html_spec.rb