Created
July 11, 2016 16:24
-
-
Save coryodaniel/48eef52a17f8024759d48e2724cff0ab to your computer and use it in GitHub Desktop.
Run Apiary / Dredd using capybara, simplecov, factory girl and database cleaner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# instead of having dredd start up an endpoint, this will boot your endpoint up | |
# using capybara so that we can take advantage or ruby testing tools like FactoryGirl, DatabaseCleaner and SimpleCov | |
include DreddHooks::Methods | |
ENV["RAILS_ENV"] = "test" | |
require "rubygems" | |
require "bundler/setup" | |
unless ENV["SKIP_COVERAGE"] | |
require "simplecov" | |
SimpleCov.command_name "Dredd" | |
SimpleCov.at_exit do | |
@exit_status = 0 | |
SimpleCov.result.format! | |
end | |
SimpleCov.start "my_profile" | |
end | |
require ::File.expand_path("../../../config/environment", __FILE__) | |
# Jose Valim's shared connection -> https://gist.github.com/josevalim/470808 | |
require ::File.expand_path("../../../spec/support/config/shared_connection", __FILE__) | |
ActiveRecord::Migration.maintain_test_schema! | |
require "capybara" | |
Capybara.server_port = 61_322 # dredd endpoint port | |
Capybara::Server.new(Rails.application).boot | |
before_all do | |
DatabaseCleaner.strategy = :truncation | |
DatabaseCleaner.clean_with :truncation, except: %w(ar_internal_metadata) | |
DatabaseCleaner.strategy = :transaction | |
end | |
before_each do | |
DatabaseCleaner.start | |
end | |
after_each do | |
DatabaseCleaner.clean | |
end | |
after_all do | |
DatabaseCleaner.clean | |
end | |
# Break up hook files by resource in subfolders for sanity. | |
Dir["./blueprints/hooks/**/**_hooks.rb"].each { |file| require file } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi there, how about the hookfiles option in
dredd.yml
?