aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-08-04 13:59:51 -0700
committerJamie Winsor <jamie@enmasse.com>2011-08-04 15:11:05 -0700
commit8bd056e3e8baa108b2e10e460ceeeed3ec7c4c86 (patch)
tree5e095d1a675daabf26e8cc0472bae433257b7616 /spec
parent84a2fcdf08430c70cb4da8c678c2d72e8ca54628 (diff)
downloadrefinerycms-blog-8bd056e3e8baa108b2e10e460ceeeed3ec7c4c86.tar.gz
refinerycms-blog-8bd056e3e8baa108b2e10e460ceeeed3ec7c4c86.tar.bz2
refinerycms-blog-8bd056e3e8baa108b2e10e460ceeeed3ec7c4c86.zip
Replace category.features with capybara rspec requests
Update FactoryGirl factory definition syntax
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/blog_categories.rb6
-rw-r--r--spec/factories/blog_comments.rb12
-rw-r--r--spec/factories/blog_posts.rb14
-rw-r--r--spec/requests/blog_categories_spec.rb29
-rw-r--r--spec/requests/manage_blog_posts_spec.rb161
5 files changed, 127 insertions, 95 deletions
diff --git a/spec/factories/blog_categories.rb b/spec/factories/blog_categories.rb
index c3701dd..31ec28b 100644
--- a/spec/factories/blog_categories.rb
+++ b/spec/factories/blog_categories.rb
@@ -1,3 +1,5 @@
-Factory.define :blog_category, :class => 'refinery/blog_category' do |f|
- f.sequence(:title) { |n| "Shopping #{n}" }
+FactoryGirl.define do
+ factory :blog_category, :class => 'refinery/blog_category' do
+ sequence(:title) { |n| "Shopping #{n}" }
+ end
end
diff --git a/spec/factories/blog_comments.rb b/spec/factories/blog_comments.rb
index d738cac..0bb5206 100644
--- a/spec/factories/blog_comments.rb
+++ b/spec/factories/blog_comments.rb
@@ -1,6 +1,8 @@
-Factory.define :blog_comment, :class => 'refinery/blog_comment' do |f|
- f.name "Joe Commenter"
- f.sequence(:email) { |n| "person#{n}@example.com" }
- f.body "Which one is the best for picking up new shoes?"
- f.association :post, :factory => :blog_post
+FactoryGirl.define do
+ factory :blog_comment, :class => 'refinery/blog_comment' do
+ name "Joe Commenter"
+ sequence(:email) { |n| "person#{n}@example.com" }
+ body "Which one is the best for picking up new shoes?"
+ association :post, :factory => :blog_post
+ end
end
diff --git a/spec/factories/blog_posts.rb b/spec/factories/blog_posts.rb
index 548636d..4586b36 100644
--- a/spec/factories/blog_posts.rb
+++ b/spec/factories/blog_posts.rb
@@ -1,7 +1,9 @@
-Factory.define :blog_post, :class => 'refinery/blog_post' do |f|
- f.sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" }
- f.body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
- f.draft false
- f.tag_list "chicago, shopping, fun times"
- f.published_at Time.now
+FactoryGirl.define do
+ factory :blog_post, :class => 'refinery/blog_post' do
+ sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" }
+ body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
+ draft false
+ tag_list "chicago, shopping, fun times"
+ published_at Time.now
+ end
end
diff --git a/spec/requests/blog_categories_spec.rb b/spec/requests/blog_categories_spec.rb
index 8ac6eff..d18a552 100644
--- a/spec/requests/blog_categories_spec.rb
+++ b/spec/requests/blog_categories_spec.rb
@@ -2,19 +2,22 @@ require "spec_helper"
describe "blog categories" do
login_refinery_user
-
- before(:each) do
- @blog_post = Factory(:blog_post, :title => "Refinery CMS blog post")
- @blog_category = Factory(:blog_category, :title => "Video Games")
- @blog_post.categories << @blog_category
- @blog_post.save!
- end
-
- context "has posts" do
- it "displays category's blog posts" do
- visit blog_category_path(@blog_category)
- page.should have_content("Refinery CMS blog post")
- page.should have_content("Video Games")
+
+ context "has one category and post" do
+ before(:each) do
+ @blog_post = Factory.create(:blog_post, :title => "Refinery CMS blog post")
+ @blog_category = Factory.create(:blog_category, :title => "Video Games")
+ @blog_post.categories << @blog_category
+ @blog_post.save!
+ end
+
+ describe "show categories blog posts" do
+ before(:each) { visit blog_category_path(@blog_category) }
+
+ it "should displays categories blog posts" do
+ page.should have_content("Refinery CMS blog post")
+ page.should have_content("Video Games")
+ end
end
end
end
diff --git a/spec/requests/manage_blog_posts_spec.rb b/spec/requests/manage_blog_posts_spec.rb
index 585bcd4..12b7b8f 100644
--- a/spec/requests/manage_blog_posts_spec.rb
+++ b/spec/requests/manage_blog_posts_spec.rb
@@ -2,95 +2,118 @@ require "spec_helper"
describe "manage blog posts" do
login_refinery_user
-
- let!(:blog_post) { Factory(:blog_post, :title => "Refinery CMS blog post") }
+
+ let!(:blog_category) { Factory.create(:blog_category, :title => "Video Games") }
context "when no blog posts" do
before(:each) { Refinery::BlogPost.destroy_all }
-
- it "invites to create new post" do
- visit refinery_admin_blog_posts_path
- page.should have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.")
- end
- end
-
- describe "when creating first blog post" do
- before(:each) do
- Refinery::BlogPost.destroy_all
-
- visit refinery_admin_blog_posts_path
- click_link "Create new post"
-
- fill_in "Title", :with => "Another Refinery CMS blog post"
- fill_in "blog_post_body", :with => "Bla bla"
- click_button "Save"
- end
-
- it "should succeed" do
- page.should have_content("'Another Refinery CMS blog post' was successfully added.")
- end
- it "should be the only blog post" do
- ::Refinery::BlogPost.all.size.should eq(1)
+ describe "blog post listing" do
+ before(:each) { visit refinery_admin_blog_posts_path }
+
+ it "invites to create new post" do
+ page.should have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.")
+ end
end
- it "should belong to me" do
- ::Refinery::BlogPost.first.author.login.should eq(::Refinery::User.last.login)
+ describe "new blog post form" do
+ before(:each) do
+ visit refinery_admin_blog_posts_path
+ click_link "Create new post"
+ end
+
+ it "should have Tags" do
+ page.should have_content("Tags")
+ end
+
+ it "should have Video Games" do
+ page.should have_content(blog_category.title)
+ end
+
+ describe "create blog post" do
+ before(:each) do
+ fill_in "Title", :with => "This is my blog post"
+ fill_in "blog_post_body", :with => "And I love it"
+ check blog_category.title
+ click_button "Save"
+ end
+
+ it "should succeed" do
+ page.should have_content("was successfully added.")
+ end
+
+ it "should be the only blog post" do
+ ::Refinery::BlogPost.all.size.should eq(1)
+ end
+
+ it "should belong to me" do
+ ::Refinery::BlogPost.first.author.login.should eq(::Refinery::User.last.login)
+ end
+
+ it "should save categories" do
+ ::Refinery::BlogPost.last.categories.count.should eq(1)
+ ::Refinery::BlogPost.last.categories.first.title.should eq(blog_category.title)
+ end
+ end
end
end
- context "when editing blog post" do
- it "should succeed" do
- visit refinery_admin_blog_posts_path
- page.should have_content(blog_post.title)
-
- click_link("Edit this blog post")
- current_path.should == edit_refinery_admin_blog_post_path(blog_post)
-
- fill_in "Title", :with => "hax0r"
- click_button "Save"
+ context "when has blog posts" do
+ let!(:blog_post) { Factory(:blog_post) }
+
+ describe "blog post listing" do
+ before(:each) { visit refinery_admin_blog_posts_path }
+
+ describe "edit blog post" do
+ it "should succeed" do
+ page.should have_content(blog_post.title)
- page.should_not have_content(blog_post.title)
- page.should have_content("'hax0r' was successfully updated.")
- end
- end
+ click_link("Edit this blog post")
+ current_path.should == edit_refinery_admin_blog_post_path(blog_post)
- context "when deleting blog post" do
- it "should succeed" do
+ fill_in "Title", :with => "hax0r"
+ click_button "Save"
- visit refinery_admin_blog_posts_path
- page.should have_content(blog_post.title)
+ page.should_not have_content(blog_post.title)
+ page.should have_content("'hax0r' was successfully updated.")
+ end
+ end
- click_link "Remove this blog post forever"
+ describe "deleting blog post" do
+ it "should succeed" do
+ page.should have_content(blog_post.title)
- page.should have_content("'#{blog_post.title}' was successfully removed.")
- end
- end
+ click_link "Remove this blog post forever"
- context "uncategorized post" do
- it "shows up in the list" do
- visit uncategorized_refinery_admin_blog_posts_path
- page.should have_content(blog_post.title)
+ page.should have_content("'#{blog_post.title}' was successfully removed.")
+ end
+ end
+
+ describe "view live" do
+ it "redirects to blog post in the frontend" do
+ click_link "View this blog post live"
+
+ current_path.should == blog_post_path(blog_post)
+ page.should have_content(blog_post.title)
+ end
+ end
end
- end
-
- context "categorized post" do
- it "won't show up in the list" do
- blog_post.categories << Factory(:blog_category)
- blog_post.save!
- visit uncategorized_refinery_admin_blog_posts_path
- page.should_not have_content(blog_post.title)
+ context "when uncategorized post" do
+ it "shows up in the list" do
+ visit uncategorized_refinery_admin_blog_posts_path
+ page.should have_content(blog_post.title)
+ end
end
- end
- describe "view live" do
- it "redirects to blog post in the frontend" do
- visit refinery_admin_blog_posts_path
- click_link "View this blog post live"
+ context "when categorized post" do
+ it "won't show up in the list" do
+ blog_post.categories << blog_category
+ blog_post.save!
- current_path.should == blog_post_path(blog_post)
- page.should have_content(blog_post.title)
+ visit uncategorized_refinery_admin_blog_posts_path
+ page.should_not have_content(blog_post.title)
+ end
end
end
end