2011-11-22 2 views
0

rails3 어플리케이션에서 단위 테스트를 구현하려고합니다. 다음은 내 'test_helper.rb'파일입니다. 내 고정 파일 다음레일 3의 단위 테스트 오류

ENV["RAILS_ENV"] = "test" 
require File.expand_path('../../config/environment', __FILE__) 
require 'rails/test_help' 

class ActiveSupport::TestCase 
    include Devise::TestHelpers 
    fixtures :all 
end 

(site_layouts.yml)

# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 

one: 
    name: layout1 
    content: <html><head></head><body>layout1</body></html> 

two: 
    name: layout2 
    content: <html><head></head><body>layout2</body></html> 

및 다음 내 단위 테스트 클래스

require 'test_helper' 

class SiteLayoutTest < Test::Unit::TestCase 
    fixtures :site_layouts 
    test "show site layout" do 
    layout = site_layouts(:one) 
    end 
end 

와 나는 rake test:units을 실행하려고 할 때 다음과 같은 오류를 얻고있다

undefined method `fixtures' for SiteLayoutTest:Class (NoMethodError) 

나는 약간 새로운 테스트를합니다. 난

  • 레일 3.0.0
  • 리눅스
  • 시험 단위 (2.4.1, 2.4.0, 2.3.2, 1.2.3)
  • (시험 단위에 통지에 0.3.0)

답변

1

내 생각에 fixtures :site_layoutsSiteLayoutTest으로 전화하지 않아도된다고 생각합니다. 레일은 당신의 조명기들을 자동으로로드해야합니다.

Rails Guides의 조명에 대해 자세히 알아보십시오.

+0

감사합니다. ream88, 맞습니다. – sameera207

1

test_helper.rb에서 생성 한 ActiveSupport :: TestCase에서 파생해야합니까? 장비를 자동으로 불러 와야합니다.

require 'test_helper' 

class SiteLayoutTest < ActiveSupport::TestCase 
    test "show site layout" do 
    layout = site_layouts(:one) 
    end 
end 
관련 문제