Created
August 1, 2016 18:24
-
-
Save ClayShentrup/2f5e35cc8f980b6ded9c26e65585f18f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.shared_examples('a foreign_key constraint association') do | |
specify do | |
expect do | |
build(described_model, "#{association}_id" => 0).save(validate: false) | |
end.to raise_error(ActiveRecord::InvalidForeignKey) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe(Employee) do | |
describe('associations') do | |
it_behaves_like('a foreign_key constraint association') do | |
let(:association) { :employer } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment