Class: DisableAnimationsInTestEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/hyrax/specs/disable_animations_in_test_environment.rb

Overview

disable CSS3 and jQuery animations in test mode for speed, consistency and avoiding timing issues. HT: gist.github.com/keithtom/8763169

Instance Method Summary collapse

Constructor Details

#initialize(app, _options = {}) ⇒ DisableAnimationsInTestEnvironment

Returns a new instance of DisableAnimationsInTestEnvironment.



5
6
7
# File 'lib/hyrax/specs/disable_animations_in_test_environment.rb', line 5

def initialize(app, _options = {})
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/hyrax/specs/disable_animations_in_test_environment.rb', line 9

def call(env)
  @status, @headers, @body = @app.call(env)
  return [@status, @headers, @body] unless html?
  response = Rack::Response.new([], @status, @headers)

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

  response.finish
end