pluginaweek-tiny_mce_helper 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +46 -0
- data/README.rdoc +185 -0
- data/Rakefile +96 -0
- data/init.rb +1 -0
- data/install.rb +7 -0
- data/lib/tiny_mce_helper.rb +262 -0
- data/tasks/tiny_mce_helper_tasks.rake +21 -0
- data/test/app_root/config/tiny_mce_options.yml +119 -0
- data/test/app_root/config_bak/tiny_mce_options.yml +119 -0
- data/test/files/sourceforge.html +2299 -0
- data/test/files/tinymce_3_2_2.zip +0 -0
- data/test/files/tinymce_3_2_2_3.zip +0 -0
- data/test/files/wiki.html +361 -0
- data/test/helpers/tiny_mce_helper_test.rb +187 -0
- data/test/test_helper.rb +31 -0
- data/test/unit/tiny_mce_helper_test.rb +168 -0
- data/uninstall.rb +2 -0
- metadata +76 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Setup default folders
|
2
|
+
require 'fileutils'
|
3
|
+
FileUtils.rm_rf('test/app_root/config')
|
4
|
+
FileUtils.cp_r('test/app_root/config_bak', 'test/app_root/config')
|
5
|
+
|
6
|
+
# Load the plugin testing framework
|
7
|
+
$:.unshift("#{File.dirname(__FILE__)}/../../plugin_test_helper/lib")
|
8
|
+
require 'rubygems'
|
9
|
+
require 'plugin_test_helper'
|
10
|
+
|
11
|
+
EXPANDED_RAILS_ROOT = File.expand_path(Rails.root)
|
12
|
+
|
13
|
+
ActiveSupport::TestCase.class_eval do
|
14
|
+
protected
|
15
|
+
def live?
|
16
|
+
ENV['LIVE']
|
17
|
+
end
|
18
|
+
|
19
|
+
def assert_html_equal(expected, actual)
|
20
|
+
assert_equal expected.strip.gsub(/\n\s*/, ''), actual.strip.gsub(/\n\s*/, '')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Allow skipping of tests that require mocha
|
25
|
+
def uses_mocha(description)
|
26
|
+
require 'rubygems'
|
27
|
+
require 'mocha'
|
28
|
+
yield
|
29
|
+
rescue LoadError
|
30
|
+
$stderr.puts "Skipping #{description} tests. `gem install mocha` and try again."
|
31
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
uses_mocha 'mocking install/update' do
|
4
|
+
class TinyMceInstallerTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
# Set up public path
|
7
|
+
FileUtils.mkdir_p("#{Rails.root}/public/javascripts")
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_save_latest_version_to_default_target
|
11
|
+
TinyMCEHelper.expects(:open).with('http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430').returns(open('test/files/sourceforge.html')) unless live?
|
12
|
+
TinyMCEHelper.expects(:open).with('http://prdownloads.sourceforge.net/tinymce/tinymce_3_2_2_3.zip?download').yields(open("#{EXPANDED_RAILS_ROOT}/../files/tinymce_3_2_2_3.zip")) unless live?
|
13
|
+
TinyMCEHelper.install(:force => true)
|
14
|
+
|
15
|
+
assert File.exists?("#{Rails.root}/public/javascripts/tiny_mce")
|
16
|
+
|
17
|
+
source = File.read("#{Rails.root}/public/javascripts/tiny_mce/tiny_mce_src.js")
|
18
|
+
|
19
|
+
if live?
|
20
|
+
assert source.include?('tinymce')
|
21
|
+
else
|
22
|
+
assert source.include?("majorVersion : '3'");
|
23
|
+
assert source.include?("minorVersion : '2.2.3'");
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_should_allow_custom_version
|
28
|
+
TinyMCEHelper.expects(:open).with('http://prdownloads.sourceforge.net/tinymce/tinymce_3_2_2.zip?download').yields(open("#{EXPANDED_RAILS_ROOT}/../files/tinymce_3_2_2.zip")) unless live?
|
29
|
+
TinyMCEHelper.install(:version => '3.2.2', :force => true)
|
30
|
+
|
31
|
+
assert File.exists?("#{Rails.root}/public/javascripts/tiny_mce")
|
32
|
+
|
33
|
+
source = File.read("#{Rails.root}/public/javascripts/tiny_mce/tiny_mce_src.js")
|
34
|
+
assert source.include?("majorVersion : '3'");
|
35
|
+
assert source.include?("minorVersion : '2.2'");
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_allow_custom_target
|
39
|
+
TinyMCEHelper.expects(:open).with('http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430').returns(open('test/files/sourceforge.html')) unless live?
|
40
|
+
TinyMCEHelper.expects(:open).with('http://prdownloads.sourceforge.net/tinymce/tinymce_3_2_2_3.zip?download').yields(open("#{EXPANDED_RAILS_ROOT}/../files/tinymce_3_2_2_3.zip")) unless live?
|
41
|
+
TinyMCEHelper.install(:target => 'public/javascripts/tinymce', :force => true)
|
42
|
+
|
43
|
+
assert File.exists?("#{Rails.root}/public/javascripts/tinymce")
|
44
|
+
end
|
45
|
+
|
46
|
+
def teardown
|
47
|
+
FileUtils.rm_rf("#{Rails.root}/public")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class TinyMceInstallerExistingTest < ActiveSupport::TestCase
|
52
|
+
def setup
|
53
|
+
# Set up public path
|
54
|
+
FileUtils.mkdir_p("#{Rails.root}/public/javascripts/tiny_mce")
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_should_prompt_user
|
58
|
+
expects_file_requests
|
59
|
+
|
60
|
+
STDIN.expects(:gets).returns("y\n")
|
61
|
+
TinyMCEHelper.install
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_should_skip_if_user_skips
|
65
|
+
TinyMCEHelper.expects(:open).never
|
66
|
+
|
67
|
+
STDIN.expects(:gets).returns("n\n")
|
68
|
+
TinyMCEHelper.install
|
69
|
+
|
70
|
+
assert !File.exists?("#{Rails.root}/public/javascripts/tiny_mce/tiny_mce_src.js")
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_should_not_skip_if_user_does_not_skip
|
74
|
+
expects_file_requests
|
75
|
+
|
76
|
+
STDIN.expects(:gets).returns("y\n")
|
77
|
+
TinyMCEHelper.install
|
78
|
+
|
79
|
+
assert File.exists?("#{Rails.root}/public/javascripts/tiny_mce/tiny_mce_src.js")
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_should_continue_prompting_user_if_invalid_response_is_typed
|
83
|
+
expects_file_requests
|
84
|
+
|
85
|
+
STDIN.expects(:gets).times(2).returns("k\n", "y\n")
|
86
|
+
TinyMCEHelper.install
|
87
|
+
|
88
|
+
assert File.exists?("#{Rails.root}/public/javascripts/tiny_mce/tiny_mce_src.js")
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_should_overwrite_if_forced
|
92
|
+
expects_file_requests
|
93
|
+
|
94
|
+
STDIN.expects(:gets).never
|
95
|
+
TinyMCEHelper.install(:force => true)
|
96
|
+
|
97
|
+
assert File.exists?("#{Rails.root}/public/javascripts/tiny_mce/tiny_mce_src.js")
|
98
|
+
end
|
99
|
+
|
100
|
+
def teardown
|
101
|
+
FileUtils.rm_rf("#{Rails.root}/public")
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
def expects_file_requests
|
106
|
+
unless live?
|
107
|
+
TinyMCEHelper.expects(:open).with('http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430').returns(open('test/files/sourceforge.html'))
|
108
|
+
TinyMCEHelper.expects(:open).with('http://prdownloads.sourceforge.net/tinymce/tinymce_3_2_2_3.zip?download').yields(open("#{EXPANDED_RAILS_ROOT}/../files/tinymce_3_2_2_3.zip"))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class TinyMceUpdaterTest < ActiveSupport::TestCase
|
114
|
+
def setup
|
115
|
+
TinyMCEHelper.expects(:open).with('http://wiki.moxiecode.com/index.php/TinyMCE:Configuration').returns(open('test/files/sourceforge.html')) unless live?
|
116
|
+
|
117
|
+
# Track valid options
|
118
|
+
@original_valid_options = TinyMCEHelper.valid_options.dup
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_should_update_options_if_options_configuration_doesnt_exist
|
122
|
+
FileUtils.rm("#{Rails.root}/config/tiny_mce_options.yml")
|
123
|
+
TinyMCEHelper.update_options
|
124
|
+
|
125
|
+
assert File.exists?("#{Rails.root}/config/tiny_mce_options.yml")
|
126
|
+
options = YAML.load(File.read(TinyMCEHelper::OPTIONS_FILE_PATH))
|
127
|
+
assert_instance_of Array, options
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_should_update_options_if_options_configuration_exists
|
131
|
+
File.truncate("#{Rails.root}/config/tiny_mce_options.yml", 0)
|
132
|
+
TinyMCEHelper.update_options
|
133
|
+
|
134
|
+
assert File.exists?("#{Rails.root}/config/tiny_mce_options.yml")
|
135
|
+
options = YAML.load(File.open(TinyMCEHelper::OPTIONS_FILE_PATH))
|
136
|
+
assert_instance_of Array, options
|
137
|
+
end
|
138
|
+
|
139
|
+
def teardown
|
140
|
+
TinyMCEHelper.valid_options = @original_valid_options
|
141
|
+
FileUtils.cp("#{Rails.root}/config_bak/tiny_mce_options.yml", "#{Rails.root}/config")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class TinyMceUninstallerTest < ActiveSupport::TestCase
|
147
|
+
def setup
|
148
|
+
# Set up public path
|
149
|
+
FileUtils.mkdir_p("#{Rails.root}/public/javascripts")
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_uninstall_should_remove_options_configuration
|
153
|
+
TinyMCEHelper.uninstall
|
154
|
+
assert !File.exists?("#{Rails.root}/config/tiny_mce_options.yml")
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_uninstall_should_remove_tinymce_source
|
158
|
+
FileUtils.mkdir("#{Rails.root}/public/javascripts/tiny_mce")
|
159
|
+
TinyMCEHelper.uninstall
|
160
|
+
|
161
|
+
assert !File.exists?("#{Rails.root}/public/javascripts/tiny_mce")
|
162
|
+
end
|
163
|
+
|
164
|
+
def teardown
|
165
|
+
FileUtils.rm_rf("#{Rails.root}/public")
|
166
|
+
FileUtils.cp("#{Rails.root}/config_bak/tiny_mce_options.yml", "#{Rails.root}/config")
|
167
|
+
end
|
168
|
+
end
|
data/uninstall.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pluginaweek-tiny_mce_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Pfeifer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-08 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Adds helper methods for creating the TinyMCE initialization script in Rails
|
17
|
+
email: aaron@pluginaweek.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/tiny_mce_helper.rb
|
26
|
+
- tasks/tiny_mce_helper_tasks.rake
|
27
|
+
- test/files
|
28
|
+
- test/files/wiki.html
|
29
|
+
- test/files/tinymce_3_2_2_3.zip
|
30
|
+
- test/files/sourceforge.html
|
31
|
+
- test/files/tinymce_3_2_2.zip
|
32
|
+
- test/unit
|
33
|
+
- test/unit/tiny_mce_helper_test.rb
|
34
|
+
- test/helpers
|
35
|
+
- test/helpers/tiny_mce_helper_test.rb
|
36
|
+
- test/app_root
|
37
|
+
- test/app_root/config_bak
|
38
|
+
- test/app_root/config_bak/tiny_mce_options.yml
|
39
|
+
- test/app_root/config
|
40
|
+
- test/app_root/config/tiny_mce_options.yml
|
41
|
+
- test/test_helper.rb
|
42
|
+
- CHANGELOG.rdoc
|
43
|
+
- init.rb
|
44
|
+
- install.rb
|
45
|
+
- Rakefile
|
46
|
+
- README.rdoc
|
47
|
+
- uninstall.rb
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://www.pluginaweek.org
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project: pluginaweek
|
70
|
+
rubygems_version: 1.2.0
|
71
|
+
signing_key:
|
72
|
+
specification_version: 2
|
73
|
+
summary: Adds helper methods for creating the TinyMCE initialization script in Rails
|
74
|
+
test_files:
|
75
|
+
- test/unit/tiny_mce_helper_test.rb
|
76
|
+
- test/helpers/tiny_mce_helper_test.rb
|