Merged branch ci-format-check into master

This commit is contained in:
Brian J. Cardiff 2016-09-06 13:26:33 -03:00
commit 4ddaf9df53
4 changed files with 13 additions and 16 deletions

View file

@ -1 +1,4 @@
language: crystal language: crystal
script:
- crystal spec
- crystal tool format --check

View file

@ -4,40 +4,39 @@ require "base64"
class SimpleMapping class SimpleMapping
DB.mapping({ DB.mapping({
c0: Int32, c0: Int32,
c1: String c1: String,
}) })
end end
class NonStrictMapping class NonStrictMapping
DB.mapping({ DB.mapping({
c1: Int32, c1: Int32,
c2: String c2: String,
}, strict: false) }, strict: false)
end end
class MappingWithDefaults class MappingWithDefaults
DB.mapping({ DB.mapping({
c0: { type: Int32, default: 10 }, c0: {type: Int32, default: 10},
c1: { type: String, default: "c" }, c1: {type: String, default: "c"},
}) })
end end
class MappingWithNilables class MappingWithNilables
DB.mapping({ DB.mapping({
c0: { type: Int32, nilable: true, default: 10 }, c0: {type: Int32, nilable: true, default: 10},
c1: { type: String, nilable: true }, c1: {type: String, nilable: true},
}) })
end end
class MappingWithKeys class MappingWithKeys
DB.mapping({ DB.mapping({
foo: { type: Int32, key: "c0" }, foo: {type: Int32, key: "c0"},
bar: { type: String, key: "c1" }, bar: {type: String, key: "c1"},
}) })
end end
class MappingWithConverter class MappingWithConverter
module Base64Converter module Base64Converter
def self.from_rs(rs) def self.from_rs(rs)
Base64.decode(rs.read(String)) Base64.decode(rs.read(String))
@ -45,8 +44,8 @@ class MappingWithConverter
end end
DB.mapping({ DB.mapping({
c0: { type: Slice(UInt8), converter: MappingWithConverter::Base64Converter }, c0: {type: Slice(UInt8), converter: MappingWithConverter::Base64Converter},
c1: { type: String }, c1: {type: String},
}) })
end end
@ -69,7 +68,6 @@ macro expect_mapping(query, t, values)
end end
describe "DB.mapping" do describe "DB.mapping" do
it "should initialize a simple mapping" do it "should initialize a simple mapping" do
expect_mapping("1,a", SimpleMapping, {c0: 1, c1: "a"}) expect_mapping("1,a", SimpleMapping, {c0: 1, c1: "a"})
end end
@ -149,5 +147,4 @@ describe "DB.mapping" do
objs[1].c1.should eq("b") objs[1].c1.should eq("b")
end end
end end
end end

View file

@ -1,9 +1,7 @@
module DB module DB
class Error < Exception class Error < Exception
end end
class MappingException < Exception class MappingException < Exception
end end
end end

View file

@ -1,5 +1,4 @@
module DB module DB
# Empty module used for marking a class as supporting DB:Mapping # Empty module used for marking a class as supporting DB:Mapping
module Mappable; end module Mappable; end