1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
require 'pathname'
require 'rspec/its'
require 'timeout'
require 'unparser'
require 'yaml'
require 'parser/current'
RSpec.configuration.around(file_path: %r{spec/unit}) do |example|
Timeout.timeout(5, &example)
end
RSpec.shared_examples_for 'a command method' do
it 'returns self' do
should equal(object)
end
end
RSpec.shared_examples_for 'an idempotent method' do
it 'is idempotent' do
first = subject
fail 'RSpec not configured for threadsafety' unless RSpec.configuration.threadsafe?
mutex = __memoized.instance_variable_get(:@mutex)
memoized = __memoized.instance_variable_get(:@memoized)
mutex.synchronize { memoized.delete(:subject) }
should equal(first)
end
end
module SpecHelper
def s(type, *children)
Parser::AST::Node.new(type, children)
end
def right(value)
Unparser::Either::Right.new(value)
end
def left(value)
Unparser::Either::Left.new(value)
end
end
RSpec.configure do |config|
config.include(SpecHelper)
config.extend(SpecHelper)
config.raise_errors_for_deprecations!
end
|