File tree Expand file tree Collapse file tree 3 files changed +44
-4
lines changed Expand file tree Collapse file tree 3 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,10 @@ module Generators
61
61
}
62
62
}
63
63
64
+ # We need to store the RAILS_DEV_PATH in a constant, otherwise the path
65
+ # can change when we FileUtils.cd.
66
+ RAILS_DEV_PATH = File . expand_path ( "../../.." , __dir__ ) # :nodoc:
67
+
64
68
class << self
65
69
def configure! ( config ) # :nodoc:
66
70
api_only! if config . api_only
Original file line number Diff line number Diff line change @@ -283,10 +283,6 @@ def devcontainer
283
283
end
284
284
285
285
module Generators
286
- # We need to store the RAILS_DEV_PATH in a constant, otherwise the path
287
- # can change in Ruby 1.8.7 when we FileUtils.cd.
288
- RAILS_DEV_PATH = File . expand_path ( "../../../../../.." , __dir__ )
289
-
290
286
class AppGenerator < AppBase
291
287
# :stopdoc:
292
288
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "generators/generators_test_helper"
4
+ require "rails/generators/rails/devcontainer/devcontainer_generator"
5
+
6
+ module Rails
7
+ module Generators
8
+ class DevcontainerGeneratorTest < Rails ::Generators ::TestCase
9
+ include GeneratorsTestHelper
10
+
11
+ def test_generates_devcontainer_files
12
+ run_generator
13
+
14
+ assert_file ".devcontainer/compose.yaml"
15
+ assert_file ".devcontainer/Dockerfile"
16
+ assert_file ".devcontainer/devcontainer.json"
17
+ end
18
+
19
+ def test_default_json_has_no_mounts
20
+ run_generator
21
+
22
+ assert_devcontainer_json_file do |devcontainer_config |
23
+ assert_nil devcontainer_config [ "mounts" ]
24
+ end
25
+ end
26
+
27
+ def test_dev_option_devcontainer_json_mounts_local_rails
28
+ run_generator [ "--dev" ]
29
+
30
+ assert_devcontainer_json_file do |devcontainer_json |
31
+ mounts = devcontainer_json [ "mounts" ] . sole
32
+
33
+ assert_equal "bind" , mounts [ "type" ]
34
+ assert_equal Rails ::Generators ::RAILS_DEV_PATH , mounts [ "source" ]
35
+ assert_equal Rails ::Generators ::RAILS_DEV_PATH , mounts [ "target" ]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
You can’t perform that action at this time.
0 commit comments