Skip to content

Commit

Permalink
test: silence some of the remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieran Pilkington committed Jan 10, 2010
1 parent 386fb24 commit ca3766d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 12 additions & 0 deletions test/test_helper.rb
Expand Up @@ -17,3 +17,15 @@ def show_page
class TestController
def self.helper(s) s; end
end

def set_constant(constant, value)
if respond_to?(:silence_warnings)
silence_warnings do
Object.send(:remove_const, constant) if Object.const_defined?(constant)
Object.const_set(constant, value)
end
else
Object.send(:remove_const, constant) if Object.const_defined?(constant)
Object.const_set(constant, value)
end
end
10 changes: 5 additions & 5 deletions test/unit/helpers/tiny_mce_helper_test.rb
@@ -1,5 +1,5 @@
require File.dirname(__FILE__) + '/../../test_helper'
require 'action_view/test_case'
require 'action_view/test_case'

module TinyMCE
class HelpersTest < ActionView::TestCase
Expand All @@ -19,13 +19,13 @@ class HelpersTest < ActionView::TestCase

test "correct tiny mce is loaded depending on environment" do
Rails.instance_variable_set('@_env', nil)
Object.const_set('RAILS_ENV', 'development')
set_constant('RAILS_ENV', 'development')
assert_match /\/javascripts\/tiny_mce\/tiny_mce_src\.js/, include_tiny_mce_js
Rails.instance_variable_set('@_env', nil)
Object.const_set('RAILS_ENV', 'production')
set_constant('RAILS_ENV', 'production')
assert_match /\/javascripts\/tiny_mce\/tiny_mce\.js/, include_tiny_mce_js
Rails.instance_variable_set('@_env', nil)
Object.const_set('RAILS_ENV', 'test') # set it back to test
set_constant('RAILS_ENV', 'test') # set it back to test
end

test "correct tiny mce is only loaded when using it" do
Expand Down Expand Up @@ -95,7 +95,7 @@ class HelpersTest < ActionView::TestCase
raw_tiny_mce_init({ 'invalid_option' => true })
end
end

test "exception when plugins option is not an array" do
assert_raise TinyMCEInvalidOptionType do
raw_tiny_mce_init({'plugins' => 'invalid as a string'})
Expand Down
1 change: 0 additions & 1 deletion test/unit/tiny_mce_test.rb
Expand Up @@ -10,7 +10,6 @@ class TinyMCETest < ActiveSupport::TestCase
end

test "tiny mce plugin is included into action controller base and uses_tiny_mce method available" do
assert ActionController::Base::TinyMCE::Base
assert ApplicationController.respond_to?(:uses_tiny_mce)
end

Expand Down

0 comments on commit ca3766d

Please sign in to comment.