Giter VIP home page Giter VIP logo

Comments (3)

pwim avatar pwim commented on June 26, 2024

I've been struggling with this one too.

from routing-filter.

svenfuchs avatar svenfuchs commented on June 26, 2024

I see. I usually don't test routes separately.

Can you guys please provide a test case for the routing-filter test suite?

from routing-filter.

mjonuschat avatar mjonuschat commented on June 26, 2024

Here is an example on how to test with Rspec 2.x:

require "spec_helper"

describe WelcomeController do
  before(:all) { RoutingFilter.active = true }
  after(:all) { RoutingFilter.active = false }
  describe "routing" do

    it "recognizes and generates #index" do
      { :get => '/' }.should route_to(:controller => "welcome", :action => "index")
      { :get => root_path }.should route_to(:controller => "welcome", :action => "index")
    end

    it "recognizes and generates #index for german (default) locale" do
      { :get => "/de" }.should route_to(:controller => "welcome", :action => "index", :locale => 'de')
    end

    it "it doesn't add the default locale to the generated root path" do
      { :get => root_path(:locale => :de) }.should route_to(:controller => "welcome", :action => "index")
    end

    it "recognizes and generates #index for english locale" do
      { :get => "/en" }.should route_to(:controller => "welcome", :action => "index", :locale => 'en')
      { :get => root_path(:locale => :en) }.should route_to(:controller => "welcome", :action => "index", :locale => 'en')
    end

  end
end

It should easily work with Test::Unit as well, closing.

from routing-filter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.