Sha256: 45d5aa6f9a361e06ffb20d406d620b12748b815ecedb8c39be9657b35bef82bf

Contents?: true

Size: 1000 Bytes

Versions: 13

Compression:

Stored size: 1000 Bytes

Contents

# Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"

require File.expand_path("../../config/environment.rb", __FILE__)
require "rails/test_help"
require "nokogiri"

require 'rails-controller-testing'
Rails::Controller::Testing.install

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

13 entries across 13 versions & 3 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/slim-4.1.0/test/rails/test/helper.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/slim-4.1.0/test/rails/test/helper.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/slim-4.1.0/test/rails/test/helper.rb
slim-5.2.1 test/rails/test/helper.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/slim-4.1.0/test/rails/test/helper.rb
slim-5.2.0 test/rails/test/helper.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/slim-4.1.0/test/rails/test/helper.rb
slim-5.1.1 test/rails/test/helper.rb
slim-5.1.0 test/rails/test/helper.rb
slim-5.0.0 test/rails/test/helper.rb
slim-4.1.0 test/rails/test/helper.rb
slim-4.0.1 test/rails/test/helper.rb
slim-4.0.0 test/rails/test/helper.rb