You can do that with pattern matching,

assert %{field1: "foo", field2: "bar"} = data

On 18 Oct 2017, 05:01 +0200, [email protected], wrote:
> I think it would be useful if =~ supported maps.  =~ would return true if the 
> key/values in the right hand map were also contained in the left-hand map.  I 
> think this would be especially useful for testing, as you could check that 
> the result matched a subset of the map, rather than the whole map.
>
> e.g.
> data = Repo.insert!(src)
> # data = %Data{id: 25, field1: "foo", field2: "bar", inserted_at: 
> ~N[2017-01-01], updated_at: ~N[2017-01-01]}
> assert data =~ %{field1: "foo", field2: "bar"}  # true
> --
> You received this message because you are subscribed to the Google Groups 
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/elixir-lang-core/7eaabb77-6c7a-4fcb-a74a-fc303f5ace26%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/a56b20c2-3336-4d99-a693-60e2468115fa%40Spark.
For more options, visit https://groups.google.com/d/optout.

Reply via email to