代码
welcomes_spec.rb :
...
describe "GET /welcomes" do
it "Should render main page" do
visit root_path
page.should have_content(t("popular_photos"))
end
end
...
ru.yml
...
ru:
hello: "Hello world"
default_page_title: "Test_page_title"
main_page: "Главная"
popular_photos: !NON ASCII SYMBOLS HERE!
$rake spec
导致错误后:
Failure/Error: page.should have_content(t("popular_photos"))
NoMethodError:
undefined method `t' for #<RSpec::Core::ExampleGroup::Nested_5::Nested_1:0xba77028>
我是新手,不知道如何解决它。
答案 0 :(得分:2)
简单地替换:
page.should have_content(t("popular_photos"))
使用:
page.should have_content(I18n.translate("popular_photos"))