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

Improve the test suite #143

Merged
merged 2 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ end
group :test do
gem 'webmock', require: false
gem 'vcr', require: false
gem 'codecov', :require => false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the arrow?

end
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ begin
desc 'Run All Suites'
RSpec::Core::RakeTask.new(:all)

task default: [:rubocop, :spec]
desc 'Run unit and integration tests'
task test: [:spec, :integration]

task default: [:rubocop, :test]
rescue LoadError
puts 'Load Error - No RSpec'
end
2 changes: 1 addition & 1 deletion build_travis.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ]; then
MODE=full bundle exec rake all
bundle exec rake all
else
bundle exec rake spec
fi
42 changes: 31 additions & 11 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
require 'pry'
require 'rack/test'
require 'faker'
require 'auth0'

require 'simplecov'
SimpleCov.start do
add_filter '/spec/'
add_filter '/spec/integration'
end

require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov if ENV['TRAVIS']

require 'dotenv'
Dotenv.load

Expand All @@ -6,6 +20,7 @@

require 'vcr'
VCR.configure do |config|
# Uncomment the line below to record new cassettes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does that mean? should it be clarified?

# config.allow_http_connections_when_no_cassette = true
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
config.configure_rspec_metadata!
Expand All @@ -14,25 +29,30 @@
config.filter_sensitive_data('API_TOKEN') { ENV['MASTER_JWT'] }
end

mode = ENV['MODE'] || 'unit'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the test mode now that we're using VCR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VCR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


$LOAD_PATH.unshift File.expand_path('..', __FILE__)
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'rspec'
require 'rack/test'
require 'faker'
require 'auth0'

Dir['./lib/**/*.rb'].each { |f| require f }
Dir['./spec/support/**/*.rb'].each { |f| require f }
Dir['./spec/support/*.rb'].each { |f| require f }

require 'rspec'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cosmetic but, shouldn't this be on the top of the file instead of flying here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no ... config.include Credentials needs to happen after the file requires

RSpec.configure do |config|
config.filter_run focus: true
config.run_all_when_everything_filtered = true
config.include Credentials
end

def wait(time, increment = 5, elapsed_time = 0, &block)
yield
rescue RSpec::Expectations::ExpectationNotMetError => e
raise e if elapsed_time >= time
sleep increment
wait(time, increment, elapsed_time + increment, &block)
end

def entity_suffix
'rubytest'
end

puts "Entity suffix is #{entity_suffix}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving test mode-specific code

puts "Running in mode #{mode}"

require_relative "spec_helper_#{mode}.rb"
puts "Entity suffix is #{entity_suffix}"
24 changes: 0 additions & 24 deletions spec/spec_helper_full.rb

This file was deleted.

3 changes: 0 additions & 3 deletions spec/spec_helper_unit.rb

This file was deleted.