Class: Capybara::Server::AnimationDisabler

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ AnimationDisabler

Returns a new instance of AnimationDisabler.



6
7
8
# File 'lib/capybara/server/animation_disabler.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/capybara/server/animation_disabler.rb', line 10

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