Sha256: d6abeb426c49d48e258c51927fa4fc63169ef6e9bc4092623bde4238310ef084
Contents?: true
Size: 1.79 KB
Versions: 15
Compression:
Stored size: 1.79 KB
Contents
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'active_record' # for Flydata::Heroku require 'protected_attributes' # Change FLYDATA_HOME to tempdir temp_dir_path = Dir.mktmpdir ENV['FLYDATA_HOME'] = temp_dir_path # Set dummy flydata_api_host file File.open(File.join(temp_dir_path, 'flydata_api_host'), 'w') do |f| f.write('http://0.0.0.0:3000') end require 'flydata' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| if defined? ActiveRecord # The ActiveRecord::Rollback exception will be caught by the transaction # block and roll back all the database changes after each spec. config.around do |example| if ActiveRecord::Base.connected? ActiveRecord::Base.transaction do example.run raise ActiveRecord::Rollback end end end end end # https://gist.github.com/stevenharman/2355172 RSpec::Matchers.define :terminate do |code| actual = nil def supports_block_expectations? true end match do |block| begin block.call rescue SystemExit => e actual = e.status end actual and actual == status_code end chain :with_code do |status_code| @status_code = status_code end failure_message_for_should do |block| "expected block to call exit(#{status_code}) but exit" + (actual.nil? ? " not called" : "(#{actual}) was called") end failure_message_for_should_not do |block| "expected block not to call exit(#{status_code})" end description do "expect block to call exit(#{status_code})" end def status_code @status_code ||= 0 end end
Version data entries
15 entries across 15 versions & 1 rubygems