Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. require 'rails_helper'
  2.  
  3. RSpec.describe Article, type: :model do
  4.  
  5. before(:each) do
  6. @article = FactoryBot.build(:article)
  7. end
  8.  
  9. it "has a valid factory" do
  10. expect(build(:article)).to be_valid
  11. end
  12.  
  13. context "validation" do
  14. it "is valid with valid attributes" do
  15. expect(@article).to be_a(Article)
  16. end
  17.  
  18. describe "#title" do
  19. it {expect(@article).to validate_presence_of(:title)}
  20. it {expect(@article).to validate_uniqueness_of(:title)}
  21. it {is_expected.to allow_value("Super article sur l'agroforesterie").for(:title)}
  22. it {is_expected.to_not allow_value("Sup").for(:title)}
  23. it {is_expected.to_not allow_value("a" *61).for(:title)}
  24. end
  25.  
  26. describe "#content" do
  27. it {expect(@article).to validate_presence_of(:content)}
  28. it {is_expected.to allow_value("Super article sur l'agroforesterie").for(:content)}
  29. it {is_expected.to_not allow_value("Sup").for(:content)}
  30. end
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement