Can I use Poletergeist with Capybara to test negative presence of option in select

55 views Asked by At

If I have this html:

<select name"bo">
    <option value="yo">Yo</option>
    <option value="ho">Ho</option>
    <option value="go">Go</option>
</select>

What step definition can I use Capybara utilizing Poltergeist to get a failing test on this step:

Then Select "bo" does not contain the "yo" option
1

There are 1 answers

2
Anthony On BEST ANSWER

I think I understand your question. You could do something like this:

it "doesn't find element" do
  visit whatever_path
  expect { select "NotARealOption", from: "bo" }.to raise_error(SomeCapybaraError, "no match found")
end