diff options
author | eileencodes <eileencodes@gmail.com> | 2016-12-03 09:27:44 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2017-02-20 15:07:34 -0500 |
commit | 3f414c22c70d5647d2ee9f16f7e4eec15c829afb (patch) | |
tree | 6465f3a3b1f1702d8ec8ae333592b081070f8c14 /actionsystemtest/test | |
parent | 970ece243d05945f59f3cdf55e44dbfe5b16d2d5 (diff) | |
download | rails-3f414c22c70d5647d2ee9f16f7e4eec15c829afb.tar.gz rails-3f414c22c70d5647d2ee9f16f7e4eec15c829afb.tar.bz2 rails-3f414c22c70d5647d2ee9f16f7e4eec15c829afb.zip |
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.
Diffstat (limited to 'actionsystemtest/test')
-rw-r--r-- | actionsystemtest/test/abstract_unit.rb | 56 |
1 files changed, 56 insertions, 0 deletions
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: <<HTML +<html> +<body> + <h1>This</h1> + <p title="the title" class="test">Paragraph 1</p> + <p title="the others" class="test">Paragraph 2</p> +</body> +</html> +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" |