caxlsx / caxlsx_rails

A Rails plugin to provide templates for the axlsx gem
MIT License
735 stars 84 forks source link

Cleanup tests #164

Closed kiskoza closed 1 year ago

kiskoza commented 1 year ago

Hi. I was working on #163 and as I mentioned there, it was a bit difficult for me to get familiar with the test suite, so I started to move things around and in the end I got these changes running. I know it's a lot, so I'll try to get a list of what I've done:

  1. Merge all dummy apps They were almost the same apps, I only had to insert a few version checks, e.g.: spec/rails_app/app/controllers/users_controller.rb. This way we have less code to maintain and easier to add a new spec for all versions.

    1. Create a few gemfiles This way you can run BUNDLE_GEMFILE=spec/gemfiles/Gemfile.rails-X.Y bundle install to install the gems and BUNDLE_GEMFILE=spec/gemfiles/Gemfile.rails-X.Y bundle exec rspec to run the specs. I think it's easier to delete and old version when we don't support it anymore. Not sure if we need to add something to the Readme about this.
  2. Update github actions to pick up all versions I had to define the bundler version for Rails 4.2 and exclude a few combunations, e.g. Rails 7 does not support older Ruby versions. Other than that we're running the full matrix.

  3. Fix tests for Rails 6.1 & 7.0 In lib/axlsx_rails/railtie.rb we required the template handler only after action_view already loaded, which does not happen in the rspec for some reason. I simply moved the require line out from the on_load block. As it's just a simple plain old ruby class, it shouldn't do any harm - apart from loading the action_view unnecessarily... it was only required to have the template handler in ActionView's namespace (which we shouldn't do, all the gem codes should live under the gem's namespace anyways), so I also renamed the template handler and removed the inclusion of action_view

  4. Delete all the .sh files as we don't need them anymore

I hope this all makes sense and we can merge it in to make this gem more maintainable

straydogstudio commented 1 year ago

@kiskoza Thanks for all the work. This is great. It's just the kind of thing I was hoping to do at some point.