summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDaniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org>2017-02-04 20:22:01 -0500
committerGitHub <noreply@github.com>2017-02-04 20:22:01 -0500
commit839f874cf920a0652d749f004c61810aa79b7d64 (patch)
treef9eca3c0785d205db3a01884a38b1b767207ca99 /spec
parent24caf3564e3073c68227590e72bf43e0a604ac68 (diff)
parentf50cf8e6bbf986556d41ca71ac4e180c33613ea1 (diff)
downloadhashie-839f874cf920a0652d749f004c61810aa79b7d64.tar.gz
Merge pull request #397 from michaelherold/improve-integration-tests
Bring integration tests into main test harness
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/omniauth/integration_spec.rb2
-rw-r--r--spec/support/integration_specs.rb36
2 files changed, 37 insertions, 1 deletions
diff --git a/spec/integration/omniauth/integration_spec.rb b/spec/integration/omniauth/integration_spec.rb
index 469dd6e..848a61b 100644
--- a/spec/integration/omniauth/integration_spec.rb
+++ b/spec/integration/omniauth/integration_spec.rb
@@ -6,7 +6,7 @@ require 'sinatra'
require 'omniauth'
class MyApplication < Sinatra::Base
- use Rack::Session::Cookie
+ use Rack::Session::Cookie, secret: 'hashie integration tests'
use OmniAuth::Strategies::Developer
get '/' do
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