@@ -1317,15 +1317,15 @@ defmodule Ecto.ChangesetTest do
13171317
13181318 assert changeset . valid?
13191319 assert changeset . errors == [ ]
1320- assert validations ( changeset ) == [ title: { :format , ~r / @ / } ]
1320+ assert match? ( [ title: { :format , % Regex { source: "@" } } ] , validations ( changeset ) )
13211321
13221322 changeset =
13231323 changeset ( % { "title" => "foobar" } )
13241324 |> validate_format ( :title , ~r/ @/ )
13251325
13261326 refute changeset . valid?
13271327 assert changeset . errors == [ title: { "has invalid format" , [ validation: :format ] } ]
1328- assert validations ( changeset ) == [ title: { :format , ~r / @ / } ]
1328+ assert match? ( [ title: { :format , % Regex { source: "@" } } ] , validations ( changeset ) )
13291329
13301330 changeset =
13311331 changeset ( % { "title" => "foobar" } )
@@ -2681,17 +2681,19 @@ defmodule Ecto.ChangesetTest do
26812681 message: "cannot be more than 15 characters"
26822682 )
26832683
2684- assert constraints ( changeset ) ==
2684+ assert match? (
26852685 [
26862686 % {
26872687 type: :check ,
26882688 field: :title ,
2689- constraint: ~r / title_must_be_short\d + / ,
2689+ constraint: % Regex { source: " title_must_be_short\\ d+" } ,
26902690 match: :exact ,
26912691 error_message: "cannot be more than 15 characters" ,
26922692 error_type: :check
26932693 }
2694- ]
2694+ ] ,
2695+ constraints ( changeset )
2696+ )
26952697
26962698 assert_raise ArgumentError , ~r/ invalid match type: :invalid/ , fn ->
26972699 change ( % Post { } )
@@ -2769,17 +2771,19 @@ defmodule Ecto.ChangesetTest do
27692771 changeset =
27702772 change ( % Post { } ) |> unique_constraint ( :title , name: ~r/ whatever\d +/ , message: "is taken" )
27712773
2772- assert constraints ( changeset ) ==
2774+ assert match? (
27732775 [
27742776 % {
27752777 type: :unique ,
27762778 field: :title ,
2777- constraint: ~r / whatever\d + / ,
2779+ constraint: % Regex { source: " whatever\\ d+" } ,
27782780 match: :exact ,
27792781 error_message: "is taken" ,
27802782 error_type: :unique
27812783 }
2782- ]
2784+ ] ,
2785+ constraints ( changeset )
2786+ )
27832787
27842788 assert_raise ArgumentError , ~r/ invalid match type: :invalid/ , fn ->
27852789 change ( % Post { } )
@@ -2836,17 +2840,19 @@ defmodule Ecto.ChangesetTest do
28362840 changeset =
28372841 change ( % Post { } ) |> unique_constraint ( :permalink , name: ~r/ whatever\d +/ , message: "is taken" )
28382842
2839- assert constraints ( changeset ) ==
2843+ assert match? (
28402844 [
28412845 % {
28422846 type: :unique ,
28432847 field: :permalink ,
2844- constraint: ~r / whatever\d + / ,
2848+ constraint: % Regex { source: " whatever\\ d+" } ,
28452849 match: :exact ,
28462850 error_message: "is taken" ,
28472851 error_type: :unique
28482852 }
2849- ]
2853+ ] ,
2854+ constraints ( changeset )
2855+ )
28502856
28512857 assert_raise ArgumentError , ~r/ invalid match type: :invalid/ , fn ->
28522858 change ( % Post { } )
@@ -2979,17 +2985,19 @@ defmodule Ecto.ChangesetTest do
29792985 change ( % Comment { } )
29802986 |> foreign_key_constraint ( :post , name: ~r/ whatever\d +/ , message: "is not available" )
29812987
2982- assert constraints ( changeset ) ==
2988+ assert match? (
29832989 [
29842990 % {
29852991 type: :foreign_key ,
29862992 field: :post ,
2987- constraint: ~r / whatever\d + / ,
2993+ constraint: % Regex { source: " whatever\\ d+" } ,
29882994 match: :exact ,
29892995 error_message: "is not available" ,
29902996 error_type: :foreign
29912997 }
2992- ]
2998+ ] ,
2999+ constraints ( changeset )
3000+ )
29933001
29943002 assert_raise ArgumentError , ~r/ invalid match type: :invalid/ , fn ->
29953003 change ( % Comment { } )
@@ -3100,17 +3108,19 @@ defmodule Ecto.ChangesetTest do
31003108 change ( % Comment { } )
31013109 |> assoc_constraint ( :post , name: ~r/ whatever\d +/ , message: "is not available" )
31023110
3103- assert constraints ( changeset ) ==
3111+ assert match? (
31043112 [
31053113 % {
31063114 type: :foreign_key ,
31073115 field: :post ,
3108- constraint: ~r / whatever\d + / ,
3116+ constraint: % Regex { source: " whatever\\ d+" } ,
31093117 match: :exact ,
31103118 error_message: "is not available" ,
31113119 error_type: :assoc
31123120 }
3113- ]
3121+ ] ,
3122+ constraints ( changeset )
3123+ )
31143124
31153125 assert_raise ArgumentError , ~r/ invalid match type: :invalid/ , fn ->
31163126 change ( % Comment { } )
@@ -3229,17 +3239,19 @@ defmodule Ecto.ChangesetTest do
32293239 change ( % Post { } )
32303240 |> no_assoc_constraint ( :comments , name: ~r/ comments_post_id_fkey\d +/ , message: "exists" )
32313241
3232- assert constraints ( changeset ) ==
3242+ assert match? (
32333243 [
32343244 % {
32353245 type: :foreign_key ,
32363246 field: :comments ,
3237- constraint: ~r / comments_post_id_fkey\d + / ,
3247+ constraint: % Regex { source: " comments_post_id_fkey\\ d+" } ,
32383248 match: :exact ,
32393249 error_message: "exists" ,
32403250 error_type: :no_assoc
32413251 }
3242- ]
3252+ ] ,
3253+ constraints ( changeset )
3254+ )
32433255
32443256 assert_raise ArgumentError , ~r/ invalid match type: :invalid/ , fn ->
32453257 change ( % Post { } )
@@ -3409,17 +3421,19 @@ defmodule Ecto.ChangesetTest do
34093421 change ( % Post { } )
34103422 |> exclusion_constraint ( :title , name: ~r/ whatever\d +/ , message: "is invalid" )
34113423
3412- assert constraints ( changeset ) ==
3424+ assert match? (
34133425 [
34143426 % {
34153427 type: :exclusion ,
34163428 field: :title ,
3417- constraint: ~r / whatever\d + / ,
3429+ constraint: % Regex { source: " whatever\\ d+" } ,
34183430 match: :exact ,
34193431 error_message: "is invalid" ,
34203432 error_type: :exclusion
34213433 }
3422- ]
3434+ ] ,
3435+ constraints ( changeset )
3436+ )
34233437
34243438 assert_raise ArgumentError , ~r/ invalid match type: :invalid/ , fn ->
34253439 change ( % Post { } )
0 commit comments