From 3f414c22c70d5647d2ee9f16f7e4eec15c829afb Mon Sep 17 00:00:00 2001 From: eileencodes Date: Sat, 3 Dec 2016 09:27:44 -0500 Subject: Cleanup Rails provided helpers 1. Clean up screenshot helper Updates documentation to be clearer and separates the concerns of saving the image, setting the image path, and displaying the image. 2. Remove Rails provided assertions for selectors This was moved upstream to Capybara and is no longer necessary to be included in Rails 3. Remove form helper The form helper is pretty specific to Basecamp's needs and may not be helpful outside of Rails. --- actionsystemtest/test/abstract_unit.rb | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'actionsystemtest/test') diff --git a/actionsystemtest/test/abstract_unit.rb b/actionsystemtest/test/abstract_unit.rb index 26da9c7ccb..81630ca66d 100644 --- a/actionsystemtest/test/abstract_unit.rb +++ b/actionsystemtest/test/abstract_unit.rb @@ -3,6 +3,62 @@ require "action_controller" require "action_dispatch" require "action_system_test" +# Set the Rails tests to use the +:rack_test+ driver because +# we're not testing Capybara or it's drivers, but rather that +# the methods accept the proper arguments. +class RoutedRackApp + attr_reader :routes + + def initialize(routes, &blk) + @routes = routes + @stack = ActionDispatch::MiddlewareStack.new(&blk).build(@routes) + end + + def call(env) + @stack.call(env) + end +end + +class ActionSystemTestCase < ActionSystemTest::Base + ActionSystemTest.driver = :rack_test + + def self.build_app(routes = nil) + RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) + end +end + +class PostsController < ActionController::Base + def index + render inline: < + +

This

+

Paragraph 1

+

Paragraph 2

+ + +HTML + end +end + +CapybaraRoutes = ActionDispatch::Routing::RouteSet.new +CapybaraRoutes.draw do + resources :posts +end + +# Initialize an application +APP = ActionSystemTestCase.build_app(CapybaraRoutes) + +# Initialize an application for Capybara +RailsApp = ActionSystemTestCase.new(APP) + +# Assign Capybara.app to original Rack Application +Capybara.app = APP + +Capybara.add_selector :title_test do + xpath { |name| XPath.css(".test")[XPath.attr(:title).is(name.to_s)] } +end + # Skips the current run on Rubinius using Minitest::Assertions#skip def rubinius_skip(message = "") skip message if RUBY_ENGINE == "rbx" -- cgit v1.2.3