I'm using Capybara 2.4.3 with Rspec-Rails 3.1.0, Ruby 2.1.5 and Rails 4.1.8. This test continues to fail:
let(:attack_squad) { create :squad, user: attacker, name: 'Attack Squad' }
scenario 'attacker has available attack squad' do
visit '/account/battles/new'
save_and_open_page
expect(page).to have_select 'Squad', options: [attack_squad.name]
end
Using save_and_open_page
, I'm able to see this HTML is being generated:
<select id="battle_squad_id" name="battle[squad_id]">
<option value="194">Attack Squad</option>
<option value="192">Default Squad</option>
</select>
And here is the failure message:
Battle Management attacker has available attack squad
Failure/Error: expect(page).to have_select 'Squad', options: [attack_squad.name]
expected to find select box "Squad" with options ["Attack Squad"] but there were no matches. Also found "Attack Squad Default Squad", which matched the selector but not all filters.
# ./spec/features/battle_spec.rb:31:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'
I'm following the same format as demonstrated in the capybara spec on GitHub. If I change the expectation to:
expect(page).to have_select 'Squad'
It is able to find the select box and pass successfully. If I make the options:
value anything other than an array, it gives me an error about there being on sort
method. What am I missing?