현재 "Page Object"패턴을 사용하기 위해 전체 오이 테스트를 리팩토링하고 있지만 RSpec matcher를 사용하는 데 많은 문제가 있습니다. .Cucumber/Capybara - "Page Object"패턴을 사용하는 RSpec matcher 사용
다음과 내가 가진 기존의 단계가 될 때 :
Then /^I should (not)?see the following alerts:$/ do |negate, alerts|
expectation = negate ? :should_not : :should
@alert_reporting_panel = AlertReportingPanel.new(Capybara.current_session)
@alert_reporting_panel.verify_contents expectation, alerts
end
그리고 내 패널 개체는 다음과 같습니다 :
Then /^I should (not)?see the following alerts:$/ do |negate, alerts|
expectation = negate ? :should_not : :should
within(ALERT_TABLE_ID) do
alerts.hashes.each do |alert|
page.send(expectation, have_content(alert["Original ID"]))
end
end
end
내 리팩토링 단계는 불행하게도
class AlertReportingPanel
def initialize(session)
@session = session
end
def verify_contents(expectation, alerts)
@session.within(ALERT_TABLE_ID) do
alerts.hashes.each do |alert|
@session.send(expectation, have_content(alert["Original ID"]))
end
end
end
end
, 나는 undefined method 'have_contents' for #<AlertReportingPanel:0x3f0faf8> (NoMethodError)
를 얻을 수 .
require 'rspec'
을 클래스 상단에 추가하려고 시도했으며 메서드를 정규화하여 시도 했으므로 : Capybara::RSpecMatchers::HaveMatcher.have_content
, 그러나 단지 uninitialized constant Capybara::RSpecMatchers (NameError)
이 표시됩니다.
저는 Ruby를 처음 접했고이 문제를 수정하는 것이 쉽다는 것을 확신합니다 ...하지만 나는 그것을 스스로 해결할 수없는 것 같습니다.
도와주세요. 고맙습니다.
감사합니다. 지연에 대해 유감스럽게 생각하고, 나는 루비/오이를 사용하지 않은 다른 프로젝트에서 바빴다. –