rspec/rspec-rails

Allow running the test suite offline

Apteryks opened this issue · 2 comments

Hello,

Is your feature request related to a problem? Please describe.
Yes: it doesn't currently appear possible to run the acceptance tests (cucumber) inside a minimal environment isolated from the network (internet).

Describe the solution you'd like
It'd be nice if the test suite was self contained, e.g. not needing to fetch any resource from the internet at the time the test suite is run.

Describe alternatives you've considered
N/A.

Additional context
This is as far as I've gotten, with some light patching to use gems from GEM_PATH instead of from git:

starting phase `check'
Resolving dependencies...
/gnu/store/j4z07lyi1ykk8bc68h1p4bpj1il9dn3f-ruby-2.7.4/bin/ruby -w -I/gnu/store/l3nss8vrb6laiqb1ayn9bri2vn4xnzj1-ruby-rspec-core-3.12.1/lib/ruby/vendor_ruby/gems/rspec-core-3.12.1/lib:/gnu/store/900s3ljm1d44zam9hsbxf7ckr49zrriv-ruby-rspec-support-3.12.0/lib/ruby/vendor_ruby/gems/rspec-support-3.12.0/lib /gnu/store/l3nss8vrb6laiqb1ayn9bri2vn4xnzj1-ruby-rspec-core-3.12.1/lib/ruby/vendor_ruby/gems/rspec-core-3.12.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32454: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32615: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32651: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32740: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32756: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32822: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32863: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32888: warning: statement not reached
/gnu/store/2cqdyxyp0dxfmjhbgk3q84dzplf2qd6a-ruby-mail-2.7.1/lib/ruby/vendor_ruby/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:31984: warning: assigned but unused variable - testEof

Randomized with seed 52034
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................***......................................................................

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) HaveEnqueuedMail matchers have_enqueued_mail when parameterized passes when mixing parameterized and non-parameterized emails
     # No reason given
     # ./spec/rspec/rails/matchers/have_enqueued_mail_spec.rb:375

  2) HaveEnqueuedMail matchers have_enqueued_mail when parameterized passes with provided argument matchers
     # No reason given
     # ./spec/rspec/rails/matchers/have_enqueued_mail_spec.rb:382

  3) HaveEnqueuedMail matchers have_enqueued_mail when parameterized passes when mailer is parameterized
     # No reason given
     # ./spec/rspec/rails/matchers/have_enqueued_mail_spec.rb:369

Finished in 2.54 seconds (files took 1.27 seconds to load)
1062 examples, 0 failures, 3 pending

Randomized with seed 52034

rm -rf tmp/example_app
rm -f /tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/bin/rails
bundle exec rails new ./tmp/example_app --no-rc --skip-javascript --skip-bootsnap --skip-sprockets --skip-git --skip-test-unit --skip-listen --skip-bundle --skip-spring --template=example_app_generator/generate_app.rb
      create  
      create  README.md
      create  Rakefile
      create  .ruby-version
      create  config.ru
      create  Gemfile
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/stylesheets/application.css
      create  app/channels/application_cable/channel.rb
      create  app/channels/application_cable/connection.rb
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/jobs/application_job.rb
      create  app/mailers/application_mailer.rb
      create  app/models/application_record.rb
      create  app/views/layouts/application.html.erb
      create  app/views/layouts/mailer.html.erb
      create  app/views/layouts/mailer.text.erb
      create  app/assets/images
      create  app/assets/images/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/rails
      create  bin/rake
      create  bin/setup
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/cable.yml
      create  config/puma.rb
      create  config/storage.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/content_security_policy.rb
      create  config/initializers/cors.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/new_framework_defaults_7_0.rb
      create  config/initializers/permissions_policy.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/master.key
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/apple-touch-icon-precomposed.png
      create  public/apple-touch-icon.png
      create  public/favicon.ico
      create  public/robots.txt
      create  tmp
      create  tmp/.keep
      create  tmp/pids
      create  tmp/pids/.keep
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor
      create  vendor/.keep
      create  test/fixtures/files
      create  test/fixtures/files/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/channels/application_cable/connection_test.rb
      create  test/test_helper.rb
      create  test/system
      create  test/system/.keep
      create  test/application_system_test_case.rb
      create  storage
      create  storage/.keep
      create  tmp/storage
      create  tmp/storage/.keep
      remove  config/initializers/cors.rb
      remove  config/initializers/new_framework_defaults_7_0.rb
       apply  /tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/example_app_generator/generate_app.rb
     prepend    Rakefile
        gsub    Gemfile
        gsub    Gemfile
        gsub    Gemfile
        gsub    Gemfile
        gsub    Gemfile
        gsub    Gemfile
      append    Gemfile
        gsub    Gemfile
        gsub    Gemfile
        gsub    Gemfile
      append    Gemfile
      create    maintenance-branch
      create    ci_retry_bundle_install.sh
        gsub    ci_retry_bundle_install.sh
        gsub    ci_retry_bundle_install.sh
       chmod    ci_retry_bundle_install.sh
    conflict    app/assets/config/manifest.js
<config/manifest.js? (enter "h" for help) [Ynaqdhm]   
       force    app/assets/config/manifest.js
    conflict    app/assets/stylesheets/application.css
<ts/application.css? (enter "h" for help) [Ynaqdhm]   
       force    app/assets/stylesheets/application.css
./ci_retry_bundle_install.sh 2>&1
Starting bundle install using shared bundle path
[DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local path '/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/../bundle'`, and stop using this flag
Your Gemfile lists the gem sqlite3 (~> 1.4) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
`/homeless-shelter` is not a directory.
Bundler will use `/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/bundler20230317-87-w9w31q87' as your home directory temporarily.
Could not reach host index.rubygems.org. Check your network connection and try
again.
rake aborted!
Command failed with status (17): [./ci_retry_bundle_install.sh 2>&1...]
/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/Rakefile:39:in `block (3 levels) in <top (required)>'
/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/Rakefile:73:in `block (2 levels) in in_example_app'
/gnu/store/r2i29lm86yj10q5f99ivgr2pc7jm9s4i-bundler-2.4.8/lib/ruby/vendor_ruby/gems/bundler-2.4.8/lib/bundler.rb:401:in `block in with_original_env'
/gnu/store/r2i29lm86yj10q5f99ivgr2pc7jm9s4i-bundler-2.4.8/lib/ruby/vendor_ruby/gems/bundler-2.4.8/lib/bundler.rb:664:in `with_env'
/gnu/store/r2i29lm86yj10q5f99ivgr2pc7jm9s4i-bundler-2.4.8/lib/ruby/vendor_ruby/gems/bundler-2.4.8/lib/bundler.rb:401:in `with_original_env'
/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/Rakefile:70:in `block in in_example_app'
/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/Rakefile:69:in `chdir'
/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/Rakefile:69:in `in_example_app'
/tmp/guix-build-ruby-rspec-rails-6.0.1.drv-0/source/Rakefile:38:in `block (2 levels) in <top (required)>'
/gnu/store/l7a6068vvi424q2rkf9f6yn9mych39sf-ruby-rake-13.0.6/lib/ruby/vendor_ruby/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Tasks: TOP => default => acceptance => smoke:app => generate:app
(See full trace by running task with --trace)
error: in phase 'check': uncaught exception:
%exception #<&invoke-error program: "rake" arguments: ("default") exit-status: 1 term-signal: #f stop-signal: #f> 
phase `check' failed after 5.0 seconds
command "rake" "default" failed with status 1
builder for `/gnu/store/11mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv' failed with exit code 1
@ build-failed /gnu/store/11mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv - 1 builder for `/gnu/store/11mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv' failed with exit code 1
derivation '/gnu/store/11mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv' offloaded to 'localhost' failed: build of `/gnu/store/11mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv' failed
build of /gnu/store/11mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv failed
View build log at '/var/log/guix/drvs/11/mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv'.
guix build: error: build of `/gnu/store/11mnywjsjhycg5a4bd33npjikmak04yq-ruby-rspec-rails-6.0.1.drv' failed

Thanks for your consideration!

The issue provided is bundler not being able to install gems, the rspec-rails test suite is dependent on being able to generate rails apps to test things insitu, but if you were able to get bundler to install from a local cache that would alleviate your difficulty.

I'm going to close this as "not planned" as its not something I feel we can dedicate the time to, but if you find something actionable for us to do to allow you to install gems from a cache of other package store (I"m assuming guix is what youre trying to use here) I'll happily review a PR.

OK; It's hard for me to suggest something because I have zero experience with Rails applications, but if I revisit the question in more depth I'll remember to do so. Thanks!