저는 오이/BDD에 상당히 익숙하지 않습니다. 나는 페이지 내용의 간단한 테스트를하려하지만 내 테스트 스위트는 페이지 머리글 만 "찾을 수있다".오이 테스트는 전체 페이지를 렌더링 할 수 없습니다. 헤더 만
예를 들어:
Scenario: User sees the menu page
Given a menu exists
When I visit the menu
Then I should see "menu" page title
And I should see "tuna poke" item name
단계 정의 :
Feature: View Menu
In order see the menu
I want to view the menu
I want to see item name
I want to see item description
I want to see item price
Scenario: User sees the menu page # features/view_menu.feature:8
Given a menu exists # features/step_definitions/view_menu_steps.rb:1
When I visit the menu # features/step_definitions/view_menu_steps.rb:9
Then I should see "menu" page title # features/step_definitions/view_menu_steps.rb:13
And I should see "tuna poke" item name # features/step_definitions/view_menu_steps.rb:17
expected to find text "tuna poke" in "menu sign in" (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/view_menu_steps.rb:18:in `"I should see {string} item name"'
features/view_menu.feature:12:in `And I should see "tuna poke" item name'
Failing Scenarios:
cucumber features/view_menu.feature:8 # Scenario: User sees the menu page
1 scenario (1 failed)
4 steps (1 failed, 3 passed)
0m1.180s
내가 가장 독특한 찾는 것은 오류의 일부입니다 :
Given("a menu exists") do
user = User.create!(email: "[email protected]", password: "hello")
restaurant = Restaurant.create!(name: "eleven tables", user_id: user.id)
menu = Menu.create!(restaurant_id: restaurant.id)
category = Category.create!(name: "appetizer")
menu_item = MenuItem.create!(name: "tuna poke", description: "it's light", price: 9, category: category, menu: menu)
end
When("I visit the menu") do
visit restaurant_menu_path
end
Then("I should see {string} page title") do |string|
expect(page).to have_title "#{string}"
end
And("I should see {string} item name") do |item_name|
expect(page).to have_content "#{item_name}"
end
나에게 결과를 제공
expected to find text "tuna poke" in "menu sign in"
나에게 많은 의미가없는 것은 어느 것입니까? 이 세 단어가 함께 표시되는 유일한 시간은 내 응용 프로그램의/메뉴 페이지에서 탐색 모음에 로그 아웃 한 사용자로있을 때뿐입니다. 정확히 여기에 해당됩니다. 하지만 전체 페이지의 내용을 읽을 수없는 이유를 알 수 없습니다.
출력'page.html'를 해결하고 그 출력이 올바른지 –
페이지에 실제로 무엇을 볼 수 : https : //로 jsfiddle. net/x98724tb/ –