hashie/hashie

Move integration tests to use inline Gemfiles

michaelherold opened this issue · 4 comments

Our integration tests currently use an external Gemfile to the test. This means that in order to onboard into contributing, you have to go through the tedious process of running bundle install within each of the integration tests' folders.

It would be great to move the Bundler configuration into using bundler/inline, like the Rails bug report templates to make them more reliable and easier to start using.

While we're at it, we could reorganize the integration specs to be single files instead of the spec/integration/<name>/integration_spec.rb pattern.

For example: spec/integration/elasticsearch/integration_spec.rb could become spec/integration/elasticsearch_spec.rb

Hi, I am interested to contribute towards this.
I am reading about how we can use bundler inline
While I was setting up my dev environment, when I ran bundle exec rake, I was greeted with the much anticipated integration test failure messages, I got to know, what I am going to fix.

What I'm looking for here is a simplification of our integration test setup. The implementation is a suggestion: if there's a different way you want to go about attempting it, that would be fine too.

Ideally, the variables I would like to optimize for are:

  1. It's easy to write a new integration test.
  2. It's easy to run integration tests locally.

I think that inline bundles will help with both of those, but there could be a different way to solve the problem.

I read the Rakefile (in the root directory) and figured out how the initial setup works, when bundle exec rake is run for the first time.
I edited one of the integration tests to include an inline gemfile.
The expected behavior I suppose is that after running rspec integration_spec.rb first the required gems are installed followed by rest of the code.
I have no success as of now.

@michaelherold
I tried the inline Gemfile approach.
It some how worked for elasticsearch/integration_ spec.rb. The presence of only the integration_spec.rb ensured that I wrote only the code for inline gem file once.

Other integration spec directories had multiple files, thus the point of eliminating the Gemfile in these directory meant writing gem requirements of each of these files at the beginning and thus doesn't looked much promising to me as writing new integration specs in future would require this to be done every time and I think is cumbersome.

I decided not to follow this.
Instead Rake itself can be used to run bundle install inside each of integration spec directories.
I am reading about Rake for a few days and turns out that it is quite powerful.

The task :integration_specs can have a prerequisite task, which runs bundle install inside each of the directories (using Bundler.with_clean_env { `bundle install` }). When this prerequisite task completes then only integration specs are evaluated.
Running bundle install creates Gemfile.lock in each directory. We put a rule on Gemfile.lock that if it doesn't exists, then only the prerequisite task runs, otherwise it continues to evaluate the specs.

What are your thoughts?