2011-11-16 2 views
1

나는 오이 1.1.1와 레일 3 응용 프로그램에서 일하고있어 내 오이 시나리오에서 여러 확인란을 선택하려고합니다.오이 여러 확인란을 선택

@wip 
    Scenario: New Clergy 
    Given I am on the clergies page 
    When I follow "New Clergy" 
    And I fill in "Surname" with "Wells" 
    And I fill in "Given names" with "Robin" 
    And I check the 1st of the "diocese" checkboxes 
    And I check the 2nd of the "diocese" checkboxes 
    And I press "Create Clergy" 
    Then I should see "Clergy was successfully created." 

내가 오류 실행 : 여기

- for diocese in Diocese.all 
    = check_box_tag "clergy[diocese_ids][]", diocese.id, @clergy.dioceses.include?(diocese) 
    = f.label diocese.name 
    %br 

내 오이 테스트입니다 내 오이 단계

여기
When /^I check the (\d+)(st|nd|rd|th) of the "([^"]*)" checkboxes$/ do |index, junk, group| 
    page.all("input[id=\"clergy_diocese_ids_\"]")[index.to_i - 1].check('clergy_diocese_ids_') 
end 

입니다 : 여기

는 HAML 내 여러 체크 박스입니다 내 검사 :

And I check the 1st of the "diocese" checkboxes         # fea 
tures/step_definitions/clergy_steps.rb:37             
     cannot check field, no checkbox with id, name, or label 'clergy_diocese_ids_' found (C 
apybara::ElementNotFound)                 
     ./features/step_definitions/clergy_steps.rb:38:in `/^I check the (\d+)(st|nd|rd|th) of 
the "([^"]*)" checkboxes$/'                
     features/clergy_new.feature:17:in `And I check the 1st of the "diocese" checkboxes' 

나는 page.all 선택기로 놀아 보려고했지만 시도 할 수 없습니다.

+1

렌더링 된 페이지 출력을 확인하여 확인란의 id 속성 형식을 확인 했습니까? –

+0

예 파이어 폭스에서 firebug를 사용하여 내 체크 박스 ID를 확인했습니다. – map7

+0

귀하의 오이 단계에서 귀하의 테스트가 모든 체크 박스가 동일한 ID를 공유 할 것으로 예상되는 것처럼 보입니다. 문자열 보간법을 사용하여 선택해야하는 체크 박스의 올바른 ID를 형성해야합니까? –

답변

0

내가 알기로, 오이가 체크 박스를 선택하고 UI와 상호 작용하는 것이 아닙니다. Cucumber는 지형지 물 파일을 구문 분석하고 일치하는 해당 단계 정의를 실행합니다. 각 단계 정의 블록에 넣는 것은 당신에게 달려 있습니다.

스텝 정의 코드가 카피 바라 (Capybara)를 사용하는 것처럼 보이므로 this solution을 표시하는 것이 좋습니다.

관련 문제