Created
May 20, 2019 17:25
-
-
Save mexelout/cc9b8a774b6173267d071ee1242f0ec8 to your computer and use it in GitHub Desktop.
wait_for関係
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
# デフォでコメントアウトされてるの外すだけ | |
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } | |
RSpec.configure do |config| | |
config.include WaitFor | |
end |
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
# spec/features/top_spec.rb | |
require 'rails_helper' | |
feature 'top page' do | |
describe 'visit top page' do | |
context '100 users' do | |
background { create_list(:user, 100) } | |
given!(:user) { create(:user) } | |
scenario 'collapse test' do | |
visit root_path | |
# こんな感じで括る | |
wait_for_html { click_on 'トグルボタン' } | |
click_on user.name | |
expect(page.current_path).to eq "/users/#{user.id}" | |
end | |
end | |
end | |
end |
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
# spec/support/wait_for.rb | |
module WaitFor | |
def wait_for_html(wait_time: Capybara.default_max_wait_time) | |
prev_html = page.html | |
yield if block_given? | |
Timeout.timeout(wait_time) { loop until prev_html != page.html } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment