File: railtie_test.rb

package info (click to toggle)
ruby-shoulda-context 2.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 476 kB
  • sloc: ruby: 1,712; sh: 200; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 1,173 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
require "test_helper"

class RailtieTest < PARENT_TEST_CASE
  context "A Rails application with shoulda-context added to it" do
    setup do
      app.create
    end

    should "load files in vendor/gems and vendor/plugins when booted" do
      app.create_gem_with_macro(
        module_name: "MacrosFromVendor",
        location: "vendor/gems/vendored_gem_with_macro",
        macro_name: "macro_from_vendored_gem"
      )
      app.create_gem_with_macro(
        module_name: "MacrosFromPlugin",
        location: "vendor/plugins/plugin_gem_with_macro",
        macro_name: "macro_from_plugin_gem"
      )
      app.create_gem_with_macro(
        module_name: "MacrosFromTest",
        location: "test",
        macro_name: "macro_from_test"
      )
      app.write_file("test/macros_test.rb", <<~RUBY)
        ENV["RAILS_ENV"] = "test"
        require_relative "../config/environment"

        class MacrosTest < #{PARENT_TEST_CASE}
          macro_from_vendored_gem
          macro_from_plugin_gem
          macro_from_test
        end
      RUBY

      app.run_n_unit_test_suite
    end
  end

  def app
    @_app ||= RailsApplicationWithShouldaContext.new
  end
end