After update to v0.1.0 from v0.0.9 tests started to fail with
expect(
get_users(page: '-2')
).to eq(errors: { page: ["must be a positive number"] })
expected: {:errors=>{:page=>["must be a positive number"]}}
got: {:errors=>{:page=>"must be a positive number"}}
In the controller errors are rendered the following way:
load_users = LoadUsers.(params)
if load_users.success?
render json: load_users.result
else
render json: { errors: load_users.errors }
end
The problem is that SimpleCommand::Errors#to_json format differs from ActiveModel::Errors#to_json
# SimpleCommand::Errors
load_users = LoadUsers.new
load_users.errors.add(:page, 'must be a positive number')
load_users.errors.add(:page, 'cannot be blank')
load_users.errors.as_json
=> {"page"=>"cannot be blank"}
# ActiveModel::Errors
user = User.new
user.errors.add(:email, 'is invalid')
user.errors.add(:email, 'cannot be blank')
user.errors.as_json
=> {:email=>["is invalid", "cannot be blank"]}
It would be good to have SimpleCommand::Errors#as_json to be the same format as ActiveModel::Errors#as_json
After update to
v0.1.0fromv0.0.9tests started to fail withIn the controller errors are rendered the following way:
The problem is that
SimpleCommand::Errors#to_jsonformat differs fromActiveModel::Errors#to_jsonIt would be good to have
SimpleCommand::Errors#as_jsonto be the same format asActiveModel::Errors#as_json