{"record":{"id":"d3e4f74ef1c7f2c7","repo":"teamcapybara/capybara","slug":"capybara-disable-animation-supports-either-a-strin","errorCode":null,"errorMessage":"Capybara.disable_animation supports either a String (the css selector to disable) or a boolean","messagePattern":"Capybara\\.disable_animation supports either a String \\(the css selector to disable\\) or a boolean","errorType":"exception","errorClass":"CapybaraError","httpStatus":null,"severity":"error","filePath":"lib/capybara/server/animation_disabler.rb","lineNumber":13,"sourceCode":"# frozen_string_literal: true\n\nmodule Capybara\n  class Server\n    class AnimationDisabler\n      def self.selector_for(css_or_bool)\n        case css_or_bool\n        when String\n          css_or_bool\n        when true\n          '*'\n        else\n          raise CapybaraError, 'Capybara.disable_animation supports either a String (the css selector to disable) or a boolean'\n        end\n      end\n\n      def initialize(app)\n        @app = app\n        @disable_css_markup = format(DISABLE_CSS_MARKUP_TEMPLATE,\n                                     selector: self.class.selector_for(Capybara.disable_animation))\n        @disable_js_markup = +DISABLE_JS_MARKUP_TEMPLATE\n      end\n\n      def call(env)\n        status, headers, body = @app.call(env)\n        return [status, headers, body] unless html_content?(headers)\n\n        nonces = directive_nonces(headers).transform_values { |nonce| \"nonce=\\\"#{nonce}\\\"\" if nonce && !nonce.empty? }\n        response = Rack::Response.new([], status, headers)\n\n        body.each { |html| response.write insert_disable(html, nonces) }","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/teamcapybara/capybara/blob/15b5fdb76e972e9623d5af2123ed3755594f9732/lib/capybara/server/animation_disabler.rb#L1-L31","documentation":"AnimationDisabler.selector_for accepts only a CSS selector String or true (mapped to the universal selector '*'); any other value of Capybara.disable_animation raises CapybaraError when the disabler middleware is constructed at server boot. false/nil are filtered out before this code in the normal server path, so the error means a truthy value of the wrong type was configured.","triggerScenarios":"Setting Capybara.disable_animation = :all (or 1, ['*'], or any other truthy non-String) in spec_helper/rails_helper and then creating a session that boots the test server (run_server true with a Rack app); also directly constructing Capybara::Server::AnimationDisabler with such a config.","commonSituations":"Copy-pasted config assuming 'truthy means all'; passing an array of selectors (only one selector string is supported); intending 'disable everywhere' with the :all symbol; wrong branch of an env conditional setting a sentinel value.","solutions":["Use Capybara.disable_animation = true to disable animations for all elements","Or pass one CSS selector string covering the animated parts: Capybara.disable_animation = '.animated, .carousel'","To opt out, leave it nil or set false rather than a sentinel like :none"],"exampleFix":"# before\nCapybara.disable_animation = :all\n\n# after\nCapybara.disable_animation = true\n# or target specific animated elements:\n# Capybara.disable_animation = '.animation, .transition'","handlingStrategy":"validation","validationCode":"def valid_disable_animation?(v)\n  v.is_a?(String) || [true, false, nil].include?(v)\nend\n\nraise 'bad Capybara.disable_animation value' unless valid_disable_animation?(Capybara.disable_animation)","typeGuard":"def normalized_disable_animation(v)\n  case v\n  when String, true, false, nil then v\n  else true # treat any other truthy intent as disable-all\n  end\nend\n\nCapybara.disable_animation = normalized_disable_animation(raw_setting)","tryCatchPattern":"begin\n  Capybara.current_session\nrescue Capybara::CapybaraError => e\n  raise unless e.message.include?('disable_animation')\n  Capybara.disable_animation = true\n  retry\nend","preventionTips":["Validate Capybara.disable_animation right after assignment in a support file","Keep all Capybara settings in one reviewed config block","Bootstrap one cheap session so bad config fails fast at startup"],"tags":["configuration","animation","css","server-boot","capybara-error"],"backgroundTag":"invalid-configuration-value","analyzedSha":"15b5fdb76e972e9623d5af2123ed3755594f9732","analyzedAt":"2026-08-21T16:53:45.588Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}