Class: Capybara::Server::AnimationDisabler Private

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/server/animation_disabler.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ AnimationDisabler

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AnimationDisabler.

API:

  • private



17
18
19
20
# File 'lib/capybara/server/animation_disabler.rb', line 17

def initialize(app)
  @app = app
  @disable_markup = format(DISABLE_MARKUP_TEMPLATE, selector: self.class.selector_for(Capybara.disable_animation))
end

Class Method Details

.selector_for(css_or_bool) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



6
7
8
9
10
11
12
13
14
15
# File 'lib/capybara/server/animation_disabler.rb', line 6

def self.selector_for(css_or_bool)
  case css_or_bool
  when String
    css_or_bool
  when true
    '*'
  else
    raise CapybaraError, 'Capybara.disable_animation supports either a String (the css selector to disable) or a boolean'
  end
end

Instance Method Details

#call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/capybara/server/animation_disabler.rb', line 22

def call(env)
  @status, @headers, @body = @app.call(env)
  return [@status, @headers, @body] unless html_content?

  response = Rack::Response.new([], @status, @headers)

  @body.each { |html| response.write insert_disable(html) }
  @body.close if @body.respond_to?(:close)

  response.finish
end