spec/form_spec.rb in rasti-form-1.0.1 vs spec/form_spec.rb in rasti-form-1.0.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 error: {"z":["unexpected attribute"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[]> {"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 error: {"boolean":["Invalid cast: \'x\' -> Rasti::Form::Types::Boolean"],"number":["Invalid cast: \'y\' -> Rasti::Form::Types::Integer"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[]> {"boolean":["Invalid cast: \'x\' -> Rasti::Form::Types::Boolean"],"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 error: {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"range.max\":[\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]}" + error.message.must_equal "Validation error: #<Rasti::Form[]> {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"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 error: {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"range.max\":[\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]}" + error.message.must_equal "Validation error: #<Rasti::Form[]> {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"range.max\":[\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]}" end end end @@ -149,11 +149,11 @@ assert_present :text end end error = proc { form.new }.must_raise Rasti::Form::ValidationError - error.message.must_equal 'Validation error: {"text":["not present"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[]> {"text":["not present"]}' end it 'Not empty string' do form = build_form do attribute :text, Rasti::Form::Types::String @@ -162,11 +162,11 @@ assert_not_empty :text end end error = proc { form.new text: ' ' }.must_raise Rasti::Form::ValidationError - error.message.must_equal 'Validation error: {"text":["is empty"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[text: " "]> {"text":["is empty"]}' end it 'Not empty array' do form = build_form do attribute :array, Rasti::Form::Types::Array[Rasti::Form::Types::String] @@ -175,11 +175,11 @@ assert_not_empty :array end end error = proc { form.new array: [] }.must_raise Rasti::Form::ValidationError - error.message.must_equal 'Validation error: {"array":["is empty"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[array: []]> {"array":["is empty"]}' end it 'Included in values list' do form = build_form do attribute :text, Rasti::Form::Types::String @@ -188,11 +188,11 @@ assert_included_in :text, %w(value_1 value_2) end end error = proc { form.new text: 'xyz' }.must_raise Rasti::Form::ValidationError - error.message.must_equal 'Validation error: {"text":["not included in \'value_1\', \'value_2\'"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[text: "xyz"]> {"text":["not included in \'value_1\', \'value_2\'"]}' 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] @@ -202,11 +202,11 @@ assert_present 'range.max' end end error = proc { form.new }.must_raise Rasti::Form::ValidationError - error.message.must_equal 'Validation error: {"range.min":["not present"],"range.max":["not present"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[]> {"range.min":["not present"],"range.max":["not present"]}' end it 'Nested validation' do range = build_form do attribute :min, Rasti::Form::Types::Integer @@ -220,10 +220,10 @@ form = build_form do attribute :range, Rasti::Form::Types::Form[range] end error = proc { form.new range: {min: 2, max: 1} }.must_raise Rasti::Form::ValidationError - error.message.must_equal 'Validation error: {"range.min":["Min must be less than Max"]}' + error.message.must_equal 'Validation error: #<Rasti::Form[]> {"range.min":["Min must be less than Max"]}' end end describe 'Comparable' do \ No newline at end of file