View Source SchemaAssertions (Schema Assertions v0.4.2)
ExUnit 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
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
Link to this function
assert_has_many(schema_module, association, association_module_or_opts)
View SourceAsserts 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
Link to this function
assert_has_one(schema_module, association, association_module_or_opts)
View SourceAsserts 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.