Class: Relevance::Tarantula::RailsIntegrationProxy
- Extended by:
- Forwardable, Relevance::Tarantula
- Includes:
- Relevance::Tarantula
- Defined in:
- lib/relevance/tarantula/rails_integration_proxy.rb
Constant Summary
Constants included from Relevance::Tarantula
Instance Attribute Summary collapse
-
#integration_test ⇒ Object
Returns the value of attribute integration_test.
Class Method Summary collapse
Instance Method Summary collapse
- #alter_response(response, code, body) ⇒ Object
-
#initialize(integration_test) ⇒ RailsIntegrationProxy
constructor
A new instance of RailsIntegrationProxy.
- #patch_response(url, response) ⇒ Object
- #static_content_file(url) ⇒ Object
- #static_content_path(url) ⇒ Object
Methods included from Relevance::Tarantula
log, rails_root, tarantula_home, verbose
Constructor Details
#initialize(integration_test) ⇒ RailsIntegrationProxy
Returns a new instance of RailsIntegrationProxy.
33 34 35 36 |
# File 'lib/relevance/tarantula/rails_integration_proxy.rb', line 33 def initialize(integration_test) @integration_test = integration_test @integration_test..attr_accessor :response end |
Instance Attribute Details
#integration_test ⇒ Object
Returns the value of attribute integration_test.
14 15 16 |
# File 'lib/relevance/tarantula/rails_integration_proxy.rb', line 14 def integration_test @integration_test end |
Class Method Details
.rails_integration_test(integration_test, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/relevance/tarantula/rails_integration_proxy.rb', line 16 def self.rails_integration_test(integration_test, = {}) t = Crawler.new t.max_url_length = [:max_url_length] if [:max_url_length] t.proxy = RailsIntegrationProxy.new(integration_test) t.handlers << HtmlDocumentHandler.new(t) t.handlers << InvalidHtmlHandler.new t.log_grabber = Relevance::Tarantula::LogGrabber.new(File.join(rails_root, "log/test.log")) t.skip_uri_patterns << /logout$/ t.transform_url_patterns += [ [/\?\d+$/, ''], # strip trailing numbers for assets [/^http:\/\/#{integration_test.host}/, ''] # strip full path down to relative ] t.test_name = t.proxy.integration_test.method_name t.reporters << Relevance::Tarantula::HtmlReporter.new(t.report_dir) t end |
Instance Method Details
#alter_response(response, code, body) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/relevance/tarantula/rails_integration_proxy.rb', line 56 def alter_response(response, code, body) response..attr_accessor :code response.code = code response.body = body response end |
#patch_response(url, response) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/relevance/tarantula/rails_integration_proxy.rb', line 63 def patch_response(url, response) if response.code == '404' if File.exist?(static_content_path(url)) case ext = File.extension(url) when /html|te?xt|css|js|jpe?g|gif|psd|png|eps|pdf|ico/ response.headers["type"] = "text/#{ext}" # readable as response.content_type alter_response(response, '200', static_content_file(url)) else log "Skipping unknown type #{url}" end end end # don't count on metaclass taking block, e.g. # http://relevancellc.com/2008/2/12/how-should-metaclass-work response..class_eval do include Relevance::CoreExtensions::Response end end |