Skip to content

Commit

Permalink
end-to-end browser tests for rate-limited protection and pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Feb 13, 2025
1 parent b943e0f commit 3365ff5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bot_challenge_page.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "appraisal"
spec.add_development_dependency "rspec-rails", "~> 7.1"
spec.add_development_dependency "capybara", "~> 3.40"
spec.add_development_dependency 'selenium-webdriver'
spec.add_development_dependency "webmock", "~> 3.5"
spec.add_development_dependency "nokogiri"

Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/controllers/dummy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class DummyController < ApplicationController
before_action { |controller| BotChallengePage::BotChallengePageController.bot_challenge_enforce_filter(controller) }

def index
render plain: "rendered action"
render plain: "rendered action dummy"
end
end
5 changes: 5 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
# instead of true.
config.use_transactional_fixtures = true

# Capyabara.javascript_driver setting directly applies to 'feature' spec
Capybara.default_driver = :rack_test # Faster but doesn't do Javascript
Capybara.javascript_driver = ENV['SHOW_BROWSER'] ? :selenium_chrome : :selenium_chrome_headless


# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false

Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'webmock/rspec'
require "capybara/rspec"

WebMock.disable_net_connect!(allow_localhost: true)

# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
Expand Down

0 comments on commit 3365ff5

Please sign in to comment.