Sha256: bfbe4283c6abe1fcc33bd01e50b4a090b876366ac45bfdad937cce60f628f2f4
Contents?: true
Size: 929 Bytes
Versions: 31
Compression:
Stored size: 929 Bytes
Contents
# Configure Rails Envinronment ENV["RAILS_ENV"] = "test" require File.expand_path("../../config/environment.rb", __FILE__) require "rails/test_help" require "nokogiri" Rails.backtrace_cleaner.remove_silencers! class ActionDispatch::IntegrationTest protected def assert_xpath(xpath, message="Unable to find '#{xpath}' in response body.") assert_response :success, "Response type is not :success (code 200..299)." body = @response.body assert !body.empty?, "No response body found." doc = Nokogiri::HTML(body) rescue nil assert_not_nil doc, "Cannot parse response body." assert doc.xpath(xpath).size >= 1, message end def assert_html(expected, options = {}) expected = "<!DOCTYPE html><html><head><title>Dummy</title></head><body>#{options[:heading]}<div class=\"content\">#{expected}</div></body></html>" unless options[:skip_layout] assert_equal expected, @response.body end end
Version data entries
31 entries across 31 versions & 3 rubygems