ruby-bbcode 0.0.3 → 1.0.0

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.
@@ -1,3 +1,6 @@
1
- module RubyBbcode
2
- VERSION = "0.0.3"
1
+ module RubyBBCode
2
+ # Version of RubyBBCode
3
+ #
4
+ # Follows semantic versioning: http://semver.org/
5
+ VERSION = "1.0.0"
3
6
  end
data/lib/tags/tags.rb CHANGED
@@ -1,6 +1,9 @@
1
- module BBCode
1
+ module RubyBBCode
2
+ # Provides the official/default BBCode tags as stated by http://www.bbcode.org/reference.php
2
3
  module Tags
3
4
  # tagname => tag, HTML open tag, HTML close tag, description, example
5
+ # All of these entrys are represented as @dictionary in the classes (or as the variable tags)
6
+ # A single item from this file (eg the :b entry) is refered to as a @definition
4
7
  @@tags = {
5
8
  :b => {
6
9
  :html_open => '<strong>', :html_close => '</strong>',
@@ -26,17 +29,32 @@ module BBCode
26
29
  :html_open => '<ul>', :html_close => '</ul>',
27
30
  :description => 'Unordered list',
28
31
  :example => '[ul][li]List item[/li][li]Another list item[/li][/ul].',
29
- :only_allow => [ :li ]},
32
+ :only_allow => [ :li, "*".to_sym ]},
33
+ :code => {
34
+ :html_open => '<pre>', :html_close => '</pre>',
35
+ :description => 'Code block with mono-spaced text',
36
+ :example => 'This is [code]mono-spaced code[/code].'},
30
37
  :ol => {
31
38
  :html_open => '<ol>', :html_close => '</ol>',
32
39
  :description => 'Ordered list',
33
40
  :example => '[ol][li]List item[/li][li]Another list item[/li][/ol].',
34
- :only_allow => [ :li ]},
41
+ :only_allow => [ :li, "*".to_sym ]},
35
42
  :li => {
36
43
  :html_open => '<li>', :html_close => '</li>',
37
44
  :description => 'List item',
38
45
  :example => '[ul][li]List item[/li][li]Another list item[/li][/ul].',
39
46
  :only_in => [ :ul, :ol ]},
47
+ :list => {
48
+ :html_open => '<ul>', :html_close => '</ul>',
49
+ :description => 'Unordered list',
50
+ :example => '[list][*]List item[*]Another list item[/list].',
51
+ :only_allow => [ "*".to_sym ]},
52
+ "*".to_sym => {
53
+ :html_open => '<li>', :html_close => '</li>',
54
+ :description => 'List item',
55
+ :example => '[list][*]List item[*]Another list item[/list].',
56
+ :self_closable => true,
57
+ :only_in => [ :list, :ul, :ol ]},
40
58
  :img => {
41
59
  :html_open => '<img src="%between%" %width%%height%alt="" />', :html_close => '',
42
60
  :description => 'Image',
@@ -44,8 +62,8 @@ module BBCode
44
62
  :only_allow => [],
45
63
  :require_between => true,
46
64
  :allow_tag_param => true, :allow_tag_param_between => false,
47
- :tag_param => /^(\d*)x(\d*)$/,
48
- :tag_param_tokens => [{:token => :width, :prefix => 'width="', :postfix => '" ' },
65
+ :tag_param => /^(\d*)x(\d*)$/,
66
+ :tag_param_tokens => [{:token => :width, :prefix => 'width="', :postfix => '" ' },
49
67
  { :token => :height, :prefix => 'height="', :postfix => '" ' } ],
50
68
  :tag_param_description => 'The image parameters \'%param%\' are incorrect, <width>x<height> excepted'},
51
69
  :url => {
@@ -62,34 +80,49 @@ module BBCode
62
80
  :description => 'Quote another person',
63
81
  :example => '[quote]BBCode is great[/quote]',
64
82
  :allow_tag_param => true, :allow_tag_param_between => false,
65
- :tag_param => /(.*)/,
83
+ :tag_param => /(.*)/,
66
84
  :tag_param_tokens => [{:token => :author, :prefix => '<strong>', :postfix => ' wrote:</strong>'}]},
67
85
  :size => {
68
86
  :html_open => '<span style="font-size: %size%px;">', :html_close => '</span>',
69
87
  :description => 'Change the size of the text',
70
88
  :example => '[size=32]This is 32px[/size]',
71
89
  :allow_tag_param => true, :allow_tag_param_between => false,
72
- :tag_param => /(\d*)/,
90
+ :tag_param => /(\d*)/,
73
91
  :tag_param_tokens => [{:token => :size}]},
74
92
  :color => {
75
93
  :html_open => '<span style="color: %color%;">', :html_close => '</span>',
76
94
  :description => 'Change the color of the text',
77
95
  :example => '[color=red]This is red[/color]',
78
96
  :allow_tag_param => true, :allow_tag_param_between => false,
79
- :tag_param => /(([a-z]+)|(#[0-9a-f]{6}))/i,
97
+ :tag_param => /(([a-z]+)|(#[0-9a-f]{6}))/i,
80
98
  :tag_param_tokens => [{:token => :color}]},
81
99
  :youtube => {
82
100
  :html_open => '<object width="400" height="325"><param name="movie" value="http://www.youtube.com/v/%between%"></param><embed src="http://www.youtube.com/v/%between%" type="application/x-shockwave-flash" width="400" height="325"></embed></object>', :html_close => '',
83
101
  :description => 'Youtube video',
84
102
  :example => '[youtube]E4Fbk52Mk1w[/youtube]',
85
103
  :only_allow => [],
104
+ :url_varients => ["youtube.com", "youtu.be", "y2u.be"], # NOT USED
105
+ :url_matches => [/youtube\.com.*[v]=([^&]*)/, /youtu\.be\/([^&]*)/, /y2u\.be\/([^&]*)/],
86
106
  :require_between => true},
87
- :gvideo => {
88
- :html_open => '<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=%between%&hl=en" style="width:400px; height:325px;" type="application/x-shockwave-flash"></embed>', :html_close => '',
89
- :description => 'Google video',
90
- :example => '[gvideo]397259729324681206[/gvideo]',
107
+ :vimeo => {
108
+ :html_open => '<iframe src="http://player.vimeo.com/video/%between%?badge=0" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>',
109
+ :html_close => '',
110
+ :description => 'Vimeo video',
111
+ :example => '[vimeo]http://vimeo.com/46141955[/vimeo]',
91
112
  :only_allow => [],
113
+ :url_matches => [/vimeo\.com\/([^&]*)/],
92
114
  :require_between => true},
115
+ :media => {
116
+ :multi_tag => true,
117
+ :supported_tags => [
118
+ :youtube,
119
+ :vimeo
120
+ ]
121
+ }
93
122
  }
123
+
124
+ def self.tag_list
125
+ @@tags
126
+ end
94
127
  end
95
128
  end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+ require 'benchmark'
3
+
4
+
5
+
6
+ class RubyBbcodeTest < Test::Unit::TestCase
7
+
8
+ end
data/test/debugging.rb ADDED
@@ -0,0 +1,93 @@
1
+ module RubyBBCode
2
+ def self.log(string, clear_file = true)
3
+ clear_log_file_at_beginning_of_execution clear_file
4
+
5
+ File.open('/tmp/ruby-bbcode.log', 'a') do |f|
6
+ f.puts string
7
+ end
8
+ end
9
+
10
+ def self.clear_log_file_at_beginning_of_execution(clear_file)
11
+ return if !clear_file
12
+ if defined?(@@cleared_file).nil?
13
+ @@cleared_file = true
14
+ File.open('/tmp/ruby-bbcode.log', 'w+') do |f|
15
+ puts ''
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ # This module can be included in the BBTree and TagNode to give them debugging features
22
+ module DebugBBTree
23
+ # For Debugging/ visualization purposes.
24
+ # This can be used to render the #nodes array in a pretty manor, showing the hirarchy.
25
+ def to_v
26
+ tree = self
27
+ visual_string = ''
28
+
29
+ walk_tree(tree) do |node, depth|
30
+ indentation = ' ' * depth
31
+ case node[:is_tag]
32
+ when true
33
+ visual_string += "#{indentation}" + node[:tag].to_s + "\n"
34
+ when false
35
+ visual_string += "#{indentation}\"#{node[:text]}\"\n"
36
+ end
37
+ end
38
+
39
+ visual_string
40
+ end
41
+
42
+
43
+ # this blocky method counts how many children are
44
+ # in the TagNode.children, recursively walking the tree
45
+ def count_child_nodes(hash = self)
46
+ count = 0
47
+ walk_tree(hash) do
48
+ count += 1
49
+ end
50
+ count
51
+ end
52
+
53
+ # For BBTree, teh to_s method shows the count of the children plus a graphical
54
+ # depiction of the tree, and the relation of the nodes.
55
+ # For TagNodes, the root-most tag is displayed, and the children are counted.
56
+ def to_s
57
+ object_identifier = "#<#{self.class.to_s}:0x#{'%x' % (self.object_id << 1)}\n"
58
+ close_object = ">\n"
59
+
60
+ case self
61
+ when RubyBBCode::BBTree
62
+ object_identifier + "Children: #{count_child_nodes}\n" + self.to_v + close_object
63
+ when RubyBBCode::TagNode # when inspecting TagNodes, it's better not to show the tree display
64
+ if self[:is_tag]
65
+ object_identifier + "Tag: #{self[:tag].to_s}, Children: #{count_child_nodes}\n" + close_object
66
+ else
67
+ object_identifier + '"' + self[:text].to_s + "\"\n" + close_object
68
+ end
69
+ end
70
+ end
71
+
72
+ private
73
+
74
+ # This function is used by to_v and anything else that needs to iterate through the
75
+ # @bbtree
76
+ def walk_tree(tree, depth = -1, &blk)
77
+ return enum_for(:walk_tree) unless blk # ignore me for now, I'm a convention for being versatile
78
+
79
+ # Perform the block action specified at top level!!!
80
+ yield tree, depth unless depth == -1
81
+
82
+ # next if we're a text node
83
+ return if tree.type == :text
84
+
85
+ # Enter into recursion (including block action) for each child node in this node
86
+ tree.children.each do |node|
87
+ walk_tree(node, depth + 1, &blk)
88
+ end
89
+ end
90
+
91
+ end
92
+
93
+ end
@@ -6,31 +6,36 @@ class RubyBbcodeTest < Test::Unit::TestCase
6
6
  assert_equal "line1<br />\nline2", "line1\nline2".bbcode_to_html
7
7
  assert_equal "line1<br />\nline2", "line1\r\nline2".bbcode_to_html
8
8
  end
9
-
9
+
10
10
  def test_strong
11
11
  assert_equal '<strong>simple</strong>', '[b]simple[/b]'.bbcode_to_html
12
12
  assert_equal "<strong>line 1<br />\nline 2</strong>", "[b]line 1\nline 2[/b]".bbcode_to_html
13
13
  end
14
-
14
+
15
15
  def test_em
16
16
  assert_equal '<em>simple</em>', '[i]simple[/i]'.bbcode_to_html
17
17
  assert_equal "<em>line 1<br />\nline 2</em>", "[i]line 1\nline 2[/i]".bbcode_to_html
18
18
  end
19
-
19
+
20
20
  def test_u
21
21
  assert_equal '<u>simple</u>', '[u]simple[/u]'.bbcode_to_html
22
22
  assert_equal "<u>line 1<br />\nline 2</u>", "[u]line 1\nline 2[/u]".bbcode_to_html
23
23
  end
24
24
 
25
+ def test_code
26
+ assert_equal '<pre>simple</pre>', '[code]simple[/code]'.bbcode_to_html
27
+ assert_equal "<pre>line 1<br />\nline 2</pre>", "[code]line 1\nline 2[/code]".bbcode_to_html
28
+ end
29
+
25
30
  def test_strikethrough
26
31
  assert_equal '<span style="text-decoration:line-through;">simple</span>', '[s]simple[/s]'.bbcode_to_html
27
32
  assert_equal "<span style=\"text-decoration:line-through;\">line 1<br />\nline 2</span>", "[s]line 1\nline 2[/s]".bbcode_to_html
28
33
  end
29
-
34
+
30
35
  def test_size
31
36
  assert_equal '<span style="font-size: 32px;">32px Text</span>', '[size=32]32px Text[/size]'.bbcode_to_html
32
37
  end
33
-
38
+
34
39
  def test_color
35
40
  assert_equal '<span style="color: red;">Red Text</span>', '[color=red]Red Text[/color]'.bbcode_to_html
36
41
  assert_equal '<span style="color: #ff0023;">Hex Color Text</span>', '[color=#ff0023]Hex Color Text[/color]'.bbcode_to_html
@@ -39,7 +44,7 @@ class RubyBbcodeTest < Test::Unit::TestCase
39
44
  def test_center
40
45
  assert_equal '<div style="text-align:center;">centered</div>', '[center]centered[/center]'.bbcode_to_html
41
46
  end
42
-
47
+
43
48
  def test_ordered_list
44
49
  assert_equal '<ol><li>item 1</li><li>item 2</li></ol>', '[ol][li]item 1[/li][li]item 2[/li][/ol]'.bbcode_to_html
45
50
  end
@@ -47,16 +52,30 @@ class RubyBbcodeTest < Test::Unit::TestCase
47
52
  def test_unordered_list
48
53
  assert_equal '<ul><li>item 1</li><li>item 2</li></ul>', '[ul][li]item 1[/li][li]item 2[/li][/ul]'.bbcode_to_html
49
54
  end
50
-
55
+
56
+ def test_unordered_list_omit_closing
57
+ assert_raise RuntimeError do
58
+ assert_equal '<ul><li>item 1</li><li>item 2</li></ul>', '[ul][li]item 1[li]item 2[/ul]'.bbcode_to_html
59
+ end
60
+ end
61
+
62
+ def test_list_common_syntax
63
+ assert_equal '<ul><li>item 1</li><li>item 2</li></ul>', '[list][*]item 1[*]item 2[/list]'.bbcode_to_html
64
+ end
65
+
66
+ def test_list_common_syntax_explicit_closing
67
+ assert_equal '<ul><li>item 1</li><li>item 2</li></ul>', '[list][*]item 1[/*][*]item 2[/*][/list]'.bbcode_to_html
68
+ end
69
+
51
70
  def test_two_lists
52
71
  assert_equal '<ul><li>item1</li><li>item2</li></ul><ul><li>item1</li><li>item2</li></ul>',
53
72
  '[ul][li]item1[/li][li]item2[/li][/ul][ul][li]item1[/li][li]item2[/li][/ul]'.bbcode_to_html
54
73
  end
55
74
 
56
75
  def test_whitespace_in_only_allowed_tags
57
- assert_equal "<ol><br />\n<li>item 1</li><br />\n<li>item 2</li><br />\n</ol>",
76
+ assert_equal "<ol><br />\n<li>item 1</li><br />\n<li>item 2</li><br />\n</ol>",
58
77
  "[ol]\n[li]item 1[/li]\n[li]item 2[/li]\n[/ol]".bbcode_to_html
59
- assert_equal "<ol> <li>item 1</li> <li>item 2</li> </ol>",
78
+ assert_equal "<ol> <li>item 1</li> <li>item 2</li> </ol>",
60
79
  "[ol] [li]item 1[/li] [li]item 2[/li] [/ol]".bbcode_to_html
61
80
 
62
81
  end
@@ -66,41 +85,41 @@ class RubyBbcodeTest < Test::Unit::TestCase
66
85
  '[li]Illegal item[/li]'.bbcode_to_html
67
86
  end
68
87
  assert_equal ['[li] can only be used in [ul] and [ol]'],
69
- '[li]Illegal item[/li]'.is_valid_bbcode?
88
+ '[li]Illegal item[/li]'.bbcode_check_validity
70
89
  assert_raise RuntimeError do
71
90
  '[b][li]Illegal item[/li][/b]'.bbcode_to_html
72
91
  end
73
-
92
+
74
93
  assert_equal ['[li] can only be used in [ul] and [ol], so using it in a [b] tag is not allowed'],
75
- '[b][li]Illegal item[/li][/b]'.is_valid_bbcode?
94
+ '[b][li]Illegal item[/li][/b]'.bbcode_check_validity
76
95
  end
77
96
 
78
97
  def test_illegal_list_contents
79
98
  assert_raise RuntimeError do
80
99
  '[ul]Illegal list[/ul]'.bbcode_to_html
81
100
  end
82
- assert_equal ['[ul] can only contain [li] tags, so "Illegal list" is not allowed'],
83
- '[ul]Illegal list[/ul]'.is_valid_bbcode?
101
+ assert_equal ['[ul] can only contain [li] and [*] tags, so "Illegal list" is not allowed'],
102
+ '[ul]Illegal list[/ul]'.bbcode_check_validity
84
103
  assert_raise RuntimeError do
85
104
  '[ul][b]Illegal list[/b][/ul]'.bbcode_to_html
86
105
  end
87
- assert_equal ['[ul] can only contain [li] tags, so [b] is not allowed'],
88
- '[ul][b]Illegal list[/b][/ul][/b]'.is_valid_bbcode?
106
+ assert_equal ['[ul] can only contain [li] and [*] tags, so [b] is not allowed'],
107
+ '[ul][b]Illegal list[/b][/ul][/b]'.bbcode_check_validity
89
108
  end
90
109
 
91
110
  def test_illegal_list_contents_text_between_list_items
92
111
  assert_raise RuntimeError do
93
112
  '[ul][li]item[/li]Illegal list[/ul]'.bbcode_to_html
94
113
  end
95
- assert_equal ['[ul] can only contain [li] tags, so "Illegal text" is not allowed'],
96
- '[ul][li]item[/li]Illegal text[/ul]'.is_valid_bbcode?
114
+ assert_equal ['[ul] can only contain [li] and [*] tags, so "Illegal text" is not allowed'],
115
+ '[ul][li]item[/li]Illegal text[/ul]'.bbcode_check_validity
97
116
  assert_raise RuntimeError do
98
117
  '[ul][li]item[/li]Illegal list[li]item[/li][/ul]'.bbcode_to_html
99
118
  end
100
- assert_equal ['[ul] can only contain [li] tags, so "Illegal text" is not allowed'],
101
- '[ul][li]item[/li]Illegal text[li]item[/li][/ul]'.is_valid_bbcode?
119
+ assert_equal ['[ul] can only contain [li] and [*] tags, so "Illegal text" is not allowed'],
120
+ '[ul][li]item[/li]Illegal text[li]item[/li][/ul]'.bbcode_check_validity
102
121
  end
103
-
122
+
104
123
  def test_quote
105
124
  assert_equal '<div class="quote">quoting</div>', '[quote]quoting[/quote]'.bbcode_to_html
106
125
  assert_equal '<div class="quote"><strong>someone wrote:</strong>quoting</div>', '[quote=someone]quoting[/quote]'.bbcode_to_html
@@ -123,25 +142,36 @@ class RubyBbcodeTest < Test::Unit::TestCase
123
142
  # Link within same domain must start with a / and a link to another domain with http://, https:// or ftp://
124
143
  '[url=www.google.com]Google[/url]'.bbcode_to_html
125
144
  end
145
+ assert_raise RuntimeError do
146
+ '[url]htfp://www.google.com[/url]'.bbcode_to_html
147
+ end
126
148
  end
127
-
149
+
128
150
  def test_image
129
151
  assert_equal '<img src="http://www.ruby-lang.org/images/logo.gif" alt="" />',
130
152
  '[img]http://www.ruby-lang.org/images/logo.gif[/img]'.bbcode_to_html
131
- assert_equal '<img src="http://www.ruby-lang.org/images/logo.gif" width="95" height="96" alt="" />',
153
+ assert_equal '<img src="http://www.ruby-lang.org/images/logo.gif" width="95" height="96" alt="" />',
132
154
  '[img=95x96]http://www.ruby-lang.org/images/logo.gif[/img]'.bbcode_to_html
133
155
  end
134
-
156
+
135
157
  def test_youtube
136
158
  assert_equal '<object width="400" height="325"><param name="movie" value="http://www.youtube.com/v/E4Fbk52Mk1w"></param><embed src="http://www.youtube.com/v/E4Fbk52Mk1w" type="application/x-shockwave-flash" width="400" height="325"></embed></object>' ,
137
159
  '[youtube]E4Fbk52Mk1w[/youtube]'.bbcode_to_html
138
160
  end
161
+
162
+ def test_youtube_with_full_url
163
+ full_url = "http://www.youtube.com/watch?feature=player_embedded&v=E4Fbk52Mk1w"
164
+ assert_equal '<object width="400" height="325"><param name="movie" value="http://www.youtube.com/v/E4Fbk52Mk1w"></param><embed src="http://www.youtube.com/v/E4Fbk52Mk1w" type="application/x-shockwave-flash" width="400" height="325"></embed></object>' ,
165
+ "[youtube]#{full_url}[/youtube]".bbcode_to_html
166
+ end
139
167
 
140
- def test_google_video
141
- assert_equal '<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=397259729324681206&hl=en" style="width:400px; height:325px;" type="application/x-shockwave-flash"></embed>',
142
- '[gvideo]397259729324681206[/gvideo]'.bbcode_to_html
168
+ def test_youtube_with_url_shortener
169
+ full_url = "http://www.youtu.be/cSohjlYQI2A"
170
+ assert_equal '<object width="400" height="325"><param name="movie" value="http://www.youtube.com/v/cSohjlYQI2A"></param><embed src="http://www.youtube.com/v/cSohjlYQI2A" type="application/x-shockwave-flash" width="400" height="325"></embed></object>' ,
171
+ "[youtube]#{full_url}[/youtube]".bbcode_to_html
143
172
  end
144
173
 
174
+
145
175
  def test_html_escaping
146
176
  assert_equal '<strong>&lt;i&gt;foobar&lt;/i&gt;</strong>', '[b]<i>foobar</i>[/b]'.bbcode_to_html
147
177
  assert_equal '<strong><i>foobar</i></strong>', '[b]<i>foobar</i>[/b]'.bbcode_to_html(false)
@@ -169,10 +199,11 @@ class RubyBbcodeTest < Test::Unit::TestCase
169
199
  assert_equal "<strong>foobar</strong>", foo
170
200
  end
171
201
 
172
- def test_self_tag_list
173
- assert_equal 15, RubyBBCode.tag_list.size
174
- end
175
-
202
+ # commented this out, it kinda just gets in the way of development atm
203
+ #def test_self_tag_list
204
+ # assert_equal 16, RubyBBCode::Tags.tag_list.size
205
+ #end
206
+
176
207
  def test_addition_of_tags
177
208
  mydef = {
178
209
  :test => {
@@ -191,7 +222,7 @@ class RubyBbcodeTest < Test::Unit::TestCase
191
222
 
192
223
  def test_no_ending_tag
193
224
  assert_raise RuntimeError do
194
- "this [b]should not be bold".bbcode_to_html
225
+ "this [b]should not be bold".bbcode_to_html
195
226
  end
196
227
  end
197
228
 
@@ -206,5 +237,49 @@ class RubyBbcodeTest < Test::Unit::TestCase
206
237
  "this [b]should not do formatting[/i]".bbcode_to_html
207
238
  end
208
239
  end
240
+
241
+ def test_no_xss_hax
242
+ expected = "<a href=\"http://www.google.com&quot; onclick=\&quot;javascript:alert\">google</a>"
243
+ assert_equal expected, '[url=http://www.google.com" onclick="javascript:alert]google[/url]'.bbcode_to_html
244
+ end
245
+
246
+ # TODO: This stack level problem should be validated during the validations
247
+ #def test_stack_level_too_deep
248
+ # num = 2300 # increase this number if the test starts failing. It's very near the tipping point
249
+ # openers = "[s]hi i'm" * num
250
+ # closers = "[/s]" * num
251
+ # assert_raise( SystemStackError ) do
252
+ # (openers+closers).bbcode_to_html
253
+ # end
254
+ #end
255
+
256
+ def test_mulit_tag
257
+ input1 = "[media]http://www.youtube.com/watch?v=cSohjlYQI2A[/media]"
258
+ input2 = "[media]http://vimeo.com/46141955[/media]"
259
+
260
+ output1 = "<object width=\"400\" height=\"325\"><param name=\"movie\" value=\"http://www.youtube.com/v/cSohjlYQI2A\"></param><embed src=\"http://www.youtube.com/v/cSohjlYQI2A\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"325\"></embed></object>"
261
+ output2 = '<iframe src="http://player.vimeo.com/video/46141955?badge=0" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
262
+
263
+
264
+ assert_equal output1, input1.bbcode_to_html
265
+ assert_equal output2, input2.bbcode_to_html
266
+ end
267
+
268
+ def test_vimeo_tag
269
+ input = "[vimeo]http://vimeo.com/46141955[/vimeo]"
270
+ input2 = "[vimeo]46141955[/vimeo]"
271
+ output = '<iframe src="http://player.vimeo.com/video/46141955?badge=0" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
272
+
273
+ assert_equal output, input.bbcode_to_html
274
+ assert_equal output, input2.bbcode_to_html
275
+ end
276
+
277
+ def test_failing_multi_tag
278
+ input1 = "[media]http://www.youtoob.com/watch?v=cSohjlYQI2A[/media]"
279
+
280
+ assert_equal input1, input1.bbcode_to_html
281
+ end
282
+
283
+
209
284
 
210
285
  end