tristandunn-acts_as_markup 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ActsAsRDocTest < ActsAsMarkupTestCase
4
+ context 'acts_as_rdoc' do
5
+ setup do
6
+ @rdoctext = "== RDoc Test Text"
7
+ class ::Post < ActiveRecord::Base
8
+ acts_as_rdoc :body
9
+ end
10
+ @post = Post.create!(:title => 'Blah', :body => @rdoctext)
11
+ end
12
+
13
+ should "have a RDocText object returned for the column value" do
14
+ assert_kind_of RDocText, @post.body
15
+ end
16
+
17
+ should "return original RDoc text for a `to_s` method call on the column value" do
18
+ assert_equal @rdoctext, @post.body.to_s
19
+ end
20
+
21
+ should 'return false for .blank?' do
22
+ assert !@post.body.blank?
23
+ end
24
+
25
+ should "return formated html for a `to_html` method call on the column value" do
26
+ assert_match(/<h2>\s*RDoc Test Text\s*<\/h2>/, @post.body.to_html)
27
+ end
28
+
29
+ context "changing value of RDoc field should return new RDoc object" do
30
+ setup do
31
+ @old_body = @post.body
32
+ @post.body = "http://www.example.com/"
33
+ end
34
+
35
+ should "still have an RDocText object but not the same object" do
36
+ assert_kind_of RDocText, @post.body
37
+ assert_not_same @post.body, @old_body
38
+ end
39
+
40
+ should "return correct text for `to_s`" do
41
+ assert_equal "http://www.example.com/", @post.body.to_s
42
+ end
43
+
44
+ should "return correct HTML for the `to_html` method" do
45
+ assert_match(/<a href="http:\/\/www.example.com">www.example.com<\/a>/, @post.body.to_html)
46
+ end
47
+
48
+ teardown do
49
+ @old_body = nil
50
+ end
51
+ end
52
+
53
+ teardown do
54
+ @rdoctext, @post = nil
55
+ Post.delete_all
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,77 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ActsAsTextileTest < ActsAsMarkupTestCase
4
+ context 'acts_as_textile' do
5
+ setup do
6
+ @textile_text = "h2. Textile Test Text"
7
+ class ::Post < ActiveRecord::Base
8
+ acts_as_textile :body
9
+ end
10
+ @post = Post.create!(:title => 'Blah', :body => @textile_text)
11
+ end
12
+
13
+ should "have a RedCloth object returned for the column value" do
14
+ assert_kind_of RedCloth::TextileDoc, @post.body
15
+ end
16
+
17
+ should "return original textile text for a `to_s` method call on the column value" do
18
+ assert_equal @textile_text, @post.body.to_s
19
+ end
20
+
21
+ should 'return false for .blank?' do
22
+ assert !@post.body.blank?
23
+ end
24
+
25
+ should "return formated html for a `to_html` method call on the column value" do
26
+ assert_match(/<h2>Textile Test Text<\/h2>/, @post.body.to_html)
27
+ end
28
+
29
+ should "not return escaped html" do
30
+ @post.body = "h2. Textile <i>Test</i> Text"
31
+ assert_match(/<i>Test<\/i>/, @post.body.to_html)
32
+ end
33
+
34
+ context "changing value of textile field should return new textile object" do
35
+ setup do
36
+ @old_body = @post.body
37
+ @post.body = "@@count = 20@"
38
+ end
39
+
40
+ should "still have an RedCloth object but not the same object" do
41
+ assert_kind_of RedCloth::TextileDoc, @post.body
42
+ assert_not_same @post.body, @old_body
43
+ end
44
+
45
+ should "return correct text for `to_s`" do
46
+ assert_equal "@@count = 20@", @post.body.to_s
47
+ end
48
+
49
+ should "return correct HTML for the `to_html` method" do
50
+ assert_match(/<code>\@count\s\=\s20<\/code>/, @post.body.to_html)
51
+ end
52
+
53
+ teardown do
54
+ @old_body = nil
55
+ end
56
+ end
57
+
58
+ teardown do
59
+ @textile_text, @post = nil
60
+ Post.delete_all
61
+ end
62
+ end
63
+
64
+ context 'acts_as_textile with options' do
65
+ setup do
66
+ class ::Post
67
+ acts_as_textile :body, :textile_options => [ [ :filter_html ] ]
68
+ end
69
+ @post = Post.new(:title => 'Blah')
70
+ end
71
+
72
+ should "return escaped html because of :filter_html" do
73
+ @post.body = "h2. Textile <i>Test</i> Text"
74
+ assert_match(/&lt;i&gt;Test&lt;\/i&gt;/, @post.body.to_html)
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,77 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ActsAsWikitextTest < ActsAsMarkupTestCase
4
+ context 'acts_as_wikitext' do
5
+ setup do
6
+ @wikitext = "== Wikitext Test Text =="
7
+ class ::Post < ActiveRecord::Base
8
+ acts_as_wikitext :body
9
+ end
10
+ @post = Post.create!(:title => 'Blah', :body => @wikitext)
11
+ end
12
+
13
+ should "have a WikitextString object returned for the column value" do
14
+ assert_kind_of WikitextString, @post.body
15
+ end
16
+
17
+ should "return original wikitext text for a `to_s` method call on the column value" do
18
+ assert_equal @wikitext, @post.body.to_s
19
+ end
20
+
21
+ should 'return false for .blank?' do
22
+ assert !@post.body.blank?
23
+ end
24
+
25
+ should "return formated html for a `to_html` method call on the column value" do
26
+ assert_match(/<h2>Wikitext Test Text<\/h2>/, @post.body.to_html)
27
+ end
28
+
29
+ should "underscore spaces in URLs" do
30
+ @post.body = "[[foo bar]]"
31
+ assert_match(/<a href="\/wiki\/foo_bar">foo bar<\/a>/, @post.body.to_html)
32
+ end
33
+
34
+ context "changing value of wikitext field should return new wikitext object" do
35
+ setup do
36
+ @old_body = @post.body
37
+ @post.body = "`@count = 20`"
38
+ end
39
+
40
+ should "still have an WikitextString object but not the same object" do
41
+ assert_kind_of WikitextString, @post.body
42
+ assert_not_same @post.body, @old_body
43
+ end
44
+
45
+ should "return correct text for `to_s`" do
46
+ assert_equal "`@count = 20`", @post.body.to_s
47
+ end
48
+
49
+ should "return correct HTML for the `to_html` method" do
50
+ assert_match(/<tt>\@count\s\=\s20<\/tt>/, @post.body.to_html)
51
+ end
52
+
53
+ teardown do
54
+ @old_body = nil
55
+ end
56
+ end
57
+
58
+ teardown do
59
+ @wikitext, @post = nil
60
+ Post.delete_all
61
+ end
62
+ end
63
+
64
+ context 'acts_as_wikitext with options' do
65
+ setup do
66
+ class ::Post
67
+ acts_as_wikitext :body, :wikitext_options => [ { :space_to_underscore => false } ]
68
+ end
69
+ @post = Post.new(:title => 'Blah')
70
+ end
71
+
72
+ should "not underscore spaces in URLs because of :space_to_underscore option" do
73
+ @post.body = "[[foo bar]]"
74
+ assert_match(/<a href="\/wiki\/foo%20bar">foo bar<\/a>/, @post.body.to_html)
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,69 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ gem 'sqlite3-ruby'
4
+ require 'shoulda'
5
+ require 'active_support'
6
+ require 'active_support/test_case'
7
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib acts_as_markup]) )
8
+ ActiveRecord::Schema.verbose = false
9
+
10
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
11
+
12
+ def setup_db
13
+ ActiveRecord::Schema.define(:version => 1) do
14
+ create_table :posts do |t|
15
+ t.column :title, :string
16
+ t.column :body, :text
17
+ t.timestamps
18
+ end
19
+
20
+ create_table :markdown_posts do |t|
21
+ t.column :title, :string
22
+ t.column :body, :text
23
+ t.timestamps
24
+ end
25
+
26
+ create_table :textile_posts do |t|
27
+ t.column :title, :string
28
+ t.column :body, :text
29
+ t.timestamps
30
+ end
31
+
32
+ create_table :variable_posts do |t|
33
+ t.column :title, :string
34
+ t.column :body, :text
35
+ t.column :markup_language, :string
36
+ t.timestamps
37
+ end
38
+
39
+ create_table :variable_language_posts do |t|
40
+ t.column :title, :string
41
+ t.column :body, :text
42
+ t.column :language_name, :string
43
+ t.timestamps
44
+ end
45
+ end
46
+ end
47
+
48
+ def teardown_db
49
+ ActiveRecord::Base.connection.tables.each do |table|
50
+ ActiveRecord::Base.connection.drop_table(table)
51
+ end
52
+ end
53
+
54
+ class ActsAsMarkupTestCase < ActiveSupport::TestCase
55
+ def setup
56
+ setup_db
57
+ end
58
+
59
+ def teardown
60
+ teardown_db
61
+ end
62
+
63
+ def self.should_act_like_a_string
64
+ should "act like a string" do
65
+ assert_equal @post.body.split(' '), ['##', 'Markdown', 'Test', 'Text']
66
+ assert @post.body.match(/Te[sx]t/)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,52 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{tristandunn-acts_as_markup}
5
+ s.version = "1.3.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Brian Landau"]
9
+ s.date = %q{2009-06-11}
10
+ s.description = %q{Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML.}
11
+ s.email = %q{brian.landau@viget.com}
12
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc"]
13
+ s.files = ["CHANGELOG", "LICENSE", "README.rdoc", "Rakefile", "acts_as_markup.gemspec", "lib/acts/as_markup.rb", "lib/acts_as_markup.rb", "lib/acts_as_markup/exts/maruku.rb", "lib/acts_as_markup/exts/object.rb", "lib/acts_as_markup/exts/peg_markdown.rb", "lib/acts_as_markup/exts/rdiscount.rb", "lib/acts_as_markup/exts/rdoc.rb", "lib/acts_as_markup/exts/wikitext.rb", "lib/acts_as_markup/stringlike.rb", "lib/acts_as_markup/exts/simple_format.rb", "tasks/bones.rake", "tasks/gem.rake", "tasks/git.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/test.rake", "test/acts_as_markdown_test.rb", "test/acts_as_markup_test.rb", "test/acts_as_rdoc_test.rb", "test/acts_as_textile_test.rb", "test/acts_as_wikitext_test.rb", "test/test_helper.rb"]
14
+ s.homepage = %q{http://viget.rubyforge.com/acts_as_markup}
15
+ s.rdoc_options = ["--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{viget}
18
+ s.rubygems_version = %q{1.3.4}
19
+ s.summary = %q{Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML}
20
+ s.test_files = ["test/acts_as_markdown_test.rb", "test/acts_as_markup_test.rb", "test/acts_as_rdoc_test.rb", "test/acts_as_textile_test.rb", "test/acts_as_wikitext_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<activesupport>, ["~> 2.3.2"])
28
+ s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.2"])
29
+ s.add_runtime_dependency(%q<rdiscount>, ["~> 1.3"])
30
+ s.add_runtime_dependency(%q<wikitext>, ["~> 1.5"])
31
+ s.add_runtime_dependency(%q<RedCloth>, ["~> 4.2"])
32
+ s.add_development_dependency(%q<thoughtbot-shoulda>, ["~> 2.0"])
33
+ s.add_development_dependency(%q<bones>, ["~> 2.5"])
34
+ else
35
+ s.add_dependency(%q<activesupport>, ["~> 2.3.2"])
36
+ s.add_dependency(%q<activerecord>, ["~> 2.3.2"])
37
+ s.add_dependency(%q<rdiscount>, ["~> 1.3"])
38
+ s.add_dependency(%q<wikitext>, ["~> 1.5"])
39
+ s.add_dependency(%q<RedCloth>, ["~> 4.2"])
40
+ s.add_dependency(%q<thoughtbot-shoulda>, ["~> 2.0"])
41
+ s.add_dependency(%q<bones>, ["~> 2.5"])
42
+ end
43
+ else
44
+ s.add_dependency(%q<activesupport>, ["~> 2.3.2"])
45
+ s.add_dependency(%q<activerecord>, ["~> 2.3.2"])
46
+ s.add_dependency(%q<rdiscount>, ["~> 1.3"])
47
+ s.add_dependency(%q<wikitext>, ["~> 1.5"])
48
+ s.add_dependency(%q<RedCloth>, ["~> 4.2"])
49
+ s.add_dependency(%q<thoughtbot-shoulda>, ["~> 2.0"])
50
+ s.add_dependency(%q<bones>, ["~> 2.5"])
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tristandunn-acts_as_markup
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.3
5
+ platform: ruby
6
+ authors:
7
+ - Brian Landau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-20 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.2
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rdiscount
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: "1.3"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: wikitext
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: "1.5"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: RedCloth
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: "4.2"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: thoughtbot-shoulda
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ version: "2.0"
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: bones
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: "2.5"
84
+ version:
85
+ description: Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML.
86
+ email: brian.landau@viget.com
87
+ executables: []
88
+
89
+ extensions: []
90
+
91
+ extra_rdoc_files:
92
+ - CHANGELOG
93
+ - LICENSE
94
+ - README.rdoc
95
+ - lib/acts/.as_markup.rb.swp
96
+ files:
97
+ - CHANGELOG
98
+ - LICENSE
99
+ - README.rdoc
100
+ - Rakefile
101
+ - lib/acts/.as_markup.rb.swp
102
+ - lib/acts/as_markup.rb
103
+ - lib/acts_as_markup.rb
104
+ - lib/acts_as_markup/exts/maruku.rb
105
+ - lib/acts_as_markup/exts/object.rb
106
+ - lib/acts_as_markup/exts/peg_markdown.rb
107
+ - lib/acts_as_markup/exts/rdiscount.rb
108
+ - lib/acts_as_markup/exts/rdoc.rb
109
+ - lib/acts_as_markup/exts/simple_format.rb
110
+ - lib/acts_as_markup/exts/wikitext.rb
111
+ - lib/acts_as_markup/stringlike.rb
112
+ - tasks/bones.rake
113
+ - tasks/gem.rake
114
+ - tasks/git.rake
115
+ - tasks/post_load.rake
116
+ - tasks/rdoc.rake
117
+ - tasks/rubyforge.rake
118
+ - tasks/setup.rb
119
+ - tasks/test.rake
120
+ - test/.acts_as_markup_test.rb.swp
121
+ - test/acts_as_markdown_test.rb
122
+ - test/acts_as_markup_test.rb
123
+ - test/acts_as_rdoc_test.rb
124
+ - test/acts_as_textile_test.rb
125
+ - test/acts_as_wikitext_test.rb
126
+ - test/test_helper.rb
127
+ - tristandunn-acts_as_markup.gemspec
128
+ has_rdoc: true
129
+ homepage: http://viget.rubyforge.com/acts_as_markup
130
+ licenses: []
131
+
132
+ post_install_message:
133
+ rdoc_options:
134
+ - --main
135
+ - README.rdoc
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: "0"
143
+ version:
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: "0"
149
+ version:
150
+ requirements: []
151
+
152
+ rubyforge_project: viget
153
+ rubygems_version: 1.3.5
154
+ signing_key:
155
+ specification_version: 3
156
+ summary: Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML
157
+ test_files:
158
+ - test/acts_as_markdown_test.rb
159
+ - test/acts_as_markup_test.rb
160
+ - test/acts_as_rdoc_test.rb
161
+ - test/acts_as_textile_test.rb
162
+ - test/acts_as_wikitext_test.rb