view_picking_test.rb

来自「A Hotel Management System based on Ruby 」· RB 代码 · 共 50 行

RB
50
字号
require File.dirname(__FILE__) + '/test_helper'

class ViewPickingTest < Test::Unit::TestCase
  include Globalize
  fixtures :globalize_languages, :globalize_countries

  class TestController < ActionView::Base
  end

  def setup
    Locale.set("en-US")
    @base_path = File.dirname(__FILE__) + '/views'
  end

  def test_first
    tc = TestController.new
    tc.base_path = @base_path
    assert_match /English/, tc.render("test")
    assert_no_match /Hebrew/, tc.render("test")
    Locale.set("he-IL")
    assert_match /Hebrew/, tc.render("test")
    assert_no_match /English/, tc.render("test")
  end

  def test_non_full_path
    tc = TestController.new
    tc.base_path = @base_path
    assert_match /English/, tc.render_file("#{@base_path}/test.rhtml", false)
  end

  def test_nil
    Locale.set(nil)
    tc = TestController.new
    tc.base_path = @base_path
    assert_match /English/, tc.render("test")
    assert_no_match /Hebrew/, tc.render("test")
    Locale.set("he-IL")
    assert_match /Hebrew/, tc.render("test")
    assert_no_match /English/, tc.render("test")
  end

  def test_non_full_path_nil
    Locale.set(nil)
    tc = TestController.new
    tc.base_path = @base_path
    assert_match /English/, tc.render_file("#{@base_path}/test.rhtml", false)
  end

end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?