From d4acc8ea3c182706a9945d3d9df15a382b120e9e Mon Sep 17 00:00:00 2001 From: Chris Blanchard Date: Thu, 20 Aug 2015 15:48:19 +0100 Subject: [PATCH] Add initial forum tests --- spec/factories/forum.rb | 6 ++++++ spec/models/forum_spec.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 spec/factories/forum.rb create mode 100644 spec/models/forum_spec.rb diff --git a/spec/factories/forum.rb b/spec/factories/forum.rb new file mode 100644 index 0000000..3ad7213 --- /dev/null +++ b/spec/factories/forum.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :forum do + sequence(:title) { |n| "Forum Title #{n}" } + sequence(:description) { |n| "Forum Description #{n}" } + end +end \ No newline at end of file diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb new file mode 100644 index 0000000..211c244 --- /dev/null +++ b/spec/models/forum_spec.rb @@ -0,0 +1,29 @@ +# == Schema Information +# +# Table name: forums +# +# id :integer not null, primary key +# title :string(255) +# description :string(255) +# category_id :integer +# created_at :datetime +# updated_at :datetime +# position :integer +# + +require "spec_helper" + +describe Forum do + let!(:user) { create :user } + + describe "create" do + let(:forum) { build :forum } + + it "creates a new forum" do + expect(forum.valid?).to eq(true) + expect do + forum.save! + end.to change(Forum, :count).by(1) + end + end +end