From 9e1c293eb864b0ab812b1620e4f91c494b792147 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Tue, 7 Jan 2014 23:40:14 +0000 Subject: [PATCH] Tidied some specs --- spec/models/feed_item_spec.rb | 68 ++++++++++++++++------------------- spec/requests/format_spec.rb | 6 ---- 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/spec/models/feed_item_spec.rb b/spec/models/feed_item_spec.rb index f932e43..d2aabc6 100644 --- a/spec/models/feed_item_spec.rb +++ b/spec/models/feed_item_spec.rb @@ -1,55 +1,49 @@ require 'spec_helper' describe FeedItem do - before(:each) do - @feed_item = FeedItem.new( - :feed_name => "feed", - :title => "foo", - :description => "bar" - ) - end - + it "is valid with valid attributes" do - expect(@feed_item).to be_valid + feed_item = FactoryGirl.build(:feed_item) + expect(feed_item).to be_valid end it "is not valid without a feed name" do - @feed_item.feed_name = nil - expect(@feed_item).not_to be_valid + feed_item = FactoryGirl.build(:feed_item, feed_name: nil) + expect(feed_item).not_to be_valid end it "is not valid without a title" do - @feed_item.title = nil - expect(@feed_item).not_to be_valid + feed_item = FactoryGirl.build(:feed_item, title: nil) + expect(feed_item).not_to be_valid end it "is not valid without a description" do - @feed_item.description = nil - expect(@feed_item).not_to be_valid + feed_item = FactoryGirl.build(:feed_item, description: nil) + expect(feed_item).not_to be_valid end it "is not valid with an improper feed name" do - @feed_item.feed_name = 'feed name' - expect(@feed_item).not_to be_valid - @feed_item.feed_name = 'feed%20name' - expect(@feed_item).not_to be_valid - @feed_item.feed_name = 'feed&name' - expect(@feed_item).not_to be_valid - @feed_item.feed_name = 'feed%26name' - expect(@feed_item).not_to be_valid - @feed_item.feed_name = 'feed