File: view_reloading_test.rb

package info (click to toggle)
rails 2%3A7.2.2.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 43,348 kB
  • sloc: ruby: 349,797; javascript: 30,703; yacc: 46; sql: 43; sh: 29; makefile: 27
file content (56 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require "isolation/abstract_unit"
require "rack/test"

module ApplicationTests
  class ViewReloadingTest < ActiveSupport::TestCase
    include ActiveSupport::Testing::Isolation
    include Rack::Test::Methods

    def setup
      build_app

      app_file "config/routes.rb", <<-RUBY
        Rails.application.routes.draw do
          get 'pages/:id', to: 'pages#show'
        end
      RUBY

      app_file "app/controllers/pages_controller.rb", <<-RUBY
        class PagesController < ApplicationController
          layout false

          def show
          end
        end
      RUBY
    end

    def teardown
      teardown_app
    end

    test "views are reloaded" do
      app_file "app/views/pages/show.html.erb", <<-RUBY
        Before!
      RUBY

      ENV["RAILS_ENV"] = "development"
      require "#{app_path}/config/environment"

      get "/pages/foo"
      get "/pages/foo"
      assert_equal 200, last_response.status, last_response.body
      assert_equal "Before!", last_response.body.strip

      app_file "app/views/pages/show.html.erb", <<-RUBY
        After!
      RUBY

      get "/pages/foo"
      assert_equal 200, last_response.status
      assert_equal "After!", last_response.body.strip
    end
  end
end