From 494e38d2f14cd3549d10bafd382d1ab71e5266d1 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Thu, 4 Dec 2014 08:50:09 -0800 Subject: Upgraded to rspec 3.x --- .../refinery/blog/admin/categories_spec.rb | 26 +++--- spec/features/refinery/blog/admin/comments_spec.rb | 32 ++++---- spec/features/refinery/blog/admin/menu_spec.rb | 2 +- spec/features/refinery/blog/admin/posts_spec.rb | 94 +++++++++++----------- spec/features/refinery/blog/categories_spec.rb | 4 +- spec/features/refinery/blog/posts_spec.rb | 42 +++++----- 6 files changed, 100 insertions(+), 100 deletions(-) (limited to 'spec/features') diff --git a/spec/features/refinery/blog/admin/categories_spec.rb b/spec/features/refinery/blog/admin/categories_spec.rb index 507f417..907c6a0 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 = 'блог' @@ -40,27 +40,27 @@ describe "Categories admin", type: :feature do 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 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("img[src='/assets/refinery/icons/flags/en.png']") 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 @@ -81,33 +81,33 @@ describe "Categories admin", type: :feature do 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 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("img[src='/assets/refinery/icons/flags/ru.png']") end end it "does not show locale flag 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("img[src='/assets/refinery/icons/flags/en.png']") 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..4efbc66 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,42 @@ 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('

And I love it

')") click_link "toggle_advanced_options" - page.should have_css '.blog_categories' - page.should have_css "#post_category_ids_#{blog_category.id}" + expect(page).to have_css '.blog_categories' + expect(page).to have_css "#post_category_ids_#{blog_category.id}" check blog_category.title - find(:css, "#post_category_ids_#{blog_category.id}").checked?.should be_truthy + expect(find(:css, "#post_category_ids_#{blog_category.id}").checked?).to be_truthy 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 +80,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 +104,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 +131,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 +140,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 +150,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 @@ -173,11 +173,11 @@ module Refinery 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 +185,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 = 'блог' @@ -204,25 +204,25 @@ module Refinery 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 within "#post_#{@p.id}" do - page.should have_css("img[src='/assets/refinery/icons/flags/en.png']") + expect(page).to have_css("img[src='/assets/refinery/icons/flags/en.png']") 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 @@ -243,36 +243,36 @@ module Refinery 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 within "#post_#{@p.id}" do - page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']") + expect(page).to have_css("img[src='/assets/refinery/icons/flags/ru.png']") end end it "does not show locale flag 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("img[src='/assets/refinery/icons/flags/en.png']") 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 @@ -294,8 +294,8 @@ module Refinery it "shows both locale flags 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("img[src='/assets/refinery/icons/flags/en.png']") + expect(page).to have_css("img[src='/assets/refinery/icons/flags/ru.png']") end end @@ -305,12 +305,12 @@ module Refinery within "#post_#{blog_post.id}" do 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 @@ -323,8 +323,8 @@ module Refinery 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 -- cgit v1.2.3