Я пишу тестовые спецификации для приложения Sinatra. Как я могу попросить rspec щелкнуть переключатель в моей форме?Rspec: выбор переключателя для формы Sinatra?
<form action="/reports/new" method="POST">
<div class="form-group">
<label class="col-md-4 control-label" for="radios">Borough</label>
<div>
<label>
<input name="Brooklyn" id="borough_1" value="1" type="radio">Brooklyn</input>
</label>
<label>
<input name="Bronx" id="borough_2" value="2" type="radio">Bronx</input>
</label>
<label>
<input name="Manhattan" id="borough_3" value="3" type="radio">Manhattan</input>
</label>
<label>
<input name="Queens" id="borough_4" value="4" type="radio">Queens</input>
</label>
<label>
<input name="Staten Island" id="borough_5" value="5" type="radio">Staten Island</input>
</label>
<button value="Submit" type="submit">Submit</button>
</div>
</div>
</form>
Edit: Я сделал проверить этот ресурс, но это не помогло мне: stackoverflow.com/questions/11483967/… Я попытался choose('Manhattan')
. Тем не менее, я продолжаю получать эту ошибку: Failure/Error: choose('Manhattan') Capybara::ElementNotFound: Unable to find radio button "Manhattan"
Хорошей новостью является то, что rspec по крайней мере ищет переключатель.
visit '/reports/new'
fill_in(:title, :with => "Ben and Jerries Ice Cream")
fill_in(:business, :with => "Starbucks")
fill_in(:location, :with => "146 Rikers Street")
fill_in(:content, :with => "Some great food")
fill_in(:date, :with => "2016-09-12")
choose('Manhattan')
Что вы пробовали? Есть [несколько] (http://stackoverflow.com/questions/27430074/how-to-click-radio-button-with-capybara-in-ruby-on-rails-app) [ответы] (http: // stackoverflow.com/questions/11483967/selecting-a-radio-button-with-rspec) [доступно] (http://stackoverflow.com/questions/21085057/capybara-chooseradio-button-not-working) с быстрым Google поиск; вы исследовали и экспериментировали с ними? –
Я проверил этот ресурс: http://stackoverflow.com/questions/11483967/selecting-a-radio-button-with-rspec?noredirect11&lq=1 Я попробовал 'select ('Manhattan')'. Тем не менее, я получаю эту ошибку: '' 'Отказ/Ошибка: выберите ('Manhattan') Капибара :: ElementNotFound: Невозможно найти кнопку радио "Manhattan"' '' –
@Joel B, пожалуйста, добавьте детали вашего последнего комментария к вашему вопросу, это поможет нам в будущем. – eeeeeean