spec/spec_helper.rb in keepassx-1.0.0 vs spec/spec_helper.rb in keepassx-1.1.0

- old
+ new

@@ -3,11 +3,11 @@ require 'respect' require 'factory_bot' # Start Simplecov SimpleCov.start do - add_filter '/spec/' + add_filter 'spec/' end # Configure RSpec RSpec.configure do |config| config.include FactoryBot::Syntax::Methods @@ -19,43 +19,39 @@ Kernel.srand config.seed config.expect_with :rspec do |c| c.syntax = :expect end + + # disable monkey patching + # see: https://relishapp.com/rspec/rspec-core/v/3-8/docs/configuration/zero-monkey-patching-mode + config.disable_monkey_patching! end -# Load lib -require 'keepassx' -require_relative 'factories' - -FIXTURE_PATH = File.expand_path File.join(File.dirname(__FILE__), 'fixtures') -TEST_DATABASE_PATH = File.join(FIXTURE_PATH, 'database_test.kdb') -EMPTY_DATABASE_PATH = File.join(FIXTURE_PATH, 'database_empty.kdb') -KEYFILE_DATABASE_PATH = File.join(FIXTURE_PATH, 'database_with_key.kdb') - - +# Configure/Patch Respect module RespectPatch - def self.included(base) - base.send(:prepend, InstanceMethods) + def validate_uuid(uuid) + return true if uuid =~ /\A[0-9a-f]{32}\z/i + raise Respect::ValidationError, "invalid UUID" end - - module InstanceMethods - - def validate_uuid(uuid) - return true if uuid =~ /\A[0-9a-f]{32}\z/i - raise Respect::ValidationError, "invalid UUID" - end - - end end module UUIDValidator def uuid(name, options = {}) string(name, { format: :uuid }.merge(options)) end end -unless Respect::FormatValidator.included_modules.include?(RespectPatch) - Respect::FormatValidator.send(:include, RespectPatch) -end - +Respect::FormatValidator.prepend(RespectPatch) Respect.extend_dsl_with(UUIDValidator) + +# Load factories +require_relative 'support/factories' + +# Declare some constants used during tests +FIXTURE_PATH = File.expand_path File.join(File.dirname(__FILE__), 'fixtures') +TEST_DATABASE_PATH = File.join(FIXTURE_PATH, 'database_test.kdb') +EMPTY_DATABASE_PATH = File.join(FIXTURE_PATH, 'database_empty.kdb') +KEYFILE_DATABASE_PATH = File.join(FIXTURE_PATH, 'database_with_key.kdb') + +# Load lib +require 'keepassx'