diff --git a/CHANGES b/CHANGES index 40ec9ec..6350c5c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ += 0.3.2 + - Put init.rb where Rails 2.3.14 expects = 0.3 - Fixed Model.textiled = false bug - Refactored tests diff --git a/acts_as_textiled.gemspec b/acts_as_textiled.gemspec new file mode 100644 index 0000000..5f2b0d3 --- /dev/null +++ b/acts_as_textiled.gemspec @@ -0,0 +1,25 @@ +$LOAD_PATH.unshift 'lib' + +Gem::Specification.new do |s| + s.name = "acts_as_textiled" + s.version = "0.3.2" + s.date = Time.now.strftime('%Y-%m-%d') + s.summary = "Render Textile" + s.homepage = "http://github.com/analog-analytics/acts_as_textiled" + s.email = "engineering@analoganalytics.com" + s.authors = [ "Chris Wanstrath" ] + s.has_rdoc = false + + s.files = %w( README.rdoc Rakefile ) + s.files += Dir.glob("lib/**/*") + s.files += Dir.glob("bin/**/*") + s.files += Dir.glob("man/**/*") + s.files += Dir.glob("test/**/*") + + s.description = < :lite_mode def author @@ -83,5 +91,17 @@ def author end end +class StorySubclass < Story + acts_as_textiled :body, :description => :lite_mode + + def self.name + Story.name + end + + def author + @author ||= Author.find(author_id) + end +end + $author = YAML.load_file(File.dirname(__FILE__) + '/fixtures/authors.yml') $story = YAML.load_file(File.dirname(__FILE__) + '/fixtures/stories.yml') diff --git a/test/textiled_test.rb b/test/textiled_test.rb index a014056..e1dd775 100644 --- a/test/textiled_test.rb +++ b/test/textiled_test.rb @@ -102,9 +102,9 @@ specify "should enhance text attributes" do story = Story.find(3) - body_html = %[

Textile is useful because it makes text slightly easier to read.

\n\n\n\t

If only it were so easy to use in every programming language. In Rails,\nwith the help of acts_as_textiled,\nit’s way easy. Thanks in no small part to RedCloth, of course.

] + body_html = %[

Textile is useful because it makes text slightly easier to read.

\n

If only it were so easy to use in every programming language. In Rails,
\nwith the help of acts_as_textiled,
\nit’s way easy. Thanks in no small part to RedCloth, of course.

] body_textile = %[_Textile_ is useful because it makes text _slightly_ easier to *read*.\n\nIf only it were so *easy* to use in every programming language. In Rails,\nwith the help of "acts_as_textiled":http://google.com/search?q=acts_as_textiled,\nit's way easy. Thanks in no small part to %{color:red}RedCloth%, of course.\n] - body_plain = %[Textile is useful because it makes text slightly easier to read.\n\n\n\tIf only it were so easy to use in every programming language. In Rails,\nwith the help of acts_as_textiled,\nit's way easy. Thanks in no small part to RedCloth, of course.] + body_plain = %[Textile is useful because it makes text slightly easier to read.\nIf only it were so easy to use in every programming language. In Rails,\nwith the help of acts_as_textiled,\nit's way easy. Thanks in no small part to RedCloth, of course.] story.body.should.equal body_html story.body_source.should.equal body_textile @@ -114,8 +114,8 @@ specify "should handle character conversions" do story = Story.find(4) - body_html = "

Is Textile™ the wave of the future? What about acts_as_textiled©? It’s\ndoubtful. Why does Textile™ smell like Python? Can we do anything to\nfix that? No? Well, I guess there are worse smells – like Ruby. jk.

\n\n\n\t

But seriously, ice > water and water < rain. But…nevermind. 1×1? 1.

\n\n\n\t

“You’re a good kid,” he said. “Keep it up.”

" - body_plain = %[Is Textile(TM) the wave of the future? What about acts_as_textiled(C)? It's\ndoubtful. Why does Textile(TM) smell like Python? Can we do anything to\nfix that? No? Well, I guess there are worse smells-like Ruby. jk.\n\n\n\tBut seriously, ice > water and water < rain. But...nevermind. 1x1? 1.\n\n\n\t"You're a good kid," he said. "Keep it up."] + body_html = "

Is Textile™ the wave of the future? What about acts_as_textiled©? It’s
\ndoubtful. Why does Textile™ smell like Python? Can we do anything to
\nfix that? No? Well, I guess there are worse smells – like Ruby. jk.

\n

But seriously, ice > water and water < rain. But…nevermind. 1 × 1? 1.

\n

“You’re a good kid,” he said. “Keep it up.”

" + body_plain = "Is Textile(TM) the wave of the future? What about acts_as_textiled(C)? It's\ndoubtful. Why does Textile(TM) smell like Python? Can we do anything to\nfix that? No? Well, I guess there are worse smells-like Ruby. jk.\nBut seriously, ice > water and water < rain. But...nevermind. 1 x 1? 1.\n\"You're a good kid,\" he said. \"Keep it up.\"" story.body.should.equal body_html story.body_plain.should.equal body_plain @@ -142,4 +142,28 @@ story.textiled.size.should.equal 2 story.description.should.equal desc_html end + + specify "should define expected methods" do + story = Story.find(1) + + story.body_plain.should.not.be.nil + story.body_source.should.not.be.nil + story.body_without_textiled.should.match /^Holy cats/ + story.body_with_textiled.should.match /^

Holy cats/ + story.body.should.match /^

Holy cats/ + end + + specify "should allow chaining on attributes that are already defined" do + story = Story.find(1) + + story.body.should.match /^

Holy cats/ + story.body_was_called.should.equal true + end + + specify "allow subclassing and redeclaration of acts_as_textiled" do + story = StorySubclass.find(1) + + story.body.should.match /^

Holy cats/ + story.body_was_called.should.equal true + end end