开发者

Rails | How to create a non-ASCII spec?

开发者 https://www.devze.com 2023-03-28 10:52 出处:网络
The code welcomes_spec.rb: ... describe \"GET /welcomes\" do it \"Should render main page\" do visit root_path

The code

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

...开发者_Go百科
ru:
  hello: "Hello world"
  default_page_title: "Test_page_title"
  main_page: "Главная"
  popular_photos:  !NON ASCII SYMBOLS HERE!

after $rake spec leads the error:

Failure/Error: page.should have_content(t("popular_photos"))
NoMethodError:
  undefined method `t' for #<RSpec::Core::ExampleGroup::Nested_5::Nested_1:0xba77028>

I am newbie and don't know how to fix it.


Simply replace:

page.should have_content(t("popular_photos"))

with:

page.should have_content(I18n.translate("popular_photos"))
0

精彩评论

暂无评论...
验证码 换一张
取 消