Я новичок в ruby и хочу создать систему автотестирования для веб-приложения. Я начал изучать связку капибара + огурец на рубине.
Я нашел пример и попытался воспроизвести его. Существует структура проекта:
devTests
features
step_definitions
test_steps.rb
support
env.rb
tests
test_send_mail.feature
Gemfile
Gemfile.lock
Файл компонента имеет текст:
Feature: Log in to site
Scenario: Log in to site on English
Given Go to page "http://localhost:3000/login"
And Select text "English" in dropdownlist id "lang"
And Wait 5 second
And Input text "admin" in field with id "session_email"
And Input text "123" in field with id "session_password"
And Press button with text "Log in"
And Wait 5 second
и step_definitions
Given(/^Go to page "(.*?)"$/) do |page|
visit page
end
Given(/^Select text "(.*?)" in dropdownlist id "(.*?)"$/) do |text, select_id|
find("//select[@id='#{select_id}']/option[text()='#{text}']").click
end
Given(/^Wait (\d+) second(?:|s)$/) do |sec|
sleep sec.to_i
end
Given(/^Input text "(.*?)" in field with id "(.*?)"$/) do |text, field_id|
find("//input[@id='#{field_id}']").set(text)
end
Given(/^Input text "(.*?)" in field with id "(.*?)"$/) do |text, field_id|
find("//input[@id='#{field_id}']").set(text)
end
Given(/^Press button with text "(.*?)"$/) do |text|
find("//input[@value='#{text}']").click
end
Given(/^Wait (\d+) second(?:|s)$/) do |sec|
sleep sec.to_i
end
Когда я запускаю тест, я получаюошибки парсера
PS D:\07 TestConwize\devTests> cucumber
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
features/tests/test_send_mail.feature: Parser errors:
(1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Feature: Log in to site'
(2:3): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Scenario: Log in to site on English'
(3:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Given Go to page "http://localhost:3000/login"'
(4:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Select text "English" in dropdownlist id "lang"'
(5:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Wait 5 second'
(6:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Input text "admin" in field with id
"session_email"'
(7:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Input text "123" in field with id "session_password"'
(8:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Press button with text "Log in"'
(9:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Wait 5 second' (Cucumber::Core::Gherkin::ParseError)
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core/gherkin/parser.rb:34:in `rescue in document'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core/gherkin/parser.rb:28:in `document'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:30:in `block in parse'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:29:in `each'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:29:in `parse'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:21:in `compile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:75:in `run!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in `execute!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/bin/cucumber:9:in `<top (required)>'
C:/Ruby25-x64/bin/cucumber:23:in `load'
C:/Ruby25-x64/bin/cucumber:23:in `<main>'
Я боролся весь день, но я не могу понять, в чем проблема. Не могли бы вы помочь мне?