mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Gracefully allow spec helper to fail on older crystal
This commit is contained in:
parent
26599a740f
commit
f592a3ed38
1 changed files with 15 additions and 9 deletions
24
src/spec.cr
24
src/spec.cr
|
@ -398,9 +398,13 @@ module DB
|
||||||
@before.call
|
@before.call
|
||||||
|
|
||||||
if options
|
if options
|
||||||
uri = URI.parse connection_string
|
{% if compare_versions(Crystal::VERSION, "1.9.0") >= 0 %}
|
||||||
uri.query_params.merge! URI::Params.parse(options)
|
uri = URI.parse connection_string
|
||||||
connection_string_with_options = uri.to_s
|
uri.query_params.merge! URI::Params.parse(options)
|
||||||
|
connection_string_with_options = uri.to_s
|
||||||
|
{% else %}
|
||||||
|
raise "Crystal 1.9.0 or greater is required to run with_db with options"
|
||||||
|
{% end %}
|
||||||
else
|
else
|
||||||
connection_string_with_options = connection_string
|
connection_string_with_options = connection_string
|
||||||
end
|
end
|
||||||
|
@ -561,14 +565,16 @@ module DB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
values.each do |prepared_statements|
|
{% if compare_versions(Crystal::VERSION, "1.9.0") >= 0 %}
|
||||||
it("#{db_it.description} (prepared_statements=#{prepared_statements})", db_it.file, db_it.line, db_it.end_line) do
|
values.each do |prepared_statements|
|
||||||
ctx.with_db "prepared_statements=#{prepared_statements}" do |db|
|
it("#{db_it.description} (prepared_statements=#{prepared_statements})", db_it.file, db_it.line, db_it.end_line) do
|
||||||
db_it.block.call db
|
ctx.with_db "prepared_statements=#{prepared_statements}" do |db|
|
||||||
nil
|
db_it.block.call db
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
{% end %}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise "Invalid prepared value. Allowed values are :both and :default"
|
raise "Invalid prepared value. Allowed values are :both and :default"
|
||||||
|
|
Loading…
Reference in a new issue