Sha256: 94e5ab8e742491d3295ef7c4f3340150cb259058bcc62aca2e0ec14a4b5a6eec

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

#          Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the MIT license.

require File.expand_path('../../../../spec/helper', __FILE__)

describe 'Controller::generate_mapping' do
  def gen(klass)
    Ramaze::Controller::generate_mapping(klass)
  end

  it 'maps ::ClassController to /class' do
    gen('ClassController').should == '/class'
  end

  it 'maps ::CamelCaseController to /camel_case' do
    gen('CamelCaseController').should == '/camel_case'
  end

  it 'maps Module::ClassController to /module/class' do
    gen('Module::ClassController').should == '/module/class'
  end

  it 'maps Class to /class' do
    gen('Class').should == '/class'
  end

  it 'maps Module::Class to /module/class' do
    gen('Module::Class').should == '/module/class'
  end

  it 'maps Module::Module::Class to module/module/class' do
    gen('Module::Module::Class').should == '/module/module/class'
  end

  it "maps MainController to '/'" do
    gen('MainController').should == '/'
  end

  it "doesn't map ::Controller" do
    gen('Controller').should == nil
  end

  it "doesn't map anonymous classes" do
    gen(Class.new.name).should == nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-2012.04.14 spec/ramaze/controller/mapping.rb
ramaze-2012.03.07 spec/ramaze/controller/mapping.rb