Skip to content

Commit

Permalink
Upgrade to rspec 3.x syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Nov 26, 2014
1 parent 475ced5 commit bc617e7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ source "http://rubygems.org"

gemspec

gem 'refinerycms', github: 'refinery/refinerycms'
gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n'
gem 'refinerycms', git: 'https://github.com/refinery/refinerycms'
gem 'refinerycms-i18n', git: 'https://github.com/refinery/refinerycms-i18n'
gem 'refinerycms-wymeditor', '~> 1.0.0'

gem "mime-types", "~> 1.25"

group :test do
gem 'refinerycms-testing', github: 'refinery/refinerycms'
gem 'refinerycms-testing', git: 'https://github.com/refinery/refinerycms'
gem 'poltergeist'
end

Expand Down
18 changes: 9 additions & 9 deletions spec/features/admin/page_images_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

describe "page images" do
describe "page images", :type => :feature do
refinery_login_with :refinery_user

let(:configure) {}
Expand All @@ -21,26 +21,26 @@
image
setup_and_visit

page_for_images.images.count.should eq 0
expect(page_for_images.images.count).to eq 0

page.find("#{page_images_tab_id} a").click

# Add the first Image
click_link "Add Image"

page.should have_selector 'iframe#dialog_iframe'
expect(page).to have_selector 'iframe#dialog_iframe'
page.within_frame('dialog_iframe') do
find(:css, "#existing_image_area img#image_#{image.id}").click
click_button ::I18n.t('button_text', :scope => 'refinery.admin.images.existing_image')
end

# image should be visable on the page
page.should have_selector("#page_images li#image_#{image.id}")
expect(page).to have_selector("#page_images li#image_#{image.id}")

click_button "Save"

# image should be in the db
page_for_images.images.count.should eq 1
expect(page_for_images.images.count).to eq 1

end

Expand All @@ -53,21 +53,21 @@

setup_and_visit

page_for_images.images.count.should eq 1
expect(page_for_images.images.count).to eq 1

page.find("#{page_images_tab_id} a").click

page.should have_selector("#page_images li#image_#{page_for_images.images.first.id}")
expect(page).to have_selector("#page_images li#image_#{page_for_images.images.first.id}")

image_li_tag = page.find("#page_images li:first-child")
image_li_tag.hover
within(image_li_tag) { page.find('img:first-child').click }

page.should_not have_selector("#page_images li#image_#{page_for_images.images.first.id}")
expect(page).not_to have_selector("#page_images li#image_#{page_for_images.images.first.id}")

click_button "Save"

page_for_images.images.count.should eq 0
expect(page_for_images.images.count).to eq 0

end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/features/attach_page_images_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

describe "attach page images" do
describe "attach page images", :type => :feature do
refinery_login_with :refinery_user

# No-op block : use default configuration by default
Expand All @@ -19,7 +19,7 @@
it "shows images tab" do
setup_and_visit
within page_images_tab_id do
page.should have_content("Images")
expect(page).to have_content("Images")
end
end

Expand All @@ -31,7 +31,7 @@
click_link "Images"
end

page.should have_content("Add Image")
expect(page).to have_content("Add Image")
end

context "with caption and WYSIWYG disabled" do
Expand All @@ -51,7 +51,7 @@
image_li_tag.hover
within(image_li_tag) { page.find('img.caption').click }

page.find('.ui-dialog textarea').should be_visible
expect(page.find('.ui-dialog textarea')).to be_visible
end
end

Expand Down
12 changes: 6 additions & 6 deletions spec/lib/refinery/initializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Tab; end
end

before(:each) do
Refinery::PageImages.config.stub(:enable_for).and_return(enable_for_config)
allow(Refinery::PageImages.config).to receive(:enable_for).and_return(enable_for_config)
end

def enable_for_config
Expand All @@ -23,18 +23,18 @@ def enable_for_config

describe "attach initializer" do
it "calls attach on all configured model" do
Refinery::PageImages.config.stub(:enable_for).and_return(enable_for_config)
allow(Refinery::PageImages.config).to receive(:enable_for).and_return(enable_for_config)

Refinery::PageImages::EnableForMock::Model.should_receive(:has_many_page_images).once
Refinery::Page.should_not_receive(:has_many_page_images)
expect(Refinery::PageImages::EnableForMock::Model).to receive(:has_many_page_images).once
expect(Refinery::Page).not_to receive(:has_many_page_images)
ActionDispatch::Reloader.prepare!
end
end

describe "attach_initialize_tabs!" do
it "registers tabs for all configured engine" do
Refinery::PageImages::EnableForMock::Tab.should_receive(:register).once
Refinery::Pages::Tab.should_not_receive(:register)
expect(Refinery::PageImages::EnableForMock::Tab).to receive(:register).once
expect(Refinery::Pages::Tab).not_to receive(:register)
Refinery::PageImages::Engine.initialize_tabs!
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/refinery/blog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module Blog
describe Post, type: :model do
it "should not have images" do
blog = FactoryGirl.create(:blog_post)
blog.images.count.should == 0
expect(blog.images.count).to eq(0)
end

it "should have images" do
blog = FactoryGirl.create(:blog_post_with_image)
blog.images.count.should == 1
expect(blog.images.count).to eq(1)
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/models/refinery/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ module Refinery
end

it 'returns an image and a caption' do
page.images_with_captions.count.should eq(0)
expect(page.images_with_captions.count).to eq(0)

page.image_pages.create(image: FactoryGirl.build(:image))
page.images_with_captions.first[:image].should be_a(Refinery::Image)
page.images_with_captions.first[:caption].should be_a(String)
expect(page.images_with_captions.first[:image]).to be_a(Refinery::Image)
expect(page.images_with_captions.first[:caption]).to be_a(String)
end

end
Expand Down Expand Up @@ -53,13 +53,13 @@ module Refinery
},
})

page.images.should eq([images.first])
expect(page.images).to eq([images.first])
end

it "deletes all images" do
page.update_attributes(:images_attributes => {"0" => {"id"=>""}})

page.images.should be_empty
expect(page.images).to be_empty
end

it "reorders images" do
Expand All @@ -81,7 +81,7 @@ module Refinery
},
})

page.images.should eq([images.second, images.first])
expect(page.images).to eq([images.second, images.first])
end
end
end
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

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
Expand Down

0 comments on commit bc617e7

Please sign in to comment.