SchemaAssertions (Schema Assertions v2.1.0)
View SourceExUnit assertions for Ecto schemas.
Examples
iex> import SchemaAssertions
iex> alias SchemaAssertions.Test.Schema
...>
iex> assert_schema Schema.House, "houses",
...> address: :text,
...> id: :bigserial
...>
iex> assert_schema Schema.House, "houses",
...> address: :text,
...> id: :id
Summary
Functions
Asserts that the given schema module has a belongs_to association.
Asserts that the given schema module has a has_many or has_many :through association.
Asserts that the given schema module has a has_one association.
Asserts that the given schema module exists and that its corresponding database table exists.
Functions
@spec assert_belongs_to( module(), atom(), module(), opts :: SchemaAssertions.Schema.belongs_to_opts() ) :: true
Asserts that the given schema module has a belongs_to association.
Example
iex> alias SchemaAssertions.Test.Schema
iex> SchemaAssertions.assert_belongs_to(Schema.Room, :house, Schema.House)
true
iex> alias SchemaAssertions.Test.Schema
iex> SchemaAssertions.assert_belongs_to(Schema.Pet, :home, Schema.House, source: :house_id)
true
Asserts that the given schema module has a has_many or has_many :through association.
Example
iex> alias SchemaAssertions.Test.Schema
iex> SchemaAssertions.assert_has_many(Schema.House, :rooms, Schema.Room)
true
iex> alias SchemaAssertions.Test.Schema
iex> SchemaAssertions.assert_has_many(Schema.House, :windows, through: [:rooms, :windows])
true
Asserts that the given schema module has a has_one association.
Example
iex> alias SchemaAssertions.Test.Schema
iex> SchemaAssertions.assert_has_one(Schema.House, :foundation, Schema.Foundation)
true
Asserts that the given schema module exists and that its corresponding database table exists.