wikitext 4.1.2 → 4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/wikitext/parser.c +12 -0
- data/lib/wikitext/version.rb +1 -1
- data/spec/pre_spec.rb +14 -0
- metadata +39 -38
- data/spec/rails_spec.rb +0 -239
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40a9dd24504ec4ae9b1584450ef0676eec9e185b
|
4
|
+
data.tar.gz: dc04f479a91ada21d9eac782e1c42ba9c66ada0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c670c7c9a76287bfea763268c6658b159384b5dfdd1568a8ecc91dac70449725df2fe9a2fe77a888b3f67c3c89b2376c985d2660ae08bb0ad8243a16a086a168
|
7
|
+
data.tar.gz: fc956347dc61cbf9c12420b8bd6e9dae4a48e874f5a51bc41f21c6cb51becfb8b9baee3676d4c021209b3327048c1bb9cb3499766375eefa35b1243478eae842
|
data/ext/wikitext/parser.c
CHANGED
@@ -61,6 +61,7 @@ typedef struct
|
|
61
61
|
bool pending_crlf;
|
62
62
|
bool autolink;
|
63
63
|
bool space_to_underscore;
|
64
|
+
bool pre_code;
|
64
65
|
} parser_t;
|
65
66
|
|
66
67
|
const char null_str[] = { 0 };
|
@@ -165,6 +166,7 @@ parser_t *parser_new(void)
|
|
165
166
|
parser->pending_crlf = false;
|
166
167
|
parser->autolink = true;
|
167
168
|
parser->space_to_underscore = true;
|
169
|
+
parser->pre_code = false;
|
168
170
|
return parser;
|
169
171
|
}
|
170
172
|
|
@@ -525,6 +527,8 @@ void wiki_append_pre_start(parser_t *parser, token_t *token)
|
|
525
527
|
}
|
526
528
|
else
|
527
529
|
str_append(parser->output, pre_start, sizeof(pre_start) - 1);
|
530
|
+
if (parser->pre_code)
|
531
|
+
str_append(parser->output, code_start, sizeof(code_start) - 1);
|
528
532
|
ary_push(parser->scope, PRE_START);
|
529
533
|
ary_push(parser->line, PRE_START);
|
530
534
|
}
|
@@ -565,6 +569,8 @@ void wiki_pop_from_stack(parser_t *parser, str_t *target)
|
|
565
569
|
{
|
566
570
|
case PRE:
|
567
571
|
case PRE_START:
|
572
|
+
if (parser->pre_code)
|
573
|
+
str_append(target, code_end, sizeof(code_end) - 1);
|
568
574
|
str_append(target, pre_end, sizeof(pre_end) - 1);
|
569
575
|
str_append_str(target, parser->line_ending);
|
570
576
|
wiki_dedent(parser, false);
|
@@ -1013,6 +1019,7 @@ VALUE Wikitext_parser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1013
1019
|
VALUE img_prefix = rb_str_new2("/images/");
|
1014
1020
|
VALUE output_style = ID2SYM(rb_intern("html"));
|
1015
1021
|
VALUE space_to_underscore = Qtrue;
|
1022
|
+
VALUE pre_code = Qfalse;
|
1016
1023
|
VALUE minimum_fulltext_token_length = INT2NUM(3);
|
1017
1024
|
VALUE base_heading_level = INT2NUM(0);
|
1018
1025
|
|
@@ -1031,6 +1038,7 @@ VALUE Wikitext_parser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1031
1038
|
img_prefix = OVERRIDE_IF_SET(img_prefix);
|
1032
1039
|
output_style = OVERRIDE_IF_SET(output_style);
|
1033
1040
|
space_to_underscore = OVERRIDE_IF_SET(space_to_underscore);
|
1041
|
+
pre_code = OVERRIDE_IF_SET(pre_code);
|
1034
1042
|
minimum_fulltext_token_length = OVERRIDE_IF_SET(minimum_fulltext_token_length);
|
1035
1043
|
base_heading_level = OVERRIDE_IF_SET(base_heading_level);
|
1036
1044
|
}
|
@@ -1046,6 +1054,7 @@ VALUE Wikitext_parser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1046
1054
|
rb_iv_set(self, "@img_prefix", img_prefix);
|
1047
1055
|
rb_iv_set(self, "@output_style", output_style);
|
1048
1056
|
rb_iv_set(self, "@space_to_underscore", space_to_underscore);
|
1057
|
+
rb_iv_set(self, "@pre_code", pre_code);
|
1049
1058
|
rb_iv_set(self, "@minimum_fulltext_token_length", minimum_fulltext_token_length);
|
1050
1059
|
rb_iv_set(self, "@base_heading_level", base_heading_level);
|
1051
1060
|
return self;
|
@@ -1150,6 +1159,7 @@ VALUE Wikitext_parser_parse(int argc, VALUE *argv, VALUE self)
|
|
1150
1159
|
parser->img_prefix = rb_iv_get(self, "@img_prefix");
|
1151
1160
|
parser->autolink = rb_iv_get(self, "@autolink") == Qtrue ? true : false;
|
1152
1161
|
parser->space_to_underscore = rb_iv_get(self, "@space_to_underscore") == Qtrue ? true : false;
|
1162
|
+
parser->pre_code = rb_iv_get(self, "@pre_code") == Qtrue ? true : false;
|
1153
1163
|
parser->line_ending = str_new_from_string(line_ending);
|
1154
1164
|
parser->base_indent = base_indent;
|
1155
1165
|
parser->base_heading_level = base_heading_level;
|
@@ -1248,6 +1258,8 @@ VALUE Wikitext_parser_parse(int argc, VALUE *argv, VALUE self)
|
|
1248
1258
|
wiki_pop_from_stack_up_to(parser, NULL, BLOCKQUOTE, false);
|
1249
1259
|
wiki_indent(parser);
|
1250
1260
|
str_append(parser->output, pre_start, sizeof(pre_start) - 1);
|
1261
|
+
if (parser->pre_code)
|
1262
|
+
str_append(parser->output, code_start, sizeof(code_start) - 1);
|
1251
1263
|
ary_push(parser->scope, PRE);
|
1252
1264
|
}
|
1253
1265
|
break;
|
data/lib/wikitext/version.rb
CHANGED
data/spec/pre_spec.rb
CHANGED
@@ -54,6 +54,13 @@ describe Wikitext::Parser, 'parsing PRE blocks' do
|
|
54
54
|
@parser.parse(' ').should == "<pre></pre>\n"
|
55
55
|
end
|
56
56
|
|
57
|
+
it 'assumes PRE blocks are code when :pre_code is set' do
|
58
|
+
Wikitext::Parser.
|
59
|
+
new(:pre_code => true).
|
60
|
+
parse(' foo').
|
61
|
+
should == "<pre><code>foo</code></pre>\n"
|
62
|
+
end
|
63
|
+
|
57
64
|
it 'should sanely handle a leading empty line' do
|
58
65
|
@parser.parse(" \n foo").should == "<pre>\nfoo</pre>\n"
|
59
66
|
end
|
@@ -148,6 +155,13 @@ describe Wikitext::Parser, 'parsing PRE_START/PRE_END blocks' do
|
|
148
155
|
@parser.parse('<pre>foo</pre>').should == "<pre>foo</pre>\n"
|
149
156
|
end
|
150
157
|
|
158
|
+
it 'assumes PRE_START/PRE_END blocks are code when :pre_code is set' do
|
159
|
+
Wikitext::Parser.
|
160
|
+
new(:pre_code => true).
|
161
|
+
parse('<pre>foo</pre>').
|
162
|
+
should == "<pre><code>foo</code></pre>\n"
|
163
|
+
end
|
164
|
+
|
151
165
|
it 'should pass through PRE unchanged in PRE_START/PRE_END blocks' do
|
152
166
|
input = dedent <<-END
|
153
167
|
<pre>line 1
|
metadata
CHANGED
@@ -1,100 +1,101 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikitext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: '4.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Hurrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '10.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.13'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.17.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.17.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.8.5.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.8.5.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: wopen3
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '0.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '0.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: ZenTest
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '4.9'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
97
|
-
description:
|
96
|
+
version: '4.9'
|
97
|
+
description: |2
|
98
|
+
Wikitext is a fast wikitext-to-HTML translator written in C.
|
98
99
|
email: greg@hurrell.net
|
99
100
|
executables:
|
100
101
|
- wikitext
|
@@ -103,21 +104,21 @@ extensions:
|
|
103
104
|
extra_rdoc_files: []
|
104
105
|
files:
|
105
106
|
- bin/wikitext
|
106
|
-
- ext/wikitext/ary.c
|
107
|
-
- ext/wikitext/ary.h
|
108
|
-
- ext/wikitext/depend
|
109
107
|
- ext/wikitext/extconf.rb
|
108
|
+
- ext/wikitext/ary.c
|
110
109
|
- ext/wikitext/parser.c
|
110
|
+
- ext/wikitext/str.c
|
111
|
+
- ext/wikitext/token.c
|
112
|
+
- ext/wikitext/wikitext.c
|
113
|
+
- ext/wikitext/wikitext_ragel.c
|
114
|
+
- ext/wikitext/ary.h
|
111
115
|
- ext/wikitext/parser.h
|
112
116
|
- ext/wikitext/ruby_compat.h
|
113
|
-
- ext/wikitext/str.c
|
114
117
|
- ext/wikitext/str.h
|
115
|
-
- ext/wikitext/token.c
|
116
118
|
- ext/wikitext/token.h
|
117
|
-
- ext/wikitext/wikitext.c
|
118
119
|
- ext/wikitext/wikitext.h
|
119
|
-
- ext/wikitext/wikitext_ragel.c
|
120
120
|
- ext/wikitext/wikitext_ragel.h
|
121
|
+
- ext/wikitext/depend
|
121
122
|
- lib/wikitext/haml_filter.rb
|
122
123
|
- lib/wikitext/nil_class.rb
|
123
124
|
- lib/wikitext/parser.rb
|
@@ -151,7 +152,6 @@ files:
|
|
151
152
|
- spec/p_spec.rb
|
152
153
|
- spec/parser_spec.rb
|
153
154
|
- spec/pre_spec.rb
|
154
|
-
- spec/rails_spec.rb
|
155
155
|
- spec/regressions_spec.rb
|
156
156
|
- spec/spec_helper.rb
|
157
157
|
- spec/string_spec.rb
|
@@ -174,18 +174,19 @@ require_paths:
|
|
174
174
|
- lib
|
175
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- -
|
177
|
+
- - '>='
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: 2.0.0
|
180
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
181
|
requirements:
|
182
|
-
- -
|
182
|
+
- - '>='
|
183
183
|
- !ruby/object:Gem::Version
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project: wikitext
|
187
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.0.14
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Wikitext-to-HTML translator
|
191
191
|
test_files: []
|
192
|
+
has_rdoc:
|
data/spec/rails_spec.rb
DELETED
@@ -1,239 +0,0 @@
|
|
1
|
-
# Copyright 2009-present Greg Hurrell. All rights reserved.
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or without
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
5
|
-
#
|
6
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
7
|
-
# this list of conditions and the following disclaimer.
|
8
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
9
|
-
# this list of conditions and the following disclaimer in the documentation
|
10
|
-
# and/or other materials provided with the distribution.
|
11
|
-
#
|
12
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
13
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
16
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
17
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
18
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
19
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
20
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
21
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
22
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
23
|
-
|
24
|
-
require 'spec_helper'
|
25
|
-
require 'wikitext/version'
|
26
|
-
require 'fileutils'
|
27
|
-
require 'pathname'
|
28
|
-
require 'wopen3'
|
29
|
-
|
30
|
-
module RailsSpecs
|
31
|
-
TRASH_PATH = Pathname.new(__FILE__).dirname + '.trash'
|
32
|
-
AREL_CLONE_PATH = TRASH_PATH + 'arel.git'
|
33
|
-
AREL_REPO = 'git://github.com/rails/arel.git'
|
34
|
-
RAILS_CLONE_PATH = TRASH_PATH + 'rails.git'
|
35
|
-
RAILS_REPO = 'git://github.com/rails/rails.git'
|
36
|
-
WIKITEXT_GEM_PATH = TRASH_PATH + '..' + '..'
|
37
|
-
SUCCESSFUL_TEST_RESULT = /1 tests, 3 assertions, 0 failures, 0 errors/
|
38
|
-
|
39
|
-
def run cmd, *args
|
40
|
-
result = Wopen3.system(*([cmd] + args))
|
41
|
-
if result.status != 0
|
42
|
-
command_string = ([cmd] + args).join(' ')
|
43
|
-
puts "\n*** COMMAND #{command_string} EXITED WITH NON-ZERO EXIT STATUS (#{result.status})"
|
44
|
-
puts "*** STDOUT FOR COMMAND #{command_string}:", result.stdout
|
45
|
-
puts "*** STDERR FOR COMMAND #{command_string}:", result.stderr
|
46
|
-
raise "non-zero exit status (#{result.status}) for '#{command_string}'"
|
47
|
-
end
|
48
|
-
result
|
49
|
-
end
|
50
|
-
|
51
|
-
def clone repo, path
|
52
|
-
if File.exist? path
|
53
|
-
FileUtils.cd path do
|
54
|
-
run 'git', 'fetch'
|
55
|
-
end
|
56
|
-
else
|
57
|
-
run 'git', 'clone', repo, path
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def app_path version
|
62
|
-
version = 'edge' if version.nil?
|
63
|
-
version = "v#{version}" if version =~ /\A\d\./
|
64
|
-
TRASH_PATH + "#{version}-app"
|
65
|
-
end
|
66
|
-
|
67
|
-
# if version is nil will create an "Edge" app
|
68
|
-
def create_rails3_app rails_version, arel_version = nil
|
69
|
-
app = app_path rails_version
|
70
|
-
clone AREL_REPO, AREL_CLONE_PATH
|
71
|
-
FileUtils.cd AREL_CLONE_PATH do
|
72
|
-
if arel_version
|
73
|
-
run 'git', 'reset', '--hard', "v#{arel_version}"
|
74
|
-
else # "Edge"
|
75
|
-
run 'git', 'reset', '--hard', 'origin/master'
|
76
|
-
end
|
77
|
-
run 'git', 'clean', '-f'
|
78
|
-
end
|
79
|
-
|
80
|
-
clone RAILS_REPO, RAILS_CLONE_PATH
|
81
|
-
FileUtils.cd RAILS_CLONE_PATH do
|
82
|
-
if rails_version
|
83
|
-
run 'git', 'reset', '--hard', "v#{rails_version}"
|
84
|
-
else # "Edge"
|
85
|
-
run 'git', 'reset', '--hard', 'origin/master'
|
86
|
-
end
|
87
|
-
run 'git', 'clean', '-f'
|
88
|
-
|
89
|
-
begin
|
90
|
-
clean_bundler_environment
|
91
|
-
run 'env', "AREL=#{AREL_CLONE_PATH}",
|
92
|
-
'bundle', 'install', '--path', '../bundle', '--without', 'db'
|
93
|
-
FileUtils.rm_r(app) if File.exist?(app)
|
94
|
-
run 'env', "AREL=#{AREL_CLONE_PATH}",
|
95
|
-
'bundle', 'exec', 'bin/rails', 'new', app, '--skip-activerecord', '--dev'
|
96
|
-
ensure
|
97
|
-
restore_bundler_environment
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
create_gemfile app
|
102
|
-
bundlerize app
|
103
|
-
end
|
104
|
-
|
105
|
-
def insert text, after, infile
|
106
|
-
output = []
|
107
|
-
found = false
|
108
|
-
File.read(infile).split("\n").each do |line|
|
109
|
-
output << line
|
110
|
-
if found == false && line =~ /#{Regexp.escape(after)}/
|
111
|
-
found = true
|
112
|
-
output << text
|
113
|
-
end
|
114
|
-
end
|
115
|
-
File.open(infile, 'wb') { |f| f.write(output.join("\n")) }
|
116
|
-
raise "text '#{after}' not found" unless found
|
117
|
-
end
|
118
|
-
|
119
|
-
def add_text_to_routes text, infile
|
120
|
-
insert text, 'Application.routes.draw', infile
|
121
|
-
end
|
122
|
-
|
123
|
-
def create_gemfile app
|
124
|
-
File.open(app + 'Gemfile', 'w') do |f|
|
125
|
-
f.write <<-GEMFILE
|
126
|
-
source :rubygems
|
127
|
-
gem 'arel', :path => "#{AREL_CLONE_PATH.realpath}"
|
128
|
-
gem 'rake'
|
129
|
-
gem 'rails', :path => "#{RAILS_CLONE_PATH.realpath}"
|
130
|
-
gem 'sqlite3'
|
131
|
-
gem 'wikitext', :path => "#{WIKITEXT_GEM_PATH.realpath}"
|
132
|
-
GEMFILE
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def bundlerize app
|
137
|
-
clean_bundler_environment
|
138
|
-
Dir.chdir app do
|
139
|
-
run 'bundle', 'install', '--path', '../bundle', '--binstubs'
|
140
|
-
end
|
141
|
-
ensure
|
142
|
-
restore_bundler_environment
|
143
|
-
end
|
144
|
-
|
145
|
-
def create_controller app
|
146
|
-
File.open(app + 'app' + 'controllers' + 'wiki_controller.rb', 'w') do |f|
|
147
|
-
f.write 'class WikiController < ApplicationController; end'
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def create_template app
|
152
|
-
template_dir = app + 'app' + 'views' + 'wiki'
|
153
|
-
FileUtils.mkdir template_dir
|
154
|
-
File.open(template_dir + 'index.html.wikitext', 'w') do |f|
|
155
|
-
f.write '* hello, world!'
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def create_test app
|
160
|
-
# integration tests won't run without a schema.rb
|
161
|
-
FileUtils.touch app + 'db' + 'schema.rb'
|
162
|
-
|
163
|
-
File.open(app + 'test' + 'integration' + 'wiki_test.rb', 'w') do |f|
|
164
|
-
f.write <<'TEST'
|
165
|
-
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
166
|
-
|
167
|
-
class WikiTest < ActionController::IntegrationTest
|
168
|
-
def test_wiki_index
|
169
|
-
get "/wiki"
|
170
|
-
assert_response :success
|
171
|
-
assert_template "wiki/index"
|
172
|
-
assert_select 'ul>li', 'hello, world!'
|
173
|
-
end
|
174
|
-
end
|
175
|
-
TEST
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
def update_routes app
|
180
|
-
routes = app + 'config' + 'routes.rb'
|
181
|
-
add_text_to_routes 'match "/wiki" => "wiki#index"', routes
|
182
|
-
end
|
183
|
-
|
184
|
-
def setup_rails_app rails_version = nil, arel_version = nil
|
185
|
-
create_rails3_app rails_version, arel_version
|
186
|
-
path = app_path rails_version
|
187
|
-
update_routes path
|
188
|
-
create_controller path
|
189
|
-
create_template path
|
190
|
-
create_test path
|
191
|
-
end
|
192
|
-
|
193
|
-
def clean_bundler_environment
|
194
|
-
@bundler_env = ENV.select { |key, value| key =~ /\A(BUNDLE|GEM)_/ }
|
195
|
-
@bundler_env.each { |pair| ENV.delete(pair.first) }
|
196
|
-
end
|
197
|
-
|
198
|
-
def restore_bundler_environment
|
199
|
-
@bundler_env.each { |pair| ENV[pair[0]] = pair[1] }
|
200
|
-
end
|
201
|
-
|
202
|
-
def run_integration_test app
|
203
|
-
clean_bundler_environment
|
204
|
-
FileUtils.cd app do
|
205
|
-
return run('bin/rake', 'test:integration').stdout
|
206
|
-
end
|
207
|
-
ensure
|
208
|
-
restore_bundler_environment
|
209
|
-
end
|
210
|
-
end # module RailsSpecs
|
211
|
-
|
212
|
-
# different versions of Rails require different versions of Arel
|
213
|
-
{ '3.1.0' => '2.1.1' }.each do |rails_version, arel_version|
|
214
|
-
describe "Template handler in Rails #{rails_version}" do
|
215
|
-
include RailsSpecs
|
216
|
-
|
217
|
-
before :all do
|
218
|
-
setup_rails_app rails_version, arel_version
|
219
|
-
@path = app_path rails_version
|
220
|
-
end
|
221
|
-
|
222
|
-
it 'should process the template using the wikitext module' do
|
223
|
-
run_integration_test(@path).should =~ RailsSpecs::SUCCESSFUL_TEST_RESULT
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
describe 'Template handler in Edge Rails' do
|
229
|
-
include RailsSpecs
|
230
|
-
|
231
|
-
before :all do
|
232
|
-
setup_rails_app
|
233
|
-
@path = app_path nil
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'should process the template using the wikitext module' do
|
237
|
-
run_integration_test(@path).should =~ RailsSpecs::SUCCESSFUL_TEST_RESULT
|
238
|
-
end
|
239
|
-
end
|