@@ -21,48 +21,54 @@ class StylesGeneratorTest < Rails::Generators::TestCase
21
21
22
22
test "does not raise if API configuration is commented out" do
23
23
within_api_only_app ( commented_out : true ) do
24
- run_generator
24
+ capture ( :stderr ) { run_generator }
25
25
end
26
26
end
27
27
28
28
test "adds gems to Gemfile" do
29
- run_generator
29
+ capture ( :stderr ) { run_generator }
30
30
31
31
assert_file app_root ( "Gemfile" ) do |file |
32
32
assert_match "cssbundling-rails" , file
33
33
end
34
34
end
35
35
36
36
test "installs gems with Bundler" do
37
- output = run_generator
37
+ capture ( :stderr ) do
38
+ output = run_generator
38
39
39
- assert_match ( /bundle install/ , output )
40
+ assert_match ( /bundle install/ , output )
41
+ end
40
42
end
41
43
42
44
test "runs install script" do
43
- output = run_generator
45
+ capture ( :stderr ) do
46
+ output = run_generator
44
47
45
- assert_match ( /bin\/ rails css:install:postcss/ , output )
48
+ assert_match ( /bin\/ rails css:install:postcss/ , output )
49
+ end
46
50
end
47
51
48
52
test "installs modern-normalize and imports stylesheets" do
49
- output = run_generator
50
- application_stylesheet = <<~TEXT
51
- @import "modern-normalize";
52
- @import "base.css";
53
- @import "components.css";
54
- @import "utilities.css";
55
- TEXT
56
-
57
- assert_match ( /add.*modern-normalize/ , output )
58
-
59
- assert_file app_root ( "app/assets/stylesheets/application.postcss.css" ) do |file |
60
- assert_equal application_stylesheet , file
53
+ capture ( :stderr ) do
54
+ output = run_generator
55
+ application_stylesheet = <<~TEXT
56
+ @import "modern-normalize";
57
+ @import "base.css";
58
+ @import "components.css";
59
+ @import "utilities.css";
60
+ TEXT
61
+
62
+ assert_match ( /add.*modern-normalize/ , output )
63
+
64
+ assert_file app_root ( "app/assets/stylesheets/application.postcss.css" ) do |file |
65
+ assert_equal application_stylesheet , file
66
+ end
61
67
end
62
68
end
63
69
64
70
test "creates stylesheets" do
65
- run_generator
71
+ capture ( :stderr ) { run_generator }
66
72
67
73
assert_file app_root ( "app/assets/stylesheets/base.css" ) do |file |
68
74
assert_equal "/* Base Styles */" , file
@@ -76,15 +82,17 @@ class StylesGeneratorTest < Rails::Generators::TestCase
76
82
end
77
83
78
84
test "installs postcss-url" do
79
- output = run_generator
85
+ capture ( :stderr ) do
86
+ output = run_generator
80
87
81
- assert_match ( /add\s *postcss-url/ , output )
88
+ assert_match ( /add\s *postcss-url/ , output )
89
+ end
82
90
end
83
91
84
92
test "configures postcss.config.js" do
85
93
expected = file_fixture ( "postcss.config.js" ) . read
86
94
87
- run_generator
95
+ capture ( :stderr ) { run_generator }
88
96
89
97
assert_file app_root ( "postcss.config.js" ) do |file |
90
98
assert_equal expected , file
@@ -95,15 +103,15 @@ class StylesGeneratorTest < Rails::Generators::TestCase
95
103
touch "postcss.config.js" , content : "unexpected"
96
104
expected = file_fixture ( "postcss.config.js" ) . read
97
105
98
- run_generator
106
+ capture ( :stderr ) { run_generator }
99
107
100
108
assert_file app_root ( "postcss.config.js" ) do |file |
101
109
assert_equal expected , file
102
110
end
103
111
end
104
112
105
113
test "creates directory to store static assets generated from postcss-url" do
106
- run_generator
114
+ capture ( :stderr ) { run_generator }
107
115
108
116
assert_file app_root ( "app/assets/static/.gitkeep" )
109
117
end
0 commit comments