spec/form_spec.rb in rasti-form-3.1.1 vs spec/form_spec.rb in rasti-form-3.1.2
- old
+ new
@@ -38,11 +38,11 @@
point.assigned?(:y).must_equal false
end
it 'Invalid attributes' do
error = proc { point_class.new z: 3 }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- z: [\"unexpected attribute\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- z: [\"unexpected attribute\"]"
end
describe 'Casting' do
it 'Attribute' do
@@ -84,20 +84,20 @@
attribute :boolean, Rasti::Form::Types::Boolean
attribute :number, Rasti::Form::Types::Integer
end
error = proc { form.new boolean: 'x', number: 'y' }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- boolean: [\"Invalid cast: \'x\' -> Rasti::Form::Types::Boolean\"]\n- number: [\"Invalid cast: \'y\' -> Rasti::Form::Types::Integer\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- boolean: [\"Invalid cast: \'x\' -> Rasti::Form::Types::Boolean\"]\n- number: [\"Invalid cast: \'y\' -> Rasti::Form::Types::Integer\"]"
end
it 'Invalid nested attributes' do
form = build_form do
attribute :range, Rasti::Form::Types::Form[min: Rasti::Form::Types::Integer, max: Rasti::Form::Types::Integer]
end
error = proc { form.new range: {min: 'x', max: 'y'} }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- range.min: [\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"]\n- range.max: [\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- range.min: [\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"]\n- range.max: [\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]"
end
it 'Invalid form attributes' do
range = build_form do
attribute :min, Rasti::Form::Types::Integer
@@ -107,11 +107,11 @@
form = build_form do
attribute :range, Rasti::Form::Types::Form[range]
end
error = proc { form.new range: {min: 'x', max: 'y'} }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- range.min: [\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"]\n- range.max: [\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- range.min: [\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"]\n- range.max: [\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]"
end
end
end
@@ -153,11 +153,11 @@
end
proc { form.new text: 'text' }.must_be_silent
error = proc { form.new }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- text: [\"Invalid text\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- text: [\"Invalid text\"]"
end
it 'Required' do
form = build_form do
attribute :text, Rasti::Form::Types::String
@@ -168,11 +168,11 @@
end
proc { form.new text: 'text' }.must_be_silent
error = proc { form.new }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- text: [\"not present\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- text: [\"not present\"]"
end
it 'Required when cast failed' do
form = build_form do
attribute :number, Rasti::Form::Types::Integer
@@ -183,11 +183,11 @@
end
proc { form.new number: 1 }.must_be_silent
error = proc { form.new number: 'text' }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- number: [\"Invalid cast: 'text' -> Rasti::Form::Types::Integer\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- number: [\"Invalid cast: 'text' -> Rasti::Form::Types::Integer\"]"
end
it 'Not required' do
form = build_form do
attribute :text, Rasti::Form::Types::String
@@ -198,11 +198,11 @@
end
proc { form.new }.must_be_silent
error = proc { form.new text: 'text' }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- text: [\"is present\"]\n#<Rasti::Form[text: \"text\"]>"
+ error.message.must_equal "Validation errors:\n- text: [\"is present\"]"
end
it 'Not empty string' do
form = build_form do
attribute :text, Rasti::Form::Types::String
@@ -213,11 +213,11 @@
end
proc { form.new text: 'text' }.must_be_silent
error = proc { form.new text: ' ' }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- text: [\"is empty\"]\n#<Rasti::Form[text: \" \"]>"
+ error.message.must_equal "Validation errors:\n- text: [\"is empty\"]"
end
it 'Not empty array' do
form = build_form do
attribute :array, Rasti::Form::Types::Array[Rasti::Form::Types::String]
@@ -228,11 +228,11 @@
end
proc { form.new array: ['text'] }.must_be_silent
error = proc { form.new array: [] }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- array: [\"is empty\"]\n#<Rasti::Form[array: []]>"
+ error.message.must_equal "Validation errors:\n- array: [\"is empty\"]"
end
it 'Included in values list' do
form = build_form do
attribute :text, Rasti::Form::Types::String
@@ -243,11 +243,11 @@
end
proc { form.new text: 'value_1' }.must_be_silent
error = proc { form.new text: 'xyz' }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- text: [\"not included in \'value_1\', \'value_2\'\"]\n#<Rasti::Form[text: \"xyz\"]>"
+ error.message.must_equal "Validation errors:\n- text: [\"not included in \'value_1\', \'value_2\'\"]"
end
it 'Time range' do
form = build_form do
attribute :from, Rasti::Form::Types::Time['%Y-%m-%d %H:%M:%S %Z']
@@ -262,11 +262,11 @@
to = Time.parse '2018-01-01 15:30:00'
proc { form.new from: from, to: to }.must_be_silent
error = proc { form.new from: to.to_s, to: from.to_s }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- from: [\"invalid time range\"]\n#<Rasti::Form[from: #{to}, to: #{from}]>"
+ error.message.must_equal "Validation errors:\n- from: [\"invalid time range\"]"
end
it 'Nested form' do
form = build_form do
attribute :range, Rasti::Form::Types::Form[min: Rasti::Form::Types::Integer, max: Rasti::Form::Types::Integer]
@@ -278,11 +278,11 @@
end
proc { form.new range: {min: 1, max: 2} }.must_be_silent
error = proc { form.new }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- range.min: [\"not present\"]\n- range.max: [\"not present\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- range.min: [\"not present\"]\n- range.max: [\"not present\"]"
end
it 'Nested validation' do
range = build_form do
attribute :min, Rasti::Form::Types::Integer
@@ -298,10 +298,10 @@
end
proc { form.new range: {min: 1, max: 2} }.must_be_silent
error = proc { form.new range: {min: 2, max: 1} }.must_raise Rasti::Form::ValidationError
- error.message.must_equal "Validation errors:\n- range.min: [\"Min must be less than Max\"]\n#<Rasti::Form[]>"
+ error.message.must_equal "Validation errors:\n- range.min: [\"Min must be less than Max\"]"
end
end
describe 'Comparable' do
\ No newline at end of file