-
Notifications
You must be signed in to change notification settings - Fork 9
Configuring Vigia
David edited this page Mar 21, 2015
·
2 revisions
Vigia tries to be flexible enough in case that you need to run custom operations during the tests.
Vigia.configure do |config|
# Define your source file. For example, within a Rails app
config.source_file = "#{ Rails.root }/apibs/my_api.apib"
# Define the host address where the request will be performed.
config.host = 'http://localhost:3000'
# Include a collection of custom headers in all the requests.
config.headers = { authorization: 'Bearer <your hash here>' }
# Reset rspec_config and set up documentation formatter
config.rspec_config do |rspec_config|
rspec_config.reset
rspec_config.formatter = RSpec::Core::Formatters::DocumentationFormatter
end
# Attach a before_context hook to set up the database using Databasecleaner
config.before_context do
DatabaseCleaner.start
end
# Set a timer on the primary group and raise an exception if the
# described group takes more than 5 seconds to run
config.before_group do
let!(:group_started_at) { Time.now } if described_class.options[:primary]
end
config.after_group do
if described_class.options[:primary]
it 'has taken less than 5 seconds to run this example' do
expect(Time.now.to_i - group_started_at.to_i).to be < 5
end
end
end
end
Vigia.rspec!
For more information about config, see the Vigia::Config
class.