Permalink
Browse files

Remove all instances of 'stub!' with 'stub' to avoid deprecation mess…

…ages in MenuRendererSpec
  • Loading branch information...
1 parent aaeef17 commit b634a1ab4de1c8ea5519e1c8f25ad4b07d2f2495 @jomz jomz committed Feb 8, 2014
Showing with 38 additions and 38 deletions.
  1. +38 −38 spec/models/menu_renderer_spec.rb
View
76 spec/models/menu_renderer_spec.rb
@@ -45,7 +45,7 @@ module SpecialTestMenuRenderer; end
let(:alternate_page){
alternate_page = AlternatePage.new
alternate_page.extend MenuRenderer
- alternate_page.stub!(:view).and_return(view)
+ alternate_page.stub(:view).and_return(view)
alternate_page
}
let(:special_page){
@@ -91,7 +91,7 @@ module SpecialTestMenuRenderer; end
special_page.menu_renderer_module_name.should == 'SpecialTestMenuRenderer'
end
it 'should return the module name if the class_name is nil' do
- special_page.stub!(:class_name).and_return(nil)
+ special_page.stub(:class_name).and_return(nil)
special_page.menu_renderer_module_name.should == 'MenuRenderer'
end
end
@@ -131,7 +131,7 @@ module SpecialTestMenuRenderer; end
before do
@link_text = 'New Page Link'
I18n.should_receive(:t).and_return(@link_text)
- view.stub!(:new_admin_page_child_path).and_return'/pages/new'
+ view.stub(:new_admin_page_child_path).and_return'/pages/new'
special_page.default_child = SpecialChildPage
end
it 'should return a menu item for the default child type' do
@@ -158,9 +158,9 @@ module SpecialTestMenuRenderer; end
describe '#child_items' do
before do
- alternate_page.stub!(:allowed_child_classes).and_return [Page, SpecialChildPage, SuperSpecialChildPage]
- AlternatePage.stub!(:default_child).and_return(SpecialChildPage)
- view.stub!(:new_admin_page_child_path).and_return'/pages/new'
+ alternate_page.stub(:allowed_child_classes).and_return [Page, SpecialChildPage, SuperSpecialChildPage]
+ AlternatePage.stub(:default_child).and_return(SpecialChildPage)
+ view.stub(:new_admin_page_child_path).and_return'/pages/new'
end
it 'should return a menu item for each of the child types' do
child_types = alternate_page.allowed_child_classes - [alternate_page.default_child]
@@ -180,123 +180,123 @@ module SpecialTestMenuRenderer; end
describe '#menu_items' do
it 'should return a collection of the default child, separator and menu items' do
default_child_item = Object.new
- special_page.stub!(:default_child_item).and_return(default_child_item)
+ special_page.stub(:default_child_item).and_return(default_child_item)
separator_item = Object.new
- special_page.stub!(:separator_item).and_return(separator_item)
+ special_page.stub(:separator_item).and_return(separator_item)
child = Object.new
child_items = [child]
- special_page.stub!(:child_items).and_return(child_items)
+ special_page.stub(:child_items).and_return(child_items)
special_page.menu_items.should == [default_child_item, separator_item, child]
end
end
describe '#menu_list' do
it 'should return a list of all menu items' do
- special_page.stub!(:menu_items).and_return(['-- menu items --'])
+ special_page.stub(:menu_items).and_return(['-- menu items --'])
special_page.menu_list.should match(/<ul class="menu" id="allowed_children_#{special_page.id}">-- menu items --<\/ul>/)
end
end
describe '#remove_link' do
it 'should return a link to remove the page' do
- I18n.stub!(:t).with('remove').and_return('Remove')
+ I18n.stub(:t).with('remove').and_return('Remove')
path = '/page/remove/url'
- view.stub!(:remove_admin_page_url).and_return(path)
+ view.stub(:remove_admin_page_url).and_return(path)
image = 'image'
- view.stub!(:image).and_return(image)
+ view.stub(:image).and_return(image)
special_page.remove_link.should match(/<a href="#{path}" class="action">#{image} Remove<\/a>/)
end
end
describe '#remove_option' do
it 'should return the remove_link' do
link = '-- remove link --'
- special_page.stub!(:remove_link).and_return(link)
+ special_page.stub(:remove_link).and_return(link)
special_page.remove_option.should == link
end
end
describe '#add_child_disabled?' do
it 'should return true if there are no allowed_child_classes' do
- special_page.stub!(:allowed_child_classes).and_return([])
+ special_page.stub(:allowed_child_classes).and_return([])
special_page.add_child_disabled?.should be_true
end
it 'should return false if there are allowed_child_classes' do
- special_page.stub!(:allowed_child_classes).and_return(['yes'])
+ special_page.stub(:allowed_child_classes).and_return(['yes'])
special_page.add_child_disabled?.should be_false
end
end
describe '#disabled_add_child_link' do
it 'should not contain a link' do
- view.stub!(:image).and_return('image')
+ view.stub(:image).and_return('image')
special_page.disabled_add_child_link.should_not match('<a.*href=')
end
it 'should have a disable image' do
image = 'disabled'
- view.stub!(:image).and_return(image)
+ view.stub(:image).and_return(image)
special_page.disabled_add_child_link.should match(/#{image}/)
end
it 'should have a disable image' do
image = 'disabled'
- view.stub!(:image).and_return(image)
+ view.stub(:image).and_return(image)
special_page.disabled_add_child_link.should match(/#{image}/)
end
end
describe '#add_child_link' do
it 'should contain a link to the new page form' do
- I18n.stub!(:t).with('add_child').and_return('Add Child')
- special_page.stub!(:default_child).and_return(AlternatePage)
+ I18n.stub(:t).with('add_child').and_return('Add Child')
+ special_page.stub(:default_child).and_return(AlternatePage)
path = '/pages/new?page_class=' + special_page.default_child.name
- view.stub!(:new_admin_page_child_path).and_return path
- view.stub!(:image).and_return 'image'
+ view.stub(:new_admin_page_child_path).and_return path
+ view.stub(:image).and_return 'image'
special_page.add_child_link.should match(/<a href="#{Regexp.quote(path)}".*>#{view.image} Add Child/)
end
end
describe '#add_child_link_with_menu_hook' do
it 'should contain a link to the new menu element' do
- I18n.stub!(:t).with('add_child').and_return('Add Child')
- special_page.stub!(:default_child).and_return(AlternatePage)
+ I18n.stub(:t).with('add_child').and_return('Add Child')
+ special_page.stub(:default_child).and_return(AlternatePage)
path = '/pages/new?page_class=' + special_page.default_child.name
- view.stub!(:new_admin_page_child_path).and_return path
- view.stub!(:image).and_return 'image'
+ view.stub(:new_admin_page_child_path).and_return path
+ view.stub(:image).and_return 'image'
special_page.add_child_link_with_menu_hook.should match(/<a href="#allowed_children_#{special_page.id}".*class="[^"]*dropdown">/)
end
end
describe '#add_child_menu' do
it 'should return the menu_list' do
- special_page.stub!(:menu_list).and_return('-- menu list --')
+ special_page.stub(:menu_list).and_return('-- menu list --')
special_page.add_child_menu.should == '-- menu list --'
end
end
describe '#add_child_link_with_menu' do
it 'should return the add_child_link_with_menu_hook and the add_child_menu' do
- special_page.stub!(:add_child_link_with_menu_hook).and_return('link with hook ')
- special_page.stub!(:add_child_menu).and_return(' -- menu')
+ special_page.stub(:add_child_link_with_menu_hook).and_return('link with hook ')
+ special_page.stub(:add_child_menu).and_return(' -- menu')
special_page.add_child_link_with_menu.should == 'link with hook -- menu'
end
end
describe '#add_child_option' do
it 'should return a disabled link if add child is disabled' do
- special_page.stub!(:add_child_disabled?).and_return(true)
- special_page.stub!(:disabled_add_child_link).and_return(' disabled link ')
+ special_page.stub(:add_child_disabled?).and_return(true)
+ special_page.stub(:disabled_add_child_link).and_return(' disabled link ')
special_page.add_child_option.should == ' disabled link '
end
it 'should return an add child link if add child is not disabled and the allowed_child_classes count is 1' do
- special_page.stub!(:add_child_disabled?).and_return(false)
- special_page.stub!(:allowed_child_classes).and_return([Page])
- special_page.stub!(:add_child_link).and_return(' link ')
+ special_page.stub(:add_child_disabled?).and_return(false)
+ special_page.stub(:allowed_child_classes).and_return([Page])
+ special_page.stub(:add_child_link).and_return(' link ')
special_page.add_child_option.should == ' link '
end
it 'should return an add child link with menu if add child is not disabled and the allowed_child_classes count is greater than 1' do
- special_page.stub!(:add_child_disabled?).and_return(false)
- special_page.stub!(:allowed_child_classes).and_return([Page, AlternatePage])
- special_page.stub!(:add_child_link_with_menu).and_return(' link with menu ')
+ special_page.stub(:add_child_disabled?).and_return(false)
+ special_page.stub(:allowed_child_classes).and_return([Page, AlternatePage])
+ special_page.stub(:add_child_link_with_menu).and_return(' link with menu ')
special_page.add_child_option.should == ' link with menu '
end
end

0 comments on commit b634a1a

Please sign in to comment.