Last active
March 8, 2016 08:23
-
-
Save carlesjove/7c9465b5c6ca27cefab2 to your computer and use it in GitHub Desktop.
How to use Temping to test a module
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
require "rails_helper" | |
# In this example I'm testing a module that introduces some | |
# AR validations to the model. Using shoulda matchers, as I | |
# normally would in a model spec, works just fine :-) | |
describe "Scopable concern" do | |
before do | |
Temping.create :parent_model do | |
end | |
Temping.create :dummy do | |
with_columns do |t| | |
t.integer :parent_model_id | |
end | |
include Scopable | |
must_belong_to :parent_model | |
end | |
end | |
subject { Dummy.new } | |
describe "associations" do | |
it { should belong_to(:parent_model) } | |
end | |
describe "validations" do | |
it { should validate_presence_of(:parent_model) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment