aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/refinery/blog/engine_spec.rb2
-rw-r--r--spec/requests/refinery/blog/admin/categories_spec.rb2
-rw-r--r--spec/requests/refinery/blog/admin/comments_spec.rb86
-rw-r--r--spec/requests/refinery/blog/admin/menu_spec.rb2
-rw-r--r--spec/requests/refinery/blog/admin/posts_spec.rb18
-rw-r--r--spec/requests/refinery/blog/categories_spec.rb2
-rw-r--r--spec/requests/refinery/blog/posts_spec.rb22
-rw-r--r--spec/spec_helper.rb51
-rw-r--r--spec/support/database_cleaner.rb17
-rw-r--r--spec/support/devise.rb8
-rw-r--r--spec/support/refinery.rb6
11 files changed, 102 insertions, 114 deletions
diff --git a/spec/lib/refinery/blog/engine_spec.rb b/spec/lib/refinery/blog/engine_spec.rb
index 54a7eb5..b64601a 100644
--- a/spec/lib/refinery/blog/engine_spec.rb
+++ b/spec/lib/refinery/blog/engine_spec.rb
@@ -9,7 +9,7 @@ module Refinery
end
it "sets the correct path for activity entries" do
- activity.url.should eq("edit_refinery_blog_admin_post_path")
+ activity.url.should eq("refinery.edit_blog_admin_post_path")
end
end
diff --git a/spec/requests/refinery/blog/admin/categories_spec.rb b/spec/requests/refinery/blog/admin/categories_spec.rb
index 60a92ab..fd18cc0 100644
--- a/spec/requests/refinery/blog/admin/categories_spec.rb
+++ b/spec/requests/refinery/blog/admin/categories_spec.rb
@@ -6,7 +6,7 @@ describe "Categories admin" do
let(:title) { "lol" }
it "can create categories" do
- visit refinery_admin_root_path
+ visit refinery.admin_root_path
within("nav#menu") { click_link "Blog" }
within("nav.multilist") { click_link "Create new category" }
diff --git a/spec/requests/refinery/blog/admin/comments_spec.rb b/spec/requests/refinery/blog/admin/comments_spec.rb
index d56e1f1..1f69327 100644
--- a/spec/requests/refinery/blog/admin/comments_spec.rb
+++ b/spec/requests/refinery/blog/admin/comments_spec.rb
@@ -5,115 +5,113 @@ module Refinery
module Admin
describe Comment do
login_refinery_user
-
- describe "#index" do
+
+ describe "#index" do
context "when has no new unapproved comments" do
- before(:each) do
+ before(:each) do
subject.class.delete_all
- visit refinery_blog_admin_comments_path
- end
-
+ visit refinery.blog_admin_comments_path
+ end
+
it "should list no comments" do
- visit refinery_blog_admin_comments_path
-
- page.should have_content('there are no new comments')
+ visit refinery.blog_admin_comments_path
+
+ page.should have_content('There are no new comments')
end
end
context "when has new unapproved comments" do
let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
- before(:each) { visit refinery_blog_admin_comments_path }
-
+ before(:each) { visit refinery.blog_admin_comments_path }
+
it "should list comments" do
page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name)
end
-
+
it "should allow me to approve a comment" do
click_link "Approve this comment"
-
+
page.should have_content("has been approved")
end
-
+
it "should allow me to reject a comment" do
click_link "Reject this comment"
-
+
page.should have_content("has been rejected")
end
end
end
-
- describe "#approved" do
+
+ describe "#approved" do
context "when has no approved comments" do
before(:each) do
subject.class.delete_all
- visit approved_refinery_blog_admin_comments_path
+ visit refinery.approved_blog_admin_comments_path
end
-
- it "should list no comments" do
- page.should have_content('there are no approved comments')
+
+ it "should list no comments" do
+ page.should have_content('There are no approved comments')
end
end
context "when has approved comments" do
let!(:blog_comment) do
- FactoryGirl.create(:blog_comment,
- :state => 'approved')
+ FactoryGirl.create(:blog_comment, :state => 'approved')
end
- before(:each) { visit approved_refinery_blog_admin_comments_path }
-
- it "should list comments" do
+ before(:each) { visit refinery.approved_blog_admin_comments_path }
+
+ it "should list comments" do
page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name)
end
-
+
it "should allow me to reject a comment" do
click_link "Reject this comment"
-
+
page.should have_content("has been rejected")
end
end
end
-
- describe "#rejected" do
+
+ describe "#rejected" do
context "when has no rejected comments" do
before(:each) do
subject.class.delete_all
- visit rejected_refinery_blog_admin_comments_path
+ visit refinery.rejected_blog_admin_comments_path
end
-
- it "should list no comments" do
- page.should have_content('there are no rejected comments')
+
+ it "should list no comments" do
+ page.should have_content('There are no rejected comments')
end
end
context "when has rejected comments" do
let!(:blog_comment) do
- FactoryGirl.create(:blog_comment,
- :state => 'rejected')
+ FactoryGirl.create(:blog_comment, :state => 'rejected')
end
- before(:each) { visit rejected_refinery_blog_admin_comments_path }
-
- it "should list comments" do
+ before(:each) { visit refinery.rejected_blog_admin_comments_path }
+
+ it "should list comments" do
page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name)
end
-
+
it "should allow me to approve a comment" do
click_link "Approve this comment"
-
+
page.should have_content("has been approved")
end
end
end
-
+
describe "#show" do
let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
- before(:each) { visit refinery_blog_admin_comment_path(blog_comment) }
+ before(:each) { visit refinery.blog_admin_comment_path(blog_comment) }
it "should display the comment" do
page.should have_content(blog_comment.body)
page.should have_content(blog_comment.name)
end
it "should allow me to approve the comment" do
click_link "Approve this comment"
-
+
page.should have_content("has been approved")
end
end
diff --git a/spec/requests/refinery/blog/admin/menu_spec.rb b/spec/requests/refinery/blog/admin/menu_spec.rb
index b02a473..8b4b011 100644
--- a/spec/requests/refinery/blog/admin/menu_spec.rb
+++ b/spec/requests/refinery/blog/admin/menu_spec.rb
@@ -4,7 +4,7 @@ describe "Blog menu entry" do
login_refinery_user
it "is highlighted when managing the blog" do
- visit refinery_admin_root_path
+ visit refinery.admin_root_path
within("#menu") { click_link "Blog" }
diff --git a/spec/requests/refinery/blog/admin/posts_spec.rb b/spec/requests/refinery/blog/admin/posts_spec.rb
index 219fd13..e1ffe0d 100644
--- a/spec/requests/refinery/blog/admin/posts_spec.rb
+++ b/spec/requests/refinery/blog/admin/posts_spec.rb
@@ -12,7 +12,7 @@ module Refinery
before(:each) { subject.class.destroy_all }
describe "blog post listing" do
- before(:each) { visit refinery_blog_admin_posts_path }
+ before(:each) { visit refinery.blog_admin_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.")
@@ -21,7 +21,7 @@ module Refinery
describe "new blog post form" do
before(:each) do
- visit refinery_blog_admin_posts_path
+ visit refinery.blog_admin_posts_path
click_link "Create new post"
end
@@ -53,7 +53,7 @@ module Refinery
subject.class.first.author.should eq(::Refinery::User.last)
end
- it "should save categories", :focus => true do
+ it "should save categories" do
subject.class.last.categories.count.should eq(1)
subject.class.last.categories.first.title.should eq(blog_category.title)
end
@@ -87,14 +87,14 @@ module Refinery
let!(:blog_post) { FactoryGirl.create(:blog_post) }
describe "blog post listing" do
- before(:each) { visit refinery_blog_admin_posts_path }
+ before(:each) { visit refinery.blog_admin_posts_path }
describe "edit blog post" do
it "should succeed" do
page.should have_content(blog_post.title)
click_link("Edit this blog post")
- current_path.should == edit_refinery_blog_admin_post_path(blog_post)
+ current_path.should == refinery.edit_blog_admin_post_path(blog_post)
fill_in "Title", :with => "hax0r"
click_button "Save"
@@ -118,7 +118,7 @@ module Refinery
it "redirects to blog post in the frontend" do
click_link "View this blog post live"
- current_path.should == refinery_blog_post_path(blog_post)
+ current_path.should == refinery.blog_post_path(blog_post)
page.should have_content(blog_post.title)
end
end
@@ -126,7 +126,7 @@ module Refinery
context "when uncategorized post" do
it "shows up in the list" do
- visit uncategorized_refinery_blog_admin_posts_path
+ visit refinery.uncategorized_blog_admin_posts_path
page.should have_content(blog_post.title)
end
end
@@ -136,7 +136,7 @@ module Refinery
blog_post.categories << blog_category
blog_post.save!
- visit uncategorized_refinery_blog_admin_posts_path
+ visit refinery.uncategorized_blog_admin_posts_path
page.should_not have_content(blog_post.title)
end
end
@@ -147,7 +147,7 @@ module Refinery
describe "create blog post with alternate author" do
before(:each) do
- visit refinery_blog_admin_posts_path
+ visit refinery.blog_admin_posts_path
click_link "Create new post"
fill_in "Title", :with => "This is some other guy's blog post"
diff --git a/spec/requests/refinery/blog/categories_spec.rb b/spec/requests/refinery/blog/categories_spec.rb
index 022d251..149723c 100644
--- a/spec/requests/refinery/blog/categories_spec.rb
+++ b/spec/requests/refinery/blog/categories_spec.rb
@@ -13,7 +13,7 @@ module Refinery
end
describe "show categories blog posts" do
- before(:each) { visit refinery_blog_category_path(@category) }
+ before(:each) { visit refinery.blog_category_path(@category) }
it "should displays categories blog posts" do
page.should have_content("Refinery CMS blog post")
page.should have_content("Video Games")
diff --git a/spec/requests/refinery/blog/posts_spec.rb b/spec/requests/refinery/blog/posts_spec.rb
index 471a460..815ca26 100644
--- a/spec/requests/refinery/blog/posts_spec.rb
+++ b/spec/requests/refinery/blog/posts_spec.rb
@@ -8,13 +8,13 @@ module Refinery
let!(:blog_post) { FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post") }
it "should display blog post" do
- visit refinery_blog_post_path(blog_post)
+ visit refinery.blog_post_path(blog_post)
page.should have_content(blog_post.title)
end
it "should display the blog rss feed" do
- get refinery_blog_rss_feed_path
+ get refinery.blog_rss_feed_path
response.should be_success
response.content_type.should eq("application/rss+xml")
@@ -31,7 +31,7 @@ module Refinery
@tag = ::Refinery::Blog::Post.tag_counts_on(:tags).first
end
it "should have one tagged post" do
- visit refinery_blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
+ visit refinery.blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
page.should have_content(@tag_name)
page.should have_content(@post.title)
@@ -44,7 +44,7 @@ module Refinery
let(:blog_post) { FactoryGirl.create(:blog_post) }
it "should display the blog post" do
- visit refinery_blog_post_path(blog_post)
+ visit refinery.blog_post_path(blog_post)
page.should have_content(blog_post.title)
page.should have_content(blog_post.body)
end
@@ -53,7 +53,7 @@ module Refinery
let(:approved_comment) { FactoryGirl.create(:approved_comment) }
it "should display the comments" do
- visit refinery_blog_post_path(approved_comment.post)
+ visit refinery.blog_post_path(approved_comment.post)
page.should have_content(approved_comment.body)
page.should have_content("Posted by #{approved_comment.name}")
@@ -63,7 +63,7 @@ module Refinery
let(:rejected_comment) { FactoryGirl.create(:rejected_comment) }
it "should not display the comments" do
- visit refinery_blog_post_path(rejected_comment.post)
+ visit refinery.blog_post_path(rejected_comment.post)
page.should_not have_content(rejected_comment.body)
end
@@ -72,7 +72,7 @@ module Refinery
let(:blog_comment) { FactoryGirl.create(:blog_comment) }
it "should not display the comments" do
- visit refinery_blog_post_path(blog_comment.post)
+ visit refinery.blog_post_path(blog_comment.post)
page.should_not have_content(blog_comment.body)
end
@@ -85,7 +85,7 @@ module Refinery
let(:body) { "Witty comment." }
before do
- visit refinery_blog_post_path(blog_post)
+ visit refinery.blog_post_path(blog_post)
fill_in "Name", :with => name
fill_in "Email", :with => email
@@ -107,16 +107,16 @@ module Refinery
let(:blog_post) { FactoryGirl.create(:blog_post_draft) }
context "when logged in as admin" do
it "should display the draft notification" do
- visit refinery_blog_post_path(blog_post)
+ visit refinery.blog_post_path(blog_post)
page.should have_content('This page is NOT live for public viewing.')
end
end
context "when not logged in as an admin" do
- before(:each) { visit destroy_refinery_user_session_path }
+ before(:each) { visit refinery.destroy_refinery_user_session_path }
it "should not display the blog post" do
- visit refinery_blog_post_path(blog_post)
+ visit refinery.blog_post_path(blog_post)
page.should have_content("The page you were looking for doesn't exist (404)")
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9d4bffe..21267d3 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,37 +1,58 @@
require 'rubygems'
-def load_all(*patterns)
- patterns.each { |pattern| Dir[pattern].sort.each { |path| load File.expand_path(path) } }
-end
-
-def setup_environment
+def setup_environment
# Configure Rails Environment
- ENV["RAILS_ENV"] = 'test'
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
-
+ ENV["RAILS_ENV"] ||= 'test'
+
+ require File.expand_path("../dummy/config/environment", __FILE__)
+
require 'rspec/rails'
require 'capybara/rspec'
require 'factory_girl_rails'
-
+
Rails.backtrace_cleaner.remove_silencers!
RSpec.configure do |config|
config.mock_with :rspec
+ config.treat_symbols_as_metadata_keys_with_true_values = true
+ config.filter_run :focus => true
+ config.run_all_when_everything_filtered = true
end
+
+ # set javascript driver for capybara
+ Capybara.javascript_driver = :selenium
+
+ # minimize password hashing stretches
+ Devise.stretches = 1
end
-def each_run
- FactoryGirl.reload
+def each_run
ActiveSupport::Dependencies.clear
- load_all 'spec/support/**/*.rb'
- load_all 'spec/factories/**/*.rb' if FactoryGirl.factories.none?
+ FactoryGirl.reload
+
+ # Requires supporting files with custom matchers and macros, etc,
+ # in ./support/ and its subdirectories including factories.
+ ([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
+ Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
+ }.flatten.sort.each do |support_file|
+ require support_file
+ end
end
# If spork is available in the Gemfile it'll be used but we don't force it.
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
- Spork.prefork { setup_environment }
- Spork.each_run { each_run }
+ Spork.prefork do
+ # Loading more in this block will cause your tests to run faster. However,
+ # if you change any configuration or code from libraries loaded here, you'll
+ # need to restart spork for it take effect.
+ setup_environment
+ end
+
+ Spork.each_run do
+ # This code will be run each time you run your specs.
+ each_run
+ end
else
setup_environment
each_run
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
deleted file mode 100644
index 40acbc9..0000000
--- a/spec/support/database_cleaner.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'database_cleaner'
-
-RSpec.configure do |config|
- config.use_transactional_fixtures = false
-
- config.before(:suite) do
- DatabaseCleaner.strategy = :truncation
- end
-
- config.before(:each) do
- DatabaseCleaner.start
- end
-
- config.after(:each) do
- DatabaseCleaner.clean
- end
-end
diff --git a/spec/support/devise.rb b/spec/support/devise.rb
deleted file mode 100644
index 9dc6823..0000000
--- a/spec/support/devise.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'devise'
-
-RSpec.configure do |config|
- config.mock_with :rspec
- config.use_transactional_fixtures = false
-
- config.include Devise::TestHelpers, :type => :controller
-end
diff --git a/spec/support/refinery.rb b/spec/support/refinery.rb
deleted file mode 100644
index d761787..0000000
--- a/spec/support/refinery.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require 'refinerycms-testing'
-
-RSpec.configure do |config|
- config.extend Refinery::Testing::ControllerMacros::Authentication, :type => :controller
- config.extend Refinery::Testing::RequestMacros::Authentication, :type => :request
-end