Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce suspenders:testing generator #1156

Merged

Commits on Mar 8, 2024

  1. Introduce suspenders:testing generator

    Generate `spec/rails_helper.rb` and `spec/spec_helper.rb` via `rails g rspec:intall`
    in an effort to not drift from what RSpec recommends out of the box.
    
    The only thing that differs from the existing `spec/rails_helper.rb` configuration is:
    
    ```ruby
    config.infer_base_class_for_anonymous_controllers = false
    ```
    
    Note that we still keep `config.fixture_path = "#{::Rails.root}/spec/fixtures"`,
    in the generated `spec/rails_helper.rb` file even though we favor
    FactoriesBotRails. This is because we can still use fixtures for things
    like file uploads.
    
    Modify `spec/spec_helper.rb` by including the following:
    
    ```ruby
    config.example_status_persistence_file_path = "tmp/rspec_examples.txt
    config.order = :random
    
    WebMock.disable_net_connect!(
      allow_localhost: true,
      allow: "chromedriver.storage.googleapis.com"
    )
    ```
    
    Introduce dependency on [webmock][], and configure RSpec and Minitest to
    use it.
    
    Calling `generate "rspec:install"` seemed to invoked the generator twice
    (at least in the test), so we rely on `rails_command "generate rspec:install"
    
    Additionally, this commit removes the [formulaic][] dependency. A
    follow-up commit could explore creating a separate one-off generator for
    this, but for now, we're aiming for the leanest build possible.
    
    [webmock]: https://github.com/bblimke/webmock
    [formulaic]: https://github.com/calebhearth/formulaic
    stevepolitodesign committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    ed625b7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9742372 View commit details
    Browse the repository at this point in the history
  3. Drop support for Minitest

    For now, drop support for Minitest to maintain existing behavior and
    continue forward momentum.
    
    A follow-up, long-term goal could be to explore how we can improve and
    extend Minitest and/or the Rails [test cases][] to better match RSpec.
    
    [test cases]: https://guides.rubyonrails.org/testing.html#a-brief-note-about-test-cases
    stevepolitodesign committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    379c63a View commit details
    Browse the repository at this point in the history
  4. Keep test directory

    Deleting a directory feels like an overstep. That should be up to the
    consumer.
    stevepolitodesign committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    0f2505e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9cb7765 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    1ad8e3e View commit details
    Browse the repository at this point in the history
  7. Allow additional Chrome hosts

    I found I needed to add these additional hosts when testing on a fresh
    Rails app.
    stevepolitodesign committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    336eeb9 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    a4c9d36 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    820c87a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    1675ea1 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    b468f32 View commit details
    Browse the repository at this point in the history
  12. Restore file

    stevepolitodesign committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    2b7c5c7 View commit details
    Browse the repository at this point in the history