Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'test_helper'
- class FoosController < ApplicationController
- def index
- render plain: 'something'
- end
- end
- class UsersControllerTest < ActionDispatch::IntegrationTest
- def test_some_routing
- with_routing do |set|
- set.draw do
- get '/foos' => 'foos#index'
- end
- get '/foos'
- assert_equal 200, response.status
- end
- end
- end
- class ActionDispatch::IntegrationTest
- def with_routing(&block)
- yield ComfortableMexicanSofa::Application.routes
- ensure
- ComfortableMexicanSofa::Application.routes_reloader.reload!
- end
- end
- def with_foo_route
- Rails.application.routes.draw do
- get 'foo' => 'foo#index'
- end
- yield
- Rails.application.routes_reloader.reload!
- end
- with_foo_route do
- get '/foo'
- assert_equal 200, status
- end
- require 'test_helper'
- class ConcernedController < ApplicationController
- include Concern
- def action
- render plain: "response", status: :ok
- end
- end
- class ConcernTest < ActionDispatch::IntegrationTest
- setup do
- @controller = ConcernedController.new
- Rails.application.routes.draw do
- get "/action" => "concerned#action"
- post "/action" => "concerned#action"
- end
- end
- teardown do
- Rails.application.reload_routes!
- end
- test "concern method" do
- post "/action"
- # Test what the concern does
- assert_response :ok
- assert_equal "Response", response.body
- end
- end
Add Comment
Please, Sign In to add comment