diff options
author | Michael Herold <michael.j.herold@gmail.com> | 2017-02-03 12:09:04 -0600 |
---|---|---|
committer | Michael Herold <michael.j.herold@gmail.com> | 2017-02-03 15:20:21 -0600 |
commit | f50cf8e6bbf986556d41ca71ac4e180c33613ea1 (patch) | |
tree | 494fa558c18a98d76c1d78d143ca910d89cae59e /spec/support/integration_specs.rb | |
parent | c1a42d4fabeb09b79f43588ca3d79e1b44718cdf (diff) | |
download | hashie-f50cf8e6bbf986556d41ca71ac4e180c33613ea1.tar.gz |
Bring integration tests into main test harness
We have a nice integration spec harness, so let's make sure we use it
when we're working on the gem. I'm making the following changes:
* Make `bundle exec rake` run integration specs, except on Travis.
* Silence a warning in the OmniAuth integration spec that has nothing to
do with Hashie.
* Make Guard run integration specs when appropriate. Now, when you run
all tasks you will run integration specs. Also, if you modify an
integration spec, it will run. Lastly, if you modify anything in `lib`
the integration specs will run.
* Keeps the extra Travis build that only runs integration specs. Travis
didn't like the Rake task that included it and there's extra signal by
doing it this way anyway.
Diffstat (limited to 'spec/support/integration_specs.rb')
-rw-r--r-- | spec/support/integration_specs.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/support/integration_specs.rb b/spec/support/integration_specs.rb new file mode 100644 index 0000000..ea0da53 --- /dev/null +++ b/spec/support/integration_specs.rb @@ -0,0 +1,36 @@ +# Generates the bundle command for running an integration test +# +# @param [String] integration the integration folder to run +# @param [String] command the command to run +# @return [String] +def integration_command(integration, command) + "#{integration_gemfile(integration)} #{command}" +end + +# Generates the Gemfile for an integration +# +# @param [String] integration the integration test name +# @return [String] +def integration_gemfile(integration) + "BUNDLE_GEMFILE=#{integration_path(integration)}/Gemfile" +end + +# Generates the path to the integration +# +# @param [String] integration the integration test name +# @return [String] +def integration_path(integration) + "spec/integration/#{integration}" +end + +# Runs all integration specs in their own environment +def run_all_integration_specs(handler: ->(_code) {}, logger: ->(_msg) {}) + Dir['spec/integration/*'] + .map { |directory| directory.split('/').last } + .each do |integration| + logger.call(%(Running "#{integration}" integration spec)) + system(integration_command(integration, 'bundle --quiet')) + system(integration_command(integration, "bundle exec rspec #{integration_path(integration)}")) + handler.call($CHILD_STATUS.exitstatus) + end +end |