Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
clean tests and make them pass in the order observed on nix systems
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Aug 13, 2011
1 parent 161878f commit b23f269
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 87 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
@@ -1,9 +1,9 @@
GIT
remote: git://github.com/floehopper/mocha.git
revision: 0ce0adc9f104a0ae2ddca400696c8694e85f1b93
revision: f417066f7f1b7d66cf5c72f28380675bde0cc424
specs:
mocha (0.9.12)
metaid (~> 1.0)
metaclass (~> 0.0.1)

GEM
remote: http://rubygems.org/
Expand Down Expand Up @@ -170,7 +170,7 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaid (1.0)
metaclass (0.0.1)
mime-types (1.16)
mimemagic (0.1.8)
mimetype-fu (0.1.2)
Expand Down
49 changes: 49 additions & 0 deletions Rakefile
Expand Up @@ -20,3 +20,52 @@ task :release => :gem do
end

task :default => [:spec, :cucumber]

# only for running the tests suite in the order observed in *nix systems
task :spec_nix do
files = %w(
lib/core_ext_spec.rb
lib/locomotive/routing/site_dispatcher_spec.rb
lib/locomotive/bushido_spec.rb
lib/locomotive/render_spec.rb
lib/locomotive/httparty/patches_spec.rb
lib/locomotive/httparty/webservice_spec.rb
lib/locomotive/configuration_spec.rb
lib/locomotive/liquid/tags/consume_spec.rb
lib/locomotive/liquid/tags/with_scope_spec.rb
lib/locomotive/liquid/tags/nav_spec.rb
lib/locomotive/liquid/tags/editable/content_spec.rb
lib/locomotive/liquid/tags/editable/short_text_spec.rb
lib/locomotive/liquid/tags/seo_spec.rb
lib/locomotive/liquid/tags/paginate_spec.rb
lib/locomotive/liquid/drops/content_spec.rb
lib/locomotive/liquid/drops/contents_spec.rb
lib/locomotive/liquid/drops/page_spec.rb
lib/locomotive/liquid/drops/site_spec.rb
lib/locomotive/liquid/filters/resize_spec.rb
lib/locomotive/liquid/filters/html_spec.rb
lib/locomotive/liquid/filters/date_spec.rb
lib/locomotive/liquid/filters/text_spec.rb
lib/locomotive/liquid/filters/misc_spec.rb
lib/locomotive/heroku_spec.rb
lib/locomotive/import_spec.rb
lib/locomotive/export_spec.rb
models/content_instance_spec.rb
models/editable_element_spec.rb
models/account_spec.rb
models/content_type_spec.rb
models/snippet_spec.rb
models/ability_spec.rb
models/membership_spec.rb
models/page_spec.rb
models/asset_spec.rb
models/theme_asset_spec.rb
models/site_spec.rb
cells/admin/main_menu_cell_spec.rb
cells/admin/global_actions_spec.rb
cells/admin/settings_menu_cell_spec.rb
requests/seo_trailing_slash_spec.rb
).collect { |f| File.join('spec', f) }.join(' ')

sh "bundle exec rspec #{files}"
end
1 change: 1 addition & 0 deletions app/cells/admin/menu_cell.rb
Expand Up @@ -45,6 +45,7 @@ def self.update_for(name, &block)
block.call(MenuProxy.new(self))
end

# Note: this might cause "stack level too deep" if called twice for the same name
alias_method_chain :build_list, name.to_sym
end

Expand Down
28 changes: 8 additions & 20 deletions spec/cells/admin/global_actions_spec.rb
@@ -1,21 +1,5 @@
require 'spec_helper'

module Resetter

@@original_global_actions_cell_klass = Admin::GlobalActionsCell

def self.original_global_actions_cell_klass
@@original_global_actions_cell_klass
end

def self.reset_global_actions_cell_klass
::Admin.send(:remove_const, 'GlobalActionsCell')
::Admin.const_set('GlobalActionsCell', self.original_global_actions_cell_klass.clone)
::Admin::GlobalActionsCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
end

end

describe Admin::GlobalActionsCell do

render_views
Expand All @@ -25,7 +9,7 @@ def self.reset_global_actions_cell_klass
describe 'show menu' do

before(:each) do
Resetter.reset_global_actions_cell_klass
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
end

it 'has 3 links' do
Expand All @@ -49,7 +33,7 @@ def self.reset_global_actions_cell_klass
describe 'add a new menu item' do

before(:each) do
Resetter.reset_global_actions_cell_klass
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
end

Expand All @@ -66,7 +50,7 @@ def self.reset_global_actions_cell_klass
describe 'remove a new menu item' do

before(:each) do
Resetter.reset_global_actions_cell_klass
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
end

Expand All @@ -83,7 +67,7 @@ def self.reset_global_actions_cell_klass
describe 'modify an existing menu item' do

before(:each) do
Resetter.reset_global_actions_cell_klass
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
end

Expand All @@ -98,4 +82,8 @@ def self.reset_global_actions_cell_klass

end

after(:all) do
CellsResetter.clean!
end

end
28 changes: 8 additions & 20 deletions spec/cells/admin/main_menu_cell_spec.rb
@@ -1,21 +1,5 @@
require 'spec_helper'

module Resetter

@@original_main_menu_cell_klass = Admin::MainMenuCell

def self.original_main_menu_cell_klass
@@original_main_menu_cell_klass
end

def self.reset_main_menu_cell_klass
::Admin.send(:remove_const, 'MainMenuCell')
::Admin.const_set('MainMenuCell', self.original_main_menu_cell_klass.clone)
::Admin::MainMenuCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
end

end

describe Admin::MainMenuCell do

render_views
Expand All @@ -25,7 +9,7 @@ def self.reset_main_menu_cell_klass
describe 'show menu' do

before(:each) do
Resetter.reset_main_menu_cell_klass
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
end

it 'has 2 items' do
Expand All @@ -45,7 +29,7 @@ def self.reset_main_menu_cell_klass
describe 'add a new menu item' do

before(:each) do
Resetter.reset_main_menu_cell_klass
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'Shop', :url => 'http://www.locomotivecms.com') }
end

Expand All @@ -62,7 +46,7 @@ def self.reset_main_menu_cell_klass
describe 'remove a new menu item' do

before(:each) do
Resetter.reset_main_menu_cell_klass
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
end

Expand All @@ -79,7 +63,7 @@ def self.reset_main_menu_cell_klass
describe 'modify an existing menu item' do

before(:each) do
Resetter.reset_main_menu_cell_klass
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
end

Expand All @@ -94,4 +78,8 @@ def self.reset_main_menu_cell_klass

end

after(:all) do
CellsResetter.clean!
end

end
28 changes: 8 additions & 20 deletions spec/cells/admin/settings_menu_cell_spec.rb
@@ -1,21 +1,5 @@
require 'spec_helper'

module Resetter

@@original_settings_menu_cell_klass = Admin::SettingsMenuCell

def self.original_settings_menu_cell_klass
@@original_settings_menu_cell_klass
end

def self.reset_settings_menu_cell_klass
::Admin.send(:remove_const, 'SettingsMenuCell')
::Admin.const_set('SettingsMenuCell', self.original_settings_menu_cell_klass.clone)
::Admin::SettingsMenuCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
end

end

describe Admin::SettingsMenuCell do

render_views
Expand All @@ -25,7 +9,7 @@ def self.reset_settings_menu_cell_klass
describe 'show menu' do

before(:each) do
Resetter.reset_settings_menu_cell_klass
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
end

it 'has 3 items' do
Expand All @@ -49,7 +33,7 @@ def self.reset_settings_menu_cell_klass
describe 'add a new menu item' do

before(:each) do
Resetter.reset_settings_menu_cell_klass
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::SettingsMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
end

Expand All @@ -66,7 +50,7 @@ def self.reset_settings_menu_cell_klass
describe 'remove a new menu item' do

before(:each) do
Resetter.reset_settings_menu_cell_klass
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
end

Expand All @@ -83,7 +67,7 @@ def self.reset_settings_menu_cell_klass
describe 'modify an existing menu item' do

before(:each) do
Resetter.reset_settings_menu_cell_klass
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::SettingsMenuCell.update_for(:testing_update) { |m| m.modify(:theme_assets, { :label => 'Modified !' }) }
end

Expand All @@ -98,4 +82,8 @@ def self.reset_settings_menu_cell_klass

end

after(:all) do
CellsResetter.clean!
end

end
8 changes: 6 additions & 2 deletions spec/factories.rb
Expand Up @@ -23,13 +23,17 @@
s.subdomain "models"
s.after_build do |site_with_models|
site_with_models.content_types.build(
:slug => 'projects',
:name => 'Existing name',
:slug => 'projects',
:name => 'Existing name',
:description => 'Existing description',
:order_by => 'created_at')
end
end

Factory.define "valid site", :parent => "site" do |s|
# s.after_build { |valid_site| valid_site.stubs(:valid?).returns(true) }
end


# Accounts ##
Factory.define :account do |a|
Expand Down
3 changes: 1 addition & 2 deletions spec/lib/locomotive/bushido_spec.rb
Expand Up @@ -83,7 +83,7 @@

before(:each) do
configure_locomotive_with_bushido
(@site = Factory.build(:site)).stubs(:valid?).returns(true)
@site = Factory.build('valid site')
end

it 'calls add_bushido_domains after saving a site' do
Expand Down Expand Up @@ -183,7 +183,6 @@ def configure_locomotive_with_bushido(&block)
end

after(:all) do
ENV['APP_TLD'] = nil
Locomotive.configure_for_test(true)
end

Expand Down
9 changes: 3 additions & 6 deletions spec/lib/locomotive/heroku_spec.rb
Expand Up @@ -2,10 +2,6 @@

describe 'Heroku support' do

before(:all) do
Site.destroy_all
end

before(:each) do
::Heroku::Client.any_instance.stubs(:post).returns(true)
::Heroku::Client.any_instance.stubs(:delete).returns(true)
Expand Down Expand Up @@ -99,7 +95,9 @@

before(:each) do
configure_locomotive_with_heroku
(@site = Factory.build(:site)).stubs(:valid?).returns(true)
# (@site = Factory.stub(:site)).stubs(:valid?).returns(true)
@site = Factory.build('valid site')
# (@site = Site.new(:name => 'foobar', :subdomain => 'acme')).stubs(:valid?).returns(true)
end

it 'calls add_heroku_domains after saving a site' do
Expand Down Expand Up @@ -178,7 +176,6 @@ def configure_locomotive_with_heroku(options = {}, domains = nil)
end

after(:all) do
ENV['HEROKU_SLUG'] = ENV['APP_NAME'] = ENV['HEROKU_LOGIN'] = ENV['HEROKU_PASSWORD'] = nil
Locomotive.configure_for_test(true)
end

Expand Down

0 comments on commit b23f269

Please sign in to comment.