Last active
September 14, 2015 09:19
-
-
Save YumaInaura/a585c8015b1272f49d11 to your computer and use it in GitHub Desktop.
Capybara + rspec で selected の状態を判定する : Rails ref: http://qiita.com/Yinaura/items/b9fb268142f4d75f84c8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect(page).to have_select('book[id]', selected: 'ソフィーの世界') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select id="book" name="book[id]"> | |
<option>我輩は猫である</option> | |
<option>ソフィーの世界</option> | |
<option>ガリバー旅行記</option> | |
</select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
feature '/books', type: :feature do | |
before do | |
visit book_path | |
select 'ソフィーの世界', from: 'book[id]' #いちど選択状態にする | |
end | |
scenario "要素が選択状態になっている" do | |
expect(page).to have_select('book[id]', selected: 'ソフィーの世界') # 選択状態を判定する | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment