aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml3
-rw-r--r--Gemfile14
-rw-r--r--app/controllers/refinery/blog/posts_controller.rb2
-rw-r--r--app/models/refinery/blog/category.rb4
-rw-r--r--app/models/refinery/blog/comment.rb2
-rw-r--r--app/models/refinery/blog/post.rb6
-rw-r--r--app/views/refinery/blog/admin/categories/_category.html.erb10
-rw-r--r--app/views/refinery/blog/admin/posts/_form.html.erb2
-rw-r--r--app/views/refinery/blog/admin/posts/_post.html.erb14
-rw-r--r--config/locales/fr.yml4
-rw-r--r--config/locales/nl.yml21
-rw-r--r--db/seeds.rb6
-rw-r--r--lib/refinery/blog.rb1
-rw-r--r--lib/refinery/blog/engine.rb2
-rw-r--r--readme.md7
-rw-r--r--refinerycms-blog.gemspec4
-rw-r--r--spec/controllers/refinery/blog/admin/comments_controller_spec.rb26
-rw-r--r--spec/controllers/refinery/blog/posts_controller_spec.rb4
-rw-r--r--spec/features/refinery/blog/admin/categories_spec.rb42
-rw-r--r--spec/features/refinery/blog/admin/comments_spec.rb32
-rw-r--r--spec/features/refinery/blog/admin/menu_spec.rb2
-rw-r--r--spec/features/refinery/blog/admin/posts_spec.rb116
-rw-r--r--spec/features/refinery/blog/categories_spec.rb4
-rw-r--r--spec/features/refinery/blog/posts_spec.rb42
-rw-r--r--spec/helpers/refinery/blog/posts_helper_spec.rb24
-rw-r--r--spec/lib/refinery/blog/engine_spec.rb2
-rw-r--r--spec/models/refinery/blog/category_spec.rb10
-rw-r--r--spec/models/refinery/blog/comment_spec.rb4
-rw-r--r--spec/models/refinery/blog/post_spec.rb66
-rw-r--r--spec/spec_helper.rb5
30 files changed, 262 insertions, 219 deletions
diff --git a/.travis.yml b/.travis.yml
index 5b35827..1dbb9b9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,8 +19,11 @@ notifications:
on_failure: always
rooms:
- secure: "JaX+Ckvdd2wqL2bD6t8PHvMDBHxWBlCrkBKPcDKxV0t0DOwzzzwxMryVqcRi\nPsmM/zvmWFATDyRmivhNOpu4lRg9RytSroxZ9nkmbLDqjCyEAZ6tv4yZXME/\nPaxPwmfwgS9g8TKjj3lSWS7rEpqqg0D5S0XIfIHrj6KB6LUmFHc="
+ webhooks:
+ - https://webhooks.gitter.im/e/b5d48907cdc89864b874
env:
- DB=postgresql
- DB=mysql
rvm:
+ - 2.2
- 2.1
diff --git a/Gemfile b/Gemfile
index b26b44e..79f0594 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,18 +2,18 @@ source "https://rubygems.org"
gemspec
-gem 'refinerycms', github: 'refinery/refinerycms'
-gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n'
-gem 'refinerycms-settings', github: 'refinery/refinerycms-settings'
-gem 'refinerycms-acts-as-indexed', github: 'refinery/refinerycms-acts-as-indexed'
-gem 'filters_spam', github: 'resolve/filters_spam'
+git "https://github.com/refinery/refinerycms", branch: "master" do
+ gem 'refinerycms'
-gem 'mime-types', '1.25.1'
+ group :development, :test do
+ gem 'refinerycms-testing'
+ end
+end
group :test do
- gem 'refinerycms-testing', github: 'refinery/refinerycms'
gem 'pry'
gem 'launchy'
+ gem 'poltergeist'
end
# Database Configuration
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb
index 1cc9698..2e504f7 100644
--- a/app/controllers/refinery/blog/posts_controller.rb
+++ b/app/controllers/refinery/blog/posts_controller.rb
@@ -41,7 +41,7 @@ module Refinery
if @comment.valid?
if Comment::Moderation.enabled? or @comment.ham?
begin
- CommentMailer.notification(@comment, request).deliver
+ CommentMailer.notification(@comment, request).deliver_now
rescue
logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
end
diff --git a/app/models/refinery/blog/category.rb b/app/models/refinery/blog/category.rb
index 5cf4ea5..ca3824e 100644
--- a/app/models/refinery/blog/category.rb
+++ b/app/models/refinery/blog/category.rb
@@ -12,6 +12,10 @@ module Refinery
validates :title, :presence => true, :uniqueness => true
+ def self.by_title(title)
+ joins(:translations).find_by(title: title)
+ end
+
def self.translated
with_translations(::Globalize.locale)
end
diff --git a/app/models/refinery/blog/comment.rb b/app/models/refinery/blog/comment.rb
index be94238..2050616 100644
--- a/app/models/refinery/blog/comment.rb
+++ b/app/models/refinery/blog/comment.rb
@@ -1,3 +1,5 @@
+require 'filters_spam'
+
module Refinery
module Blog
class Comment < ActiveRecord::Base
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index f80a939..c64c8f2 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -78,7 +78,7 @@ module Refinery
def find_by_slug_or_id(slug_or_id)
if slug_or_id.friendly_id?
- find_by_slug(slug_or_id)
+ friendly.find(slug_or_id)
else
find(slug_or_id)
end
@@ -92,6 +92,10 @@ module Refinery
newest_first.where(:published_at => date.beginning_of_year..date.end_of_year).with_globalize
end
+ def by_title(title)
+ joins(:translations).find_by(:title => title)
+ end
+
def newest_first
order("published_at DESC")
end
diff --git a/app/views/refinery/blog/admin/categories/_category.html.erb b/app/views/refinery/blog/admin/categories/_category.html.erb
index c1cfa15..3f813f5 100644
--- a/app/views/refinery/blog/admin/categories/_category.html.erb
+++ b/app/views/refinery/blog/admin/categories/_category.html.erb
@@ -4,10 +4,14 @@
<span class="preview">
<% category.translations.each do |translation| %>
<% if translation.title.present? %>
- <%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
- refinery.edit_blog_admin_category_path(category, :switch_locale => translation.locale),
- :class => 'locale' %>
+ <%= link_to refinery.edit_blog_admin_category_path(category, :switch_locale => translation.locale),
+ :class => 'locale' do %>
+ <div class="locale_icon <%= translation.locale %>">
+ <%= refinery_icon_tag('locale-blue.svg', :size => '24x24') %>
+ <span class="code"><%= translation.locale.upcase %></span>
+ </div>
<% end %>
+ <% end %>
<% end %>
</span>
</span>
diff --git a/app/views/refinery/blog/admin/posts/_form.html.erb b/app/views/refinery/blog/admin/posts/_form.html.erb
index b2a31e1..1d52c56 100644
--- a/app/views/refinery/blog/admin/posts/_form.html.erb
+++ b/app/views/refinery/blog/admin/posts/_form.html.erb
@@ -44,7 +44,7 @@
<div class='field'>
<%= f.label :tag_list, t('refinery.blog.shared.tags.title') -%>
- <%= f.text_field :tag_list, :class => 'larger' -%>
+ <%= f.text_field :tag_list, value: @post.tag_list.to_s, :class => 'larger' -%>
</div>
<div id='more_options' style="display:none;">
diff --git a/app/views/refinery/blog/admin/posts/_post.html.erb b/app/views/refinery/blog/admin/posts/_post.html.erb
index eb9cc9d..6457c7b 100644
--- a/app/views/refinery/blog/admin/posts/_post.html.erb
+++ b/app/views/refinery/blog/admin/posts/_post.html.erb
@@ -2,12 +2,14 @@
<span class='title'>
<%= post.title.presence || post.translations.detect {|t| t.title.present?}.title %>
<span class="preview">
- <% post.translations.each do |translation| %>
- <% if translation.title.present? %>
- <%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
- refinery.edit_blog_admin_post_path(post, :switch_locale => translation.locale),
- :class => 'locale' %>
- <% end %>
+ <% post.translations.reject {|t| t.title.blank? }.each do |translation| %>
+ <%= link_to refinery.edit_blog_admin_post_path(post, :switch_locale => translation.locale),
+ :class => 'locale' do %>
+ <div class="locale_icon <%= translation.locale %>">
+ <%= refinery_icon_tag('locale-blue.svg', :size => '24x24') %>
+ <span class="code"><%= translation.locale.upcase %></span>
+ </div>
+ <% end %>
<% end %>
<%= post.published_at.try(:strftime, '%b %d, %Y') || 'draft' %>
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index d381e4e..fe62db2 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -79,9 +79,9 @@ fr:
title: Articles
manage: Gérer les articles
new: Créer un nouvel article
- uncategorized: Aricles non catégorisés
+ uncategorized: Articles non catégorisés
settings:
- title: Paramêtres
+ title: Paramètres
moderation: Modération
update_notified: Mettre à jour les personnes à notifier
comments: Commentaires
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index e785395..64e2751 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -37,6 +37,16 @@ nl:
form:
toggle_advanced_options: Klik voor toegang tot meta tag instellingen en menu opties
published_at: Publicatiedatum
+ custom_url: Custom URL
+ custom_url_help: Genereer de URL van deze blogpost aan de hand van deze tekst in plaats van de titel.
+ source_url: Bron URL
+ source_url_help: Slaat de bron URL op van materiaal voor deze post.
+ source_url_title: Bron URL titel
+ source_url_title_help: Titel van de bron URL van de post.
+ author: Auteur
+ author_help: Stel in wie wordt weergegeven als auteur van deze post.
+ copy_body: Kopieer de post body naar de teaser
+ copy_body_help: Kopieer de post body naar de teaser. Laat de teaser leeg om deze automatisch te laten genereren.
index:
no_items_yet: 'Er zijn momenteel geen blogposts. Klik op "%{create}" om uw eerste blogpost toe te voegen.'
uncategorized:
@@ -45,6 +55,7 @@ nl:
view_live_html: 'Bekijk deze blogpost op de website <br/><em>(opent in een nieuw venster)</em>'
edit: Bewerk deze blogpost
delete: Verwijder deze blogpost definitief
+ draft: Concept
settings:
notification_recipients:
value: Stuur notificaties naar
@@ -84,6 +95,10 @@ nl:
from: Van
email: E-mail
message: Bericht
+ approve: Goedkeuren
+ or: " of "
+ reject: afkeuren
+ this_comment: " deze comment."
closing_line: Met vriendelijke groet
ps: 'P.S. Alle reacties worden opgeslagen in de "Blog" sectie van Refinery onder het submenu "Comments", voor als u deze reacties later wilt bekijken.'
shared:
@@ -125,8 +140,14 @@ nl:
filled_in: Toegevoegd aan
tagged: Tagged
submit: Verstuur reactie
+ name: Naam
+ email: Email
+ message: Bericht
+ by: Door
+ source: Bron
tagged:
no_blog_articles_yet: Er zijn momenteel nog geen blogposts. Neem regelmatig een kijkje.
+ posts_tagged: Posts tagged
archive:
blog_archive_for: 'Blog archief voor %{date}'
no_blog_articles_posted: 'Er zijn geen blogposts voor %{date}. Neem regelmatig een kijkje.'
diff --git a/db/seeds.rb b/db/seeds.rb
index 6eaa1ba..271b044 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -5,12 +5,12 @@ Refinery::User.all.each do |user|
end
end if defined?(Refinery::User)
-if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => '/blog')
+if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => (url = Refinery::Blog.page_url))
page = Refinery::Page.create(
:title => "Blog",
- :link_url => "/blog",
+ :link_url => url,
:deletable => false,
- :menu_match => "^/blogs?(\/|\/.+?|)$"
+ :menu_match => "^#{url}?(\/|\/.+?|)$"
)
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
diff --git a/lib/refinery/blog.rb b/lib/refinery/blog.rb
index 604d0b1..c601e4d 100644
--- a/lib/refinery/blog.rb
+++ b/lib/refinery/blog.rb
@@ -1,7 +1,6 @@
require 'refinerycms-core'
require 'refinerycms-settings'
require 'refinerycms-wymeditor'
-require 'filters_spam'
require 'rails_autolink'
require 'friendly_id'
require 'jquery-ui-rails'
diff --git a/lib/refinery/blog/engine.rb b/lib/refinery/blog/engine.rb
index 7b29466..c4c39d8 100644
--- a/lib/refinery/blog/engine.rb
+++ b/lib/refinery/blog/engine.rb
@@ -5,7 +5,7 @@ module Refinery
isolate_namespace Refinery::Blog
- initializer "register refinerycms_blog plugin" do
+ before_inclusion do
Refinery::Plugin.register do |plugin|
plugin.pathname = root
plugin.name = "refinerycms_blog"
diff --git a/readme.md b/readme.md
index 655db85..d0c4f42 100644
--- a/readme.md
+++ b/readme.md
@@ -15,12 +15,15 @@ Refinery CMS version 3.0.0 or above.
## Install
-Open up your ``Gemfile`` and add at the bottom this line:
+Open up your ``Gemfile`` and at the bottom, add this line:
+
```ruby
gem 'refinerycms-blog', git: 'https://github.com/refinery/refinerycms-blog', branch: 'master'
```
+Note: if the [refinerycms-page-images](https://github.com/refinery/refinerycms-page-images) extension is also installed, make sure `gem refinerycms-blog` comes before `gem 'refinerycms-page-images'`.
+
Now, run ``bundle install``
Next, to install the blog plugin run:
@@ -56,7 +59,7 @@ Or just with rake spec
## Additional Features
* To limit rss feed length, use the 'max_results' parameter
- http://test.host/blog/feed.rss?max_results=10
+ http://test.host/blog/feed.rss?max_results=10
## More Information
* Check out our [Website](http://refinerycms.com/)
diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec
index 2d99591..75acccb 100644
--- a/refinerycms-blog.gemspec
+++ b/refinerycms-blog.gemspec
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency 'acts-as-taggable-on'
s.add_dependency 'seo_meta', '~> 2.0.0.rc.1'
s.add_dependency 'rails_autolink', '~> 1.1.3'
- s.add_dependency 'friendly_id', '~> 5.0.0'
- s.add_dependency 'globalize', '~> 4.0.0'
+ s.add_dependency 'friendly_id', '~> 5.1.0'
+ s.add_dependency 'globalize', ['>= 4.0.0', '< 5.2']
s.add_dependency 'jquery-ui-rails', '~> 5.0.0'
end
diff --git a/spec/controllers/refinery/blog/admin/comments_controller_spec.rb b/spec/controllers/refinery/blog/admin/comments_controller_spec.rb
index 5a439f1..4139c18 100644
--- a/spec/controllers/refinery/blog/admin/comments_controller_spec.rb
+++ b/spec/controllers/refinery/blog/admin/comments_controller_spec.rb
@@ -14,13 +14,13 @@ module Refinery
it "succeeds" do
get :index
- response.should be_success
- response.should render_template(:index)
+ expect(response).to be_success
+ expect(response).to render_template(:index)
end
it "assigns unmoderated comments" do
get :index
- assigns(:comments).first.should eq(comment)
+ expect(assigns(:comments).first).to eq(comment)
end
end
@@ -29,13 +29,13 @@ module Refinery
it "succeeds" do
get :approved
- response.should be_success
- response.should render_template(:index)
+ expect(response).to be_success
+ expect(response).to render_template(:index)
end
it "assigns approved comments" do
get :approved
- assigns(:comments).first.should eq(comment)
+ expect(assigns(:comments).first).to eq(comment)
end
end
@@ -44,12 +44,12 @@ module Refinery
it "redirects on success" do
post :approve, :id => comment.id
- response.should be_redirect
+ expect(response).to be_redirect
end
it "approves the comment" do
post :approve, :id => comment.id
- Refinery::Blog::Comment.approved.count.should eq(1)
+ expect(Refinery::Blog::Comment.approved.count).to eq(1)
end
end
@@ -58,13 +58,13 @@ module Refinery
it "succeeds" do
get :rejected
- response.should be_success
- response.should render_template(:index)
+ expect(response).to be_success
+ expect(response).to render_template(:index)
end
it "assigns rejected comments" do
get :rejected
- assigns(:comments).first.should eq(comment)
+ expect(assigns(:comments).first).to eq(comment)
end
end
@@ -73,12 +73,12 @@ module Refinery
it "redirects on success" do
post :reject, :id => comment.id
- response.should be_redirect
+ expect(response).to be_redirect
end
it "rejects the comment" do
post :reject, :id => comment.id
- Refinery::Blog::Comment.rejected.count.should eq(1)
+ expect(Refinery::Blog::Comment.rejected.count).to eq(1)
end
end
end
diff --git a/spec/controllers/refinery/blog/posts_controller_spec.rb b/spec/controllers/refinery/blog/posts_controller_spec.rb
index 4b62d53..7265d64 100644
--- a/spec/controllers/refinery/blog/posts_controller_spec.rb
+++ b/spec/controllers/refinery/blog/posts_controller_spec.rb
@@ -11,12 +11,12 @@ module Refinery
it "should not limit rss feed" do
get :index, :format => :rss
- assigns[:posts].size.should == 3
+ expect(assigns[:posts].size).to eq(3)
end
it "should limit rss feed" do
get :index, :format => :rss, :max_results => 2
- assigns[:posts].count.should == 2
+ expect(assigns[:posts].count).to eq(2)
end
end
end
diff --git a/spec/features/refinery/blog/admin/categories_spec.rb b/spec/features/refinery/blog/admin/categories_spec.rb
index 507f417..7a8df8c 100644
--- a/spec/features/refinery/blog/admin/categories_spec.rb
+++ b/spec/features/refinery/blog/admin/categories_spec.rb
@@ -16,12 +16,12 @@ describe "Categories admin", type: :feature do
click_button "Save"
category = Refinery::Blog::Category.first
- category.title.should eq(title)
+ expect(category.title).to eq(title)
end
context "with translations" do
before do
- Refinery::I18n.stub(:frontend_locales).and_return([:en, :ru])
+ allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
blog_page = Globalize.with_locale(:en) { FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog") }
Globalize.with_locale(:ru) do
blog_page.title = 'блог'
@@ -35,32 +35,32 @@ describe "Categories admin", type: :feature do
visit refinery.blog_admin_posts_path
click_link "Create new category"
fill_in "Title", :with => "Testing Category"
- click_button "Save"
- @c = Refinery::Blog::Category.find_by_title("Testing Category")
+ expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1)
+ @c = Refinery::Blog::Category.by_title("Testing Category")
end
it "suceeds" do
- page.should have_content("'#{@c.title}' was successfully added.")
- Refinery::Blog::Category.count.should eq(1)
+ expect(page).to have_content("'#{@c.title}' was successfully added.")
+ expect(Refinery::Blog::Category.count).to eq(1)
end
- it "shows locale flag for category" do
+ it "shows locale for category" do
click_link "Manage"
within "#category_#{@c.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).to have_css(".locale_icon.en")
end
end
it "shows up in blog page for default locale" do
visit refinery.blog_root_path
within "#categories" do
- page.should have_selector('li')
+ expect(page).to have_selector('li')
end
end
it "does not show up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
- page.should_not have_selector('#categories')
+ expect(page).not_to have_selector('#categories')
end
end
@@ -73,41 +73,41 @@ describe "Categories admin", type: :feature do
visit refinery.blog_admin_posts_path
click_link "Create new category"
within "#switch_locale_picker" do
- click_link "ru"
+ click_link "RU"
end
fill_in "Title", :with => ru_category_title
- click_button "Save"
- @c = Refinery::Blog::Category.find_by_title(ru_category_title)
+ expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1)
+ @c = Refinery::Blog::Category.by_title(ru_category_title)
end
it "suceeds" do
- page.should have_content("'#{@c.title}' was successfully added.")
- Refinery::Blog::Category.count.should eq(1)
+ expect(page).to have_content("'#{@c.title}' was successfully added.")
+ expect(Refinery::Blog::Category.count).to eq(1)
end
- it "shows locale flag for category" do
+ it "shows locale for category" do
click_link "Manage"
within "#category_#{@c.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
+ expect(page).to have_css(".locale_icon.ru")
end
end
- it "does not show locale flag for primary locale" do
+ it "does not show locale for primary locale" do
click_link "Manage"
within "#category_#{@c.id}" do
- page.should_not have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).not_to have_css(".locale_icon.en")
end
end
it "does not shows up in blog page for default locale" do
visit refinery.blog_root_path
- page.should_not have_selector('#categories')
+ expect(page).not_to have_selector('#categories')
end
it "shows up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
within "#categories" do
- page.should have_selector('li')
+ expect(page).to have_selector('li')
end
end
diff --git a/spec/features/refinery/blog/admin/comments_spec.rb b/spec/features/refinery/blog/admin/comments_spec.rb
index 0eb5108..097210d 100644
--- a/spec/features/refinery/blog/admin/comments_spec.rb
+++ b/spec/features/refinery/blog/admin/comments_spec.rb
@@ -16,7 +16,7 @@ module Refinery
it "should list no comments" do
visit refinery.blog_admin_comments_path
- page.should have_content('There are no new comments')
+ expect(page).to have_content('There are no new comments')
end
end
context "when has new unapproved comments" do
@@ -24,20 +24,20 @@ module Refinery
before { 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)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to 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")
+ expect(page).to 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")
+ expect(page).to have_content("has been rejected")
end
end
end
@@ -50,7 +50,7 @@ module Refinery
end
it "should list no comments" do
- page.should have_content('There are no approved comments')
+ expect(page).to have_content('There are no approved comments')
end
end
context "when has approved comments" do
@@ -60,14 +60,14 @@ module Refinery
before { 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)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to 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")
+ expect(page).to have_content("has been rejected")
end
end
end
@@ -80,7 +80,7 @@ module Refinery
end
it "should list no comments" do
- page.should have_content('There are no rejected comments')
+ expect(page).to have_content('There are no rejected comments')
end
end
context "when has rejected comments" do
@@ -90,14 +90,14 @@ module Refinery
before { 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)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to 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")
+ expect(page).to have_content("has been approved")
end
end
end
@@ -106,13 +106,13 @@ module Refinery
let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
before { 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)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to 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")
+ expect(page).to have_content("has been approved")
end
end
end
diff --git a/spec/features/refinery/blog/admin/menu_spec.rb b/spec/features/refinery/blog/admin/menu_spec.rb
index 3411c6c..748d5c3 100644
--- a/spec/features/refinery/blog/admin/menu_spec.rb
+++ b/spec/features/refinery/blog/admin/menu_spec.rb
@@ -8,6 +8,6 @@ describe "Blog menu entry", type: :feature do
within("#menu") { click_link "Blog" }
- page.should have_css("a.active", :text => "Blog")
+ expect(page).to have_css("a.active", :text => "Blog")
end
end
diff --git a/spec/features/refinery/blog/admin/posts_spec.rb b/spec/features/refinery/blog/admin/posts_spec.rb
index 591c6b0..c139b0d 100644
--- a/spec/features/refinery/blog/admin/posts_spec.rb
+++ b/spec/features/refinery/blog/admin/posts_spec.rb
@@ -18,7 +18,7 @@ module Refinery
before { 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.")
+ expect(page).to have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.")
end
end
@@ -29,42 +29,44 @@ module Refinery
end
it "should have Tags" do
- page.should have_content("Tags")
+ expect(page).to have_content("Tags")
end
it "should have category title", :js => true do
click_link "toggle_advanced_options"
- page.should have_content(blog_category.title)
+ expect(page).to have_content(blog_category.title)
end
describe "create blog post", :js => true do
before do
- subject.class.count.should eq(0)
+ expect(subject.class.count).to eq(0)
fill_in "post_title", :with => "This is my blog post"
# this is a dirty hack but textarea that needs to be filled is
# hidden and capybara refuses to fill in elements it can't see
page.evaluate_script("WYMeditor.INSTANCES[0].html('<p>And I love it</p>')")
click_link "toggle_advanced_options"
- page.should have_css '.blog_categories'
- page.should have_css "#post_category_ids_#{blog_category.id}"
+ sleep 1
+ expect(page).to have_css '.blog_categories'
+ expect(page).to have_css "#post_category_ids_#{blog_category.id}"
+ expect(page).to have_selector("#post_category_ids_#{blog_category.id}:not(:checked)")
check blog_category.title
- find(:css, "#post_category_ids_#{blog_category.id}").checked?.should be_truthy
+ expect(page).to have_selector("#post_category_ids_#{blog_category.id}:checked")
click_button "Save"
- page.should have_content("was successfully added.")
+ expect(page).to have_content("was successfully added.")
end
it "should be the only blog post" do
- subject.class.count.should eq(1)
+ expect(subject.class.count).to eq(1)
end
it "should belong to me" do
- subject.class.first.author.should eq(::Refinery::User.last)
+ expect(subject.class.first.author).to eq(::Refinery::User.last)
end
it "should save categories" do
- subject.class.last.categories.count.should eq(1)
- subject.class.last.categories.first.title.should eq(blog_category.title)
+ expect(subject.class.last.categories.count).to eq(1)
+ expect(subject.class.last.categories.first.title).to eq(blog_category.title)
end
end
@@ -80,15 +82,15 @@ module Refinery
end
it "should succeed" do
- page.should have_content("was successfully added.")
+ expect(page).to have_content("was successfully added.")
end
it "should be the only blog post" do
- subject.class.count.should eq(1)
+ expect(subject.class.count).to eq(1)
end
it "should have the specified tags" do
- subject.class.last.tag_list.sort.should eq(tag_list.split(', ').sort)
+ expect(subject.class.last.tag_list.sort).to eq(tag_list.split(', ').sort)
end
end
end
@@ -104,26 +106,26 @@ module Refinery
describe "edit blog post" do
it "should succeed" do
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
click_link("Edit this blog post")
- current_path.should == refinery.edit_blog_admin_post_path(blog_post)
+ expect(current_path).to eq(refinery.edit_blog_admin_post_path(blog_post))
fill_in "post_title", :with => "hax0r"
click_button "Save"
- page.should_not have_content(blog_post.title)
- page.should have_content("'hax0r' was successfully updated.")
+ expect(page).not_to have_content(blog_post.title)
+ expect(page).to have_content("'hax0r' was successfully updated.")
end
end
describe "deleting blog post" do
it "should succeed" do
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
click_link "Remove this blog post forever"
- page.should have_content("'#{blog_post.title}' was successfully removed.")
+ expect(page).to have_content("'#{blog_post.title}' was successfully removed.")
end
end
@@ -131,8 +133,8 @@ 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)
- page.should have_content(blog_post.title)
+ expect(current_path).to eq(refinery.blog_post_path(blog_post))
+ expect(page).to have_content(blog_post.title)
end
end
end
@@ -140,7 +142,7 @@ module Refinery
context "when uncategorized post" do
it "shows up in the list" do
visit refinery.uncategorized_blog_admin_posts_path
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
end
end
@@ -150,7 +152,7 @@ module Refinery
blog_post.save!
visit refinery.uncategorized_blog_admin_posts_path
- page.should_not have_content(blog_post.title)
+ expect(page).not_to have_content(blog_post.title)
end
end
end
@@ -169,15 +171,15 @@ module Refinery
page.evaluate_script("WYMeditor.INSTANCES[0].html('<p>I totally did not write it.</p>')")
click_link "toggle_advanced_options"
-
+ expect(page).to have_content("Author")
select other_guy.username, :from => "Author"
click_button "Save"
- page.should have_content("was successfully added.")
+ expect(page).to have_content("was successfully added.")
end
it "belongs to another user" do
- subject.class.last.author.should eq(other_guy)
+ expect(subject.class.last.author).to eq(other_guy)
end
end
end
@@ -185,7 +187,7 @@ module Refinery
context "with translations" do
before do
Globalize.locale = :en
- Refinery::I18n.stub(:frontend_locales).and_return([:en, :ru])
+ allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
blog_page = FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog")
Globalize.with_locale(:ru) do
blog_page.title = 'блог'
@@ -200,29 +202,29 @@ module Refinery
fill_in "Title", :with => "Post"
fill_in "post_body", :with => "One post in my blog"
click_button "Save"
- @p = Refinery::Blog::Post.find_by_title("Post")
+ @p = Refinery::Blog::Post.by_title("Post")
end
it "succeeds" do
- page.should have_content("'Post' was successfully added.")
- Refinery::Blog::Post.count.should eq(1)
+ expect(page).to have_content("'Post' was successfully added.")
+ expect(Refinery::Blog::Post.count).to eq(1)
end
- it "shows locale flag for post" do
+ it "shows locale for post" do
within "#post_#{@p.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).to have_css(".locale_icon.en")
end
end
it "shows up in blog page for default locale" do
visit refinery.blog_root_path
- page.should have_selector("#post_#{@p.id}")
+ expect(page).to have_selector("#post_#{@p.id}")
end
it "does not show up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
- page.should_not have_selector("#post_#{@p.id}")
+ expect(page).not_to have_selector("#post_#{@p.id}")
end
end
@@ -234,45 +236,45 @@ module Refinery
before do
click_link "Create new post"
within "#switch_locale_picker" do
- click_link "ru"
+ click_link "RU"
end
fill_in "Title", :with => ru_page_title
fill_in "post_body", :with => "One post in my blog"
click_button "Save"
- @p = Refinery::Blog::Post.find_by_title("Новости")
+ @p = Refinery::Blog::Post.by_title(ru_page_title)
end
it "succeeds" do
- page.should have_content("was successfully added.")
- Refinery::Blog::Post.count.should eq(1)
+ expect(page).to have_content("was successfully added.")
+ expect(Refinery::Blog::Post.count).to eq(1)
end
it "shows title in secondary locale" do
within "#post_#{@p.id}" do
- page.should have_content(ru_page_title)
+ expect(page).to have_content(ru_page_title)
end
end
- it "shows locale flag for post" do
+ it "shows locale for post" do
within "#post_#{@p.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
+ expect(page).to have_css(".locale_icon.ru")
end
end
- it "does not show locale flag for primary locale" do
+ it "does not show locale for primary locale" do
within "#post_#{@p.id}" do
- page.should_not have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).not_to have_css(".locale_icon.en")
end
end
it "does not show up in blog page for default locale" do
visit refinery.blog_root_path
- page.should_not have_selector("#post_#{@p.id}")
+ expect(page).not_to have_selector("#post_#{@p.id}")
end
it "shows up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
- page.should have_selector("#post_#{@p.id}")
+ expect(page).to have_selector("#post_#{@p.id}")
end
end
@@ -292,10 +294,10 @@ module Refinery
visit refinery.blog_admin_posts_path
end
- it "shows both locale flags for post" do
+ it "shows both locales for post" do
within "#post_#{blog_post.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
- page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
+ expect(page).to have_css(".locale_icon.en")
+ expect(page).to have_css(".locale_icon.ru")
end
end
@@ -303,28 +305,28 @@ module Refinery
it "succeeds" do
within "#post_#{blog_post.id}" do
- click_link("En")
+ click_link("EN")
end
- current_path.should == refinery.edit_blog_admin_post_path(blog_post)
+ expect(current_path).to eq(refinery.edit_blog_admin_post_path(blog_post))
fill_in "Title", :with => "New Post Title"
click_button "Save"
- page.should_not have_content(blog_post.title)
- page.should have_content("'New Post Title' was successfully updated.")
+ expect(page).not_to have_content(blog_post.title)
+ expect(page).to have_content("'New Post Title' was successfully updated.")
end
end
describe "edit the post in secondary locale" do
it "succeeds" do
within "#post_#{blog_post.id}" do
- click_link("ru")
+ click_link("RU")
end
fill_in "Title", :with => "Нов"
click_button "Save"
- page.should_not have_content(blog_post.title)
- page.should have_content("'Нов' was successfully updated.")
+ expect(page).not_to have_content(blog_post.title)
+ expect(page).to have_content("'Нов' was successfully updated.")
end
end
diff --git a/spec/features/refinery/blog/categories_spec.rb b/spec/features/refinery/blog/categories_spec.rb
index efcf388..b778254 100644
--- a/spec/features/refinery/blog/categories_spec.rb
+++ b/spec/features/refinery/blog/categories_spec.rb
@@ -19,8 +19,8 @@ module Refinery
describe "show categories blog posts" do
it "should displays categories blog posts" do
visit refinery.blog_category_path(@category)
- page.should have_content("Refinery CMS blog post")
- page.should have_content("Video Games")
+ expect(page).to have_content("Refinery CMS blog post")
+ expect(page).to have_content("Video Games")
end
end
end
diff --git a/spec/features/refinery/blog/posts_spec.rb b/spec/features/refinery/blog/posts_spec.rb
index daba07e..a96b63a 100644
--- a/spec/features/refinery/blog/posts_spec.rb
+++ b/spec/features/refinery/blog/posts_spec.rb
@@ -12,7 +12,7 @@ module Refinery
it "should display blog post" do
visit refinery.blog_post_path(blog_post)
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
end
describe "visit blog" do
@@ -25,14 +25,14 @@ module Refinery
it "shows blog link in menu" do
visit "/"
within "#menu" do
- page.should have_content("Blog")
- page.should have_selector("a[href='/blog']")
+ expect(page).to have_content("Blog")
+ expect(page).to have_selector("a[href='/blog']")
end
end
it "shows blog posts" do
visit refinery.blog_root_path
- page.should have_content blog_post.title
+ expect(page).to have_content blog_post.title
end
end
@@ -51,8 +51,8 @@ module Refinery
it "should have one tagged post" do
visit refinery.blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
- page.should have_content(@tag_name)
- page.should have_content(@post.title)
+ expect(page).to have_content(@tag_name)
+ expect(page).to have_content(@post.title)
end
end
end
@@ -63,8 +63,8 @@ module Refinery
it "should display the blog post" do
visit refinery.blog_post_path(blog_post)
- page.should have_content(blog_post.title)
- page.should have_content(blog_post.body)
+ expect(page).to have_content(blog_post.title)
+ expect(page).to have_content(blog_post.body)
end
end
context "when has approved comments" do
@@ -73,8 +73,8 @@ module Refinery
it "should display the comments" do
visit refinery.blog_post_path(approved_comment.post)
- page.should have_content(approved_comment.body)
- page.should have_content("Posted by #{approved_comment.name}")
+ expect(page).to have_content(approved_comment.body)
+ expect(page).to have_content("Posted by #{approved_comment.name}")
end
end
context "when has rejected comments" do
@@ -83,7 +83,7 @@ module Refinery
it "should not display the comments" do
visit refinery.blog_post_path(rejected_comment.post)
- page.should_not have_content(rejected_comment.body)
+ expect(page).not_to have_content(rejected_comment.body)
end
end
context "when has new comments" do
@@ -92,7 +92,7 @@ module Refinery
it "should not display the comments" do
visit refinery.blog_post_path(blog_comment.post)
- page.should_not have_content(blog_comment.body)
+ expect(page).not_to have_content(blog_comment.body)
end
end
@@ -114,9 +114,9 @@ module Refinery
it "creates the comment" do
comment = blog_post.reload.comments.last
- comment.name.should eq(name)
- comment.email.should eq(email)
- comment.body.should eq(body)
+ expect(comment.name).to eq(name)
+ expect(comment.email).to eq(email)
+ expect(comment.body).to eq(body)
end
end
@@ -129,13 +129,13 @@ module Refinery
end
it "should increment access count" do
- blog_post.reload.access_count.should eq(1)
+ expect(blog_post.reload.access_count).to eq(1)
visit refinery.blog_post_path(blog_post)
- blog_post.reload.access_count.should eq(2)
+ expect(blog_post.reload.access_count).to eq(2)
end
it "should be most popular" do
- Refinery::Blog::Post.popular(2).first.should eq(blog_post)
+ expect(Refinery::Blog::Post.popular(2).first).to eq(blog_post)
end
end
@@ -144,7 +144,7 @@ module Refinery
let!(:blog_post2) { FactoryGirl.create(:blog_post, :published_at => Time.now - 2.minutes) }
it "should be the most recent" do
- Refinery::Blog::Post.recent(2).first.id.should eq(blog_post2.id)
+ expect(Refinery::Blog::Post.recent(2).first.id).to eq(blog_post2.id)
end
end
@@ -157,7 +157,7 @@ module Refinery
it "should display the draft notification" do
visit refinery.blog_post_path(blog_post)
- page.should have_content('This page is NOT live for public viewing.')
+ expect(page).to have_content('This page is NOT live for public viewing.')
end
end
@@ -172,7 +172,7 @@ module Refinery
it "should not display the blog post" do
visit refinery.blog_post_path(blog_post)
- page.should have_content("The page you requested was not found.")
+ expect(page).to have_content("The page you requested was not found.")
end
end
end
diff --git a/spec/helpers/refinery/blog/posts_helper_spec.rb b/spec/helpers/refinery/blog/posts_helper_spec.rb
index 4a791d9..4e19999 100644
--- a/spec/helpers/refinery/blog/posts_helper_spec.rb
+++ b/spec/helpers/refinery/blog/posts_helper_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
module Refinery
module Blog
- describe PostsHelper do
+ describe PostsHelper, :type => :helper do
describe "#blog_archive_widget", type: :helper do
let(:html) { helper.blog_archive_widget(dates) }
let(:links) { Capybara.string(html).find("#blog_archive_widget ul") }
@@ -11,7 +11,7 @@ module Refinery
let(:dates) { [] }
it "does not display anything" do
- html.should be_blank
+ expect(html).to be_blank
end
end
@@ -29,18 +29,18 @@ module Refinery
month = Date::MONTHNAMES[recent_post.month]
year = recent_post.year
- links.should have_link("#{month} #{year} (3)")
+ expect(links).to have_link("#{month} #{year} (3)")
end
it "has a link for the year of dates older than one year" do
year = old_post.year
- links.should have_link("#{year} (3)")
+ expect(links).to have_link("#{year} (3)")
end
it "sorts recent links before old links" do
- links.find("li:first").should have_content(recent_post.year.to_s)
- links.find("li:last").should have_content(old_post.year.to_s)
+ expect(links.find("li:first")).to have_content(recent_post.year.to_s)
+ expect(links.find("li:last")).to have_content(old_post.year.to_s)
end
end
@@ -50,8 +50,8 @@ module Refinery
it "sorts by the more recent date" do
first, second = dates.map {|p| Date::MONTHNAMES[p.month] }
- links.find("li:first").should have_content(second)
- links.find("li:last").should have_content(first)
+ expect(links.find("li:first")).to have_content(second)
+ expect(links.find("li:last")).to have_content(first)
end
end
@@ -61,8 +61,8 @@ module Refinery
it "sorts by the more recent date" do
first, second = dates.map {|p| p.year.to_s }
- links.find("li:first").should have_content(second)
- links.find("li:last").should have_content(first)
+ expect(links.find("li:first")).to have_content(second)
+ expect(links.find("li:last")).to have_content(first)
end
end
end
@@ -71,11 +71,11 @@ module Refinery
let(:email) { "test@test.com" }
it "returns gravatar url" do
- helper.avatar_url(email).should eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=60.jpg")
+ expect(helper.avatar_url(email)).to eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=60.jpg")
end
it "accepts options hash to change default size" do
- helper.avatar_url(email, :size => 55).should eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=55.jpg")
+ expect(helper.avatar_url(email, :size => 55)).to eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=55.jpg")
end
end
end
diff --git a/spec/lib/refinery/blog/engine_spec.rb b/spec/lib/refinery/blog/engine_spec.rb
index 0e2952d..37edce3 100644
--- a/spec/lib/refinery/blog/engine_spec.rb
+++ b/spec/lib/refinery/blog/engine_spec.rb
@@ -8,7 +8,7 @@ module Refinery
Engine.load_seed
Engine.load_seed
- Refinery::Page.where(:link_url => '/blog').count.should eq(1)
+ expect(Refinery::Page.where(:link_url => '/blog').count).to eq(1)
end
end
end
diff --git a/spec/models/refinery/blog/category_spec.rb b/spec/models/refinery/blog/category_spec.rb
index 0292991..577cb9d 100644
--- a/spec/models/refinery/blog/category_spec.rb
+++ b/spec/models/refinery/blog/category_spec.rb
@@ -8,17 +8,17 @@ module Refinery
describe "validations" do
it "requires title" do
- FactoryGirl.build(:blog_category, :title => "").should_not be_valid
+ expect(FactoryGirl.build(:blog_category, :title => "")).not_to be_valid
end
it "won't allow duplicate titles" do
- FactoryGirl.build(:blog_category, :title => category.title).should_not be_valid
+ expect(FactoryGirl.build(:blog_category, :title => category.title)).not_to be_valid
end
end
describe "blog posts association" do
it "has a posts attribute" do
- category.should respond_to(:posts)
+ expect(category).to respond_to(:posts)
end
it "returns posts by published_at date in descending order" do
@@ -32,7 +32,7 @@ module Refinery
:published_at => Time.now,
:author => refinery_user })
- category.posts.newest_first.first.should == latest_post
+ expect(category.posts.newest_first.first).to eq(latest_post)
end
end
@@ -42,7 +42,7 @@ module Refinery
2.times do
category.posts << FactoryGirl.create(:blog_post)
end
- category.post_count.should == 2
+ expect(category.post_count).to eq(2)
end
end
end
diff --git a/spec/models/refinery/blog/comment_spec.rb b/spec/models/refinery/blog/comment_spec.rb
index 7a35a59..69430ac 100644
--- a/spec/models/refinery/blog/comment_spec.rb
+++ b/spec/models/refinery/blog/comment_spec.rb
@@ -7,11 +7,11 @@ module Refinery
let(:comment) { FactoryGirl.create(:blog_comment) }
it "saves" do
- comment.should_not be_nil
+ expect(comment).not_to be_nil
end
it "has a blog post" do
- comment.post.should_not be_nil
+ expect(comment.post).not_to be_nil
end
end
end
diff --git a/spec/models/refinery/blog/post_spec.rb b/spec/models/refinery/blog/post_spec.rb
index 73668e4..a56a33b 100644
--- a/spec/models/refinery/blog/post_spec.rb
+++ b/spec/models/refinery/blog/post_spec.rb
@@ -7,51 +7,51 @@ module Refinery
describe "validations" do
it "requires title" do
- FactoryGirl.build(:blog_post, :title => "").should_not be_valid
+ expect(FactoryGirl.build(:blog_post, :title => "")).not_to be_valid
end
it "won't allow duplicate titles" do
- FactoryGirl.build(:blog_post, :title => post.title).should_not be_valid
+ expect(FactoryGirl.build(:blog_post, :title => post.title)).not_to be_valid
end
it "requires body" do
- FactoryGirl.build(:blog_post, :body => nil).should_not be_valid
+ expect(FactoryGirl.build(:blog_post, :body => nil)).not_to be_valid
end
end
describe "comments association" do
it "have a comments attribute" do
- post.should respond_to(:comments)
+ expect(post).to respond_to(:comments)
end
it "destroys associated comments" do
FactoryGirl.create(:blog_comment, :blog_post_id => post.id)
post.destroy
- Blog::Comment.where(:blog_post_id => post.id).should be_empty
+ expect(Blog::Comment.where(:blog_post_id => post.id)).to be_empty
end
end
describe "categories association" do
it "have categories attribute" do
- post.should respond_to(:categories)
+ expect(post).to respond_to(:categories)
end
end
describe "tags" do
it "acts as taggable" do
- post.should respond_to(:tag_list)
+ expect(post).to respond_to(:tag_list)
post.tag_list = "refinery, cms"
post.save!
- post.tag_list.should include("refinery")
+ expect(post.tag_list).to include("refinery")
end
end
describe "authors" do
it "are authored" do
- described_class.instance_methods.map(&:to_sym).should include(:author)
+ expect(described_class.instance_methods.map(&:to_sym)).to include(:author)
end
end
@@ -67,8 +67,8 @@ module Refinery
it "returns all posts from specified month" do
#check for this month
date = "03/2011"
- described_class.by_month(Time.parse(date)).count.should be == 2
- described_class.by_month(Time.parse(date)).should == [@post2, @post1]
+ expect(described_class.by_month(Time.parse(date)).count).to eq(2)
+ expect(described_class.by_month(Time.parse(date))).to eq([@post2, @post1])
end
end
@@ -82,7 +82,7 @@ module Refinery
it "returns all published dates older than the argument" do
expected = [@post2.published_at, @post1.published_at]
- described_class.published_dates_older_than(5.minutes.ago).should eq(expected)
+ expect(described_class.published_dates_older_than(5.minutes.ago)).to eq(expected)
end
end
@@ -96,9 +96,9 @@ module Refinery
it "returns all posts which aren't in draft and pub date isn't in future" do
live_posts = described_class.live
- live_posts.count.should be == 2
- live_posts.should include(@post2)
- live_posts.should include(@post1)
+ expect(live_posts.count).to eq(2)
+ expect(live_posts).to include(@post2)
+ expect(live_posts).to include(@post1)
end
end
@@ -111,22 +111,22 @@ module Refinery
end
it "returns uncategorized posts if they exist" do
- described_class.uncategorized.should include @uncategorized_post
- described_class.uncategorized.should_not include @categorized_post
+ expect(described_class.uncategorized).to include @uncategorized_post
+ expect(described_class.uncategorized).not_to include @categorized_post
end
end
describe "#live?" do
it "returns true if post is not in draft and it's published" do
- FactoryGirl.build(:blog_post).should be_live
+ expect(FactoryGirl.build(:blog_post)).to be_live
end
it "returns false if post is in draft" do
- FactoryGirl.build(:blog_post, :draft => true).should_not be_live
+ expect(FactoryGirl.build(:blog_post, :draft => true)).not_to be_live
end
it "returns false if post pub date is in future" do
- FactoryGirl.build(:blog_post, :published_at => Time.now.advance(:minutes => 1)).should_not be_live
+ expect(FactoryGirl.build(:blog_post, :published_at => Time.now.advance(:minutes => 1))).not_to be_live
end
end
@@ -137,7 +137,7 @@ module Refinery
end
it "returns next article when called on current article" do
- described_class.newest_first.last.next.should == @post
+ expect(described_class.newest_first.last.next).to eq(@post)
end
end
@@ -148,7 +148,7 @@ module Refinery
end
it "returns previous article when called on current article" do
- described_class.first.prev.should == @post
+ expect(described_class.first.prev).to eq(@post)
end
end
@@ -159,7 +159,7 @@ module Refinery
end
it "should be true" do
- described_class.comments_allowed?.should be_truthy
+ expect(described_class.comments_allowed?).to be_truthy
end
end
@@ -169,14 +169,14 @@ module Refinery
end
it "should be false" do
- described_class.comments_allowed?.should be_falsey
+ expect(described_class.comments_allowed?).to be_falsey
end
end
end
describe "custom teasers" do
it "should allow a custom teaser" do
- FactoryGirl.create(:blog_post, :custom_teaser => 'This is some custom content').should be_valid
+ expect(FactoryGirl.create(:blog_post, :custom_teaser => 'This is some custom content')).to be_valid
end
end
@@ -187,7 +187,7 @@ module Refinery
end
it "should be true" do
- described_class.teasers_enabled?.should be_truthy
+ expect(described_class.teasers_enabled?).to be_truthy
end
end
@@ -197,7 +197,7 @@ module Refinery
end
it "should be false" do
- described_class.teasers_enabled?.should be_falsey
+ expect(described_class.teasers_enabled?).to be_falsey
end
end
end
@@ -205,9 +205,9 @@ module Refinery
describe "source url" do
it "should allow a source url and title" do
p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'author')
- p.should be_valid
- p.source_url.should include('google')
- p.source_url_title.should include('author')
+ expect(p).to be_valid
+ expect(p.source_url).to include('google')
+ expect(p.source_url_title).to include('author')
end
end
@@ -217,10 +217,10 @@ module Refinery
Refinery::Blog.validate_source_url = true
end
it "should have canonical url" do
- UrlValidator.any_instance.should_receive(:resolve_redirects_verify_url).
+ expect_any_instance_of(UrlValidator).to receive(:resolve_redirects_verify_url).
and_return('http://www.google.com')
p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'google')
- p.source_url.should include('www')
+ expect(p.source_url).to include('www')
end
end
context "with Refinery::Blog.validate_source_url set to false" do
@@ -229,7 +229,7 @@ module Refinery
end
it "should have original url" do
p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'google')
- p.source_url.should_not include('www')
+ expect(p.source_url).not_to include('www')
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4b29712..bddb8bc 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -7,19 +7,18 @@ 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
+require 'capybara/poltergeist'
+Capybara.javascript_driver = :poltergeist
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories including factories.