Class Mechanize::TestCase
In: lib/mechanize/test_case.rb
Parent: MiniTest::Unit::TestCase

A generic test case for testing mechanize. Using a subclass of Mechanize::TestCase for your tests will create an isolated mechanize instance that won‘t pollute your filesystem or other tests.

Once Mechanize::TestCase is loaded no HTTP requests will be made outside mechanize itself. All requests are handled via WEBrick servlets.

Mechanize uses WEBrick servlets to test some functionality. You can run other HTTP clients against the servlets using:

  ruby -rmechanize/test_case/server -e0

Which will launch a test server at localhost:8000

Methods

Constants

TEST_DIR = File.expand_path '../../../test', __FILE__
REQUESTS = []

Public Instance methods

Creates a fake page with URI fake.example and an empty, submittable form.

Is the Encoding constant defined?

Creates a Mechanize::Page with the given body

Runs the block inside a temporary directory

Creates a Nokogiri Node element with the given attributes

Creates a Mechanize::Page for the given uri with the given content_type, response body and HTTP status code

Requests made during this tests

Creates a clean mechanize instance +@mech+ for use in tests.

An X509 certificate. This certificate is the same across all test runs

An SSL private key. This key is the same across all test runs

Creates a Tempfile with content that is immediately unlinked

[Validate]