WithProcfileApp creates an application to use with your CLI command that contains Procfile defining web and worker processes.
(f func(dir string))
| 137 | // WithProcfileApp creates an application to use with your CLI command |
| 138 | // that contains Procfile defining web and worker processes. |
| 139 | func WithProcfileApp(f func(dir string)) { |
| 140 | dir := TempDirAbsolutePath("", "simple-ruby-app") |
| 141 | defer os.RemoveAll(dir) |
| 142 | |
| 143 | err := os.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- |
| 144 | web: ruby -run -e httpd . -p $PORT |
| 145 | console: bundle exec irb`, |
| 146 | ), 0666) |
| 147 | Expect(err).ToNot(HaveOccurred()) |
| 148 | |
| 149 | //TODO: Remove the ruby version once bundler issue(https://github.com/rubygems/rubygems/issues/6280) |
| 150 | // is solved |
| 151 | err = os.WriteFile(filepath.Join(dir, "Gemfile"), []byte(`source 'http://rubygems.org' |
| 152 | ruby '~> 3.0' |
| 153 | gem 'irb' |
| 154 | gem 'webrick'`, |
| 155 | ), 0666) |
| 156 | Expect(err).ToNot(HaveOccurred()) |
| 157 | |
| 158 | err = os.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` |
| 159 | GEM |
| 160 | remote: http://rubygems.org/ |
| 161 | specs: |
| 162 | io-console (0.6.0) |
| 163 | irb (1.6.4) |
| 164 | reline (>= 0.3.0) |
| 165 | reline (0.3.3) |
| 166 | io-console (~> 0.5) |
| 167 | webrick (1.8.1) |
| 168 | |
| 169 | PLATFORMS |
| 170 | ruby |
| 171 | |
| 172 | DEPENDENCIES |
| 173 | irb |
| 174 | webrick |
| 175 | |
| 176 | RUBY VERSION |
| 177 | ruby 3.3.1p55 |
| 178 | |
| 179 | BUNDLED WITH |
| 180 | 2.5.18 |
| 181 | `, |
| 182 | ), 0666) |
| 183 | Expect(err).ToNot(HaveOccurred()) |
| 184 | |
| 185 | f(dir) |
| 186 | } |
| 187 | |
| 188 | // WithCrashingApp creates an application to use with your CLI command |
| 189 | // that will not successfully start its `web` process |
no test coverage detected