Skip to content

Commit

Permalink
Merge pull request #97 from belousovAV/fix-spec
Browse files Browse the repository at this point in the history
Fix spec
  • Loading branch information
rous-gg authored Jan 25, 2024
2 parents 6603bbb + a8fd713 commit 94c1200
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
}

it {
expect { mapper.serialize({ bool: 'true' }) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean, got `\"true\"`")
expect { mapper.serialize({ bool: 'true' }) }.to raise_error(ReeMapper::TypeError, /`bool` should be a boolean, got `\"true\"`/)
}

it {
expect { mapper.serialize({ bool: 1 }) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean, got `1`")
expect { mapper.serialize({ bool: 1 }) }.to raise_error(ReeMapper::TypeError, /`bool` should be a boolean, got `1`/)
}
end

Expand Down Expand Up @@ -81,12 +81,12 @@
}

it {
expect { mapper.cast({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean, got `\"right\"`")
expect { mapper.cast({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError, /`bool` is invalid boolean, got `\"right\"`/)
}

it {
object = Object.new
expect { mapper.cast({ 'bool' => object }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean, got `#{object.inspect}`")
expect { mapper.cast({ 'bool' => object }) }.to raise_error(ReeMapper::CoercionError, /`bool` is invalid boolean, got `#{object.inspect}`/)
}
end

Expand All @@ -100,11 +100,11 @@
}

it {
expect { mapper.db_dump(OpenStruct.new({ bool: 'true' })) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean, got `\"true\"`")
expect { mapper.db_dump(OpenStruct.new({ bool: 'true' })) }.to raise_error(ReeMapper::TypeError, /`bool` should be a boolean, got `\"true\"`/)
}

it {
expect { mapper.db_dump(OpenStruct.new({ bool: 1 })) }.to raise_error(ReeMapper::TypeError, "`bool` should be a boolean, got `1`")
expect { mapper.db_dump(OpenStruct.new({ bool: 1 })) }.to raise_error(ReeMapper::TypeError, /`bool` should be a boolean, got `1`/)
}
end

Expand Down Expand Up @@ -150,12 +150,12 @@
}

it {
expect { mapper.db_load({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean, got `\"right\"`")
expect { mapper.db_load({ 'bool' => 'right' }) }.to raise_error(ReeMapper::CoercionError, /`bool` is invalid boolean, got `\"right\"`/)
}

it {
object = Object.new
expect { mapper.db_load({ 'bool' => object }) }.to raise_error(ReeMapper::CoercionError, "`bool` is invalid boolean, got `#{object.inspect}`")
expect { mapper.db_load({ 'bool' => object }) }.to raise_error(ReeMapper::CoercionError, /`bool` is invalid boolean, got `#{object.inspect}`/)
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@
}

it {
expect { mapper.serialize({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `#{DateTime.new(2020).inspect}`")
expect { mapper.serialize({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `#{Regexp.quote(DateTime.new(2020).inspect)}`/)
}

it {
expect { mapper.serialize({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `#{Time.new(2020).inspect}`")
expect { mapper.serialize({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `#{Regexp.quote(Time.new(2020).inspect)}`/)
}

it {
expect { mapper.serialize({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `\"2020-01-01\"`")
expect { mapper.serialize({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `\"2020-01-01\"`/)
}

it {
object = Object.new
expect { mapper.serialize({ date: object }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `#{object.inspect}`")
expect { mapper.serialize({ date: object }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `#{object.inspect}`/)
}
end

Expand All @@ -62,7 +62,7 @@
}

it {
expect { mapper.cast({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError, "`date` is invalid date, got `\"no date\"`")
expect { mapper.cast({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError, /`date` is invalid date, got `\"no date\"`/)
}
end

Expand All @@ -84,7 +84,7 @@
}

it {
expect { mapper.db_load({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError, "`date` is invalid date, got `\"no date\"`")
expect { mapper.db_load({ 'date' => 'no date' }) }.to raise_error(ReeMapper::CoercionError, /`date` is invalid date, got `\"no date\"`/)
}
end

Expand All @@ -94,20 +94,20 @@
}

it {
expect { mapper.db_dump OpenStruct.new({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `#{DateTime.new(2020).inspect}`")
expect { mapper.db_dump OpenStruct.new({ date: DateTime.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `#{Regexp.quote(DateTime.new(2020).inspect)}`/)
}

it {
expect { mapper.db_dump OpenStruct.new({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `#{Time.new(2020).inspect}`")
expect { mapper.db_dump OpenStruct.new({ date: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `#{Regexp.quote(Time.new(2020).inspect)}`/)
}

it {
expect { mapper.db_dump OpenStruct.new({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `\"2020-01-01\"`")
expect { mapper.db_dump OpenStruct.new({ date: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `\"2020-01-01\"`/)
}

it {
object = Object.new
expect { mapper.db_dump OpenStruct.new({ date: object }) }.to raise_error(ReeMapper::TypeError, "`date` should be a date, got `#{object.inspect}`")
expect { mapper.db_dump OpenStruct.new({ date: object }) }.to raise_error(ReeMapper::TypeError, /`date` should be a date, got `#{object.inspect}`/)
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@
}

it {
expect { mapper.serialize({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Time.new(2020).inspect}`")
expect { mapper.serialize({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{Regexp.quote(Time.new(2020).inspect)}`/)
}

it {
expect { mapper.serialize({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
expect { mapper.serialize({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{Regexp.quote(Date.new(2020).inspect)}`/)
}

it {
expect { mapper.serialize({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"#{DateTime.new(2020).to_s}\"`")
expect { mapper.serialize({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `\"#{Regexp.quote(DateTime.new(2020).to_s)}\"`/)
}

it {
expect { mapper.serialize({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"2020-01-01\"`")
expect { mapper.serialize({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `\"2020-01-01\"`/)
}

it {
object = Object.new
expect { mapper.serialize({ date_time: object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
expect { mapper.serialize({ date_time: object }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{object.inspect}`/)
}
end

Expand All @@ -66,16 +66,16 @@
}

it {
expect { mapper.cast({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
expect { mapper.cast({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{Regexp.quote(Date.new(2020).inspect)}`/)
}

it {
object = Object.new
expect { mapper.cast({ 'date_time' => object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
expect { mapper.cast({ 'date_time' => object }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{object.inspect}`/)
}

it {
expect { mapper.cast({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime, got `\"no date time\"`")
expect { mapper.cast({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, /`date_time` is invalid datetime, got `\"no date time\"`/)
}
end

Expand All @@ -85,24 +85,24 @@
}

it {
expect { mapper.db_dump OpenStruct.new({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Time.new(2020).inspect}`")
expect { mapper.db_dump OpenStruct.new({ date_time: Time.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{Regexp.quote(Time.new(2020).inspect)}`/)
}

it {
expect { mapper.db_dump OpenStruct.new({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
expect { mapper.db_dump OpenStruct.new({ date_time: Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{Regexp.quote(Date.new(2020).inspect)}`/)
}

it {
expect { mapper.db_dump OpenStruct.new({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"#{DateTime.new(2020).to_s}\"`")
expect { mapper.db_dump OpenStruct.new({ date_time: DateTime.new(2020).to_s }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `\"#{Regexp.quote(DateTime.new(2020).to_s)}\"`/)
}

it {
expect { mapper.db_dump OpenStruct.new({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `\"2020-01-01\"`")
expect { mapper.db_dump OpenStruct.new({ date_time: '2020-01-01' }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `\"2020-01-01\"`/)
}

it {
object = Object.new
expect { mapper.db_dump OpenStruct.new({ date_time: object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
expect { mapper.db_dump OpenStruct.new({ date_time: object }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{object.inspect}`/)
}
end

Expand All @@ -124,16 +124,16 @@
}

it {
expect { mapper.db_load({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{Date.new(2020).inspect}`")
expect { mapper.db_load({ 'date_time' => Date.new(2020) }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{Regexp.quote(Date.new(2020).inspect)}`/)
}

it {
object = Object.new
expect { mapper.db_load({ 'date_time' => object }) }.to raise_error(ReeMapper::TypeError, "`date_time` should be a datetime, got `#{object.inspect}`")
expect { mapper.db_load({ 'date_time' => object }) }.to raise_error(ReeMapper::TypeError, /`date_time` should be a datetime, got `#{object.inspect}`/)
}

it {
expect { mapper.db_load({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, "`date_time` is invalid datetime, got `\"no date time\"`")
expect { mapper.db_load({ 'date_time' => 'no date time' }) }.to raise_error(ReeMapper::CoercionError, /`date_time` is invalid datetime, got `\"no date time\"`/)
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
}

it {
expect { mapper.cast({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"a1.1"`')
expect { mapper.cast({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, /`float` is invalid float, got `"a1.1"`/)
}

it {
expect { mapper.cast({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"1.1a"`')
expect { mapper.cast({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, /`float` is invalid float, got `"1.1a"`/)
}

it {
object = Object.new
expect { mapper.cast({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
expect { mapper.cast({ float: object }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `#{object.inspect}`/)
}
end

Expand All @@ -59,16 +59,16 @@
}

it {
expect { mapper.serialize({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `\"1.1\"`")
expect { mapper.serialize({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `\"1.1\"`/)
}

it {
expect { mapper.serialize({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `nil`")
expect { mapper.serialize({ float: nil }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `nil`/)
}

it {
object = Object.new
expect { mapper.serialize({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
expect { mapper.serialize({ float: object }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `#{object.inspect}`/)
}
end

Expand All @@ -78,16 +78,16 @@
}

it {
expect { mapper.db_dump({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `\"1.1\"`")
expect { mapper.db_dump({ float: '1.1' }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `\"1.1\"`/)
}

it {
expect { mapper.db_dump({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `nil`")
expect { mapper.db_dump({ float: nil }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `nil`/)
}

it {
object = Object.new
expect { mapper.db_dump({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
expect { mapper.db_dump({ float: object }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `#{object.inspect}`/)
}
end

Expand All @@ -109,20 +109,20 @@
}

it {
expect { mapper.db_load({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"a1.1"`')
expect { mapper.db_load({ float: 'a1.1' }) }.to raise_error(ReeMapper::CoercionError, /`float` is invalid float, got `"a1.1"`/)
}

it {
expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, '`float` is invalid float, got `"1.1a"`')
expect { mapper.db_load({ float: '1.1a' }) }.to raise_error(ReeMapper::CoercionError, /`float` is invalid float, got `"1.1a"`/)
}

it {
expect { mapper.db_load({ float: nil }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `nil`")
expect { mapper.db_load({ float: nil }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `nil`/)
}

it {
object = Object.new
expect { mapper.db_load({ float: object }) }.to raise_error(ReeMapper::TypeError, "`float` should be a float, got `#{object.inspect}`")
expect { mapper.db_load({ float: object }) }.to raise_error(ReeMapper::TypeError, /`float` should be a float, got `#{object.inspect}`/)
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
}

it {
expect { mapper.cast({ point: 1 }) }.to raise_error(ReeMapper::TypeError, 'Missing required field `x` for `point`')
expect { mapper.cast({ point: 1 }) }.to raise_error(ReeMapper::TypeError, /Missing required field `x` for `point`/)
}

it {
expect { mapper.cast({ point: { x: 1, y: 'not integer' } }) }.to raise_error(ReeMapper::CoercionError, '`point[y]` is invalid integer, got `"not integer"`')
expect { mapper.cast({ point: { x: 1, y: 'not integer' } }) }.to raise_error(ReeMapper::CoercionError, /`point\[y\]` is invalid integer, got `"not integer"`/)
}
end

Expand Down
Loading

0 comments on commit 94c1200

Please sign in to comment.