Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Administrative Changes

* Convert testing from test/spec -> shoulda
* Convert packaging from bones -> echoe
  • Loading branch information...
commit 61c7d14b57f72af1bb40d8ed39dfa5052eced87f 1 parent d226f07
@bruce authored
View
25 CHANGELOG
@@ -0,0 +1,25 @@
+v1.99.0 2008-04-20
+
+ Released RTeX v1.99.0 as a Rubygem, with a standalone executable for PDF generation
+ and support for plugin installation from the executable.
+
+ This release requires Rails >= 2.0.1
+
+ Thanks to:
+ * Jonas Bähr for a patch with additional LaTeX escaping
+ * Fouad Mardini for a TemplateHandler patch
+
+v1.0.0+
+
+ Added quite a few *long* overdue fixes & enhancements sent in by various people.
+
+ * Added latex escaping 'l' method (Thanks, Benjamin Quorning)
+ * Added support for @options_for_rtex hash for configuration:
+ * Added :tempdir option, and changed default temporary directory
+ (Thanks, Francesco Levorato)
+ * Added :preprocess option to support running through latex before pdflatex
+ (Thanks Charles Lesburg, Benjamin Quorning)
+ * Moved old @filename setting to :filename option in this hash
+
+ If you're using the same settings for @options_for_rtex often, you might want to
+ put your assignment in a before_filter (perhaps overriding :filename, etc in your actions).
View
29 HISTORY.rdoc
@@ -1,29 +0,0 @@
-2008-04-20
-
-Released RTeX v1.99.0 as a Rubygem, with a standalone executable for PDF generation
-and support for plugin installation from the executable.
-
-This release requires Rails >= 2.0.1
-
-Thanks to:
-* Jonas Bähr for a patch with additional LaTeX escaping
-* Fouad Mardini for a TemplateHandler patch
-
-2007
-
-No active development, maintenance primarily by Wiebe Cazemier
-
-2006-07-27
-
-Added quite a few *long* overdue fixes & enhancements sent in by various people.
-
-* Added latex escaping 'l' method (Thanks, Benjamin Quorning)
-* Added support for @options_for_rtex hash for configuration:
- * Added :tempdir option, and changed default temporary directory
- (Thanks, Francesco Levorato)
- * Added :preprocess option to support running through latex before pdflatex
- (Thanks Charles Lesburg, Benjamin Quorning)
- * Moved old @filename setting to :filename option in this hash
-
-If you're using the same settings for @options_for_rtex often, you might want to
-put your assignment in a before_filter (perhaps overriding :filename, etc in your actions).
View
18 Manifest.txt → Manifest
@@ -1,24 +1,18 @@
-HISTORY.rdoc
-Manifest.txt
-README.rdoc
-README_RAILS.rdoc
-Rakefile
bin/rtex
+CHANGELOG
init.rb
-lib/rtex.rb
lib/rtex/document.rb
lib/rtex/escaping.rb
lib/rtex/framework/merb.rb
lib/rtex/framework/rails.rb
lib/rtex/tempdir.rb
lib/rtex/version.rb
+lib/rtex.rb
+Manifest
rails/init.rb
-tasks/doc.rake
-tasks/gem.rake
-tasks/manifest.rake
-tasks/post_load.rake
-tasks/setup.rb
-tasks/test.rake
+Rakefile
+README.rdoc
+README_RAILS.rdoc
test/document_test.rb
test/filter_test.rb
test/fixtures/first.tex
View
38 Rakefile
@@ -1,23 +1,21 @@
-require File.dirname(__FILE__) << "/lib/rtex/version"
-
-load 'tasks/setup.rb'
-
-PROJ.name = 'rtex'
-PROJ.authors = ['Bruce Williams', 'Wiebe Cazemier']
-PROJ.email = ['bruce@codefluency.com']
-PROJ.url = 'http://rtex.rubyforge.org'
-PROJ.rubyforge_name = 'rtex'
+require 'rubygems'
+require 'echoe'
-PROJ.libs = %w[]
-PROJ.ruby_opts = []
-PROJ.test_opts = []
-
-PROJ.rdoc_main = 'README.rdoc'
-PROJ.rdoc_include.push 'README.rdoc', 'README_RAILS.rdoc'
-
-PROJ.description = "LaTeX preprocessor for PDF generation; Rails plugin"
-PROJ.summary = PROJ.description
+require File.dirname(__FILE__) << "/lib/rtex/version"
-PROJ.version = RTeX::Version::STRING
+Echoe.new 'rtex' do |p|
+ p.version = RTeX::Version::STRING
+ p.author = ['Bruce Williams', 'Wiebe Cazemier']
+ p.email = 'bruce@codefluency.com'
+ p.project = 'rtex'
+ p.summary = "LaTeX preprocessor for PDF generation; Rails plugin"
+ p.url = "http://rtex.rubyforge.org"
+ p.include_rakefile = true
+ p.development_dependencies = %w(Shoulda echoe)
+ p.rcov_options = '--exclude gems --exclude version.rb --sort coverage --text-summary --html -o coverage'
+ p.ignore_pattern = /^(pkg|doc|site)|\.svn|CVS|\.bzr|\.DS|\.git/
+end
-task 'gem:package' => 'manifest:assert'
+task :coverage do
+ system "open coverage/index.html" if PLATFORM['darwin']
+end
View
48 tasks/doc.rake
@@ -1,48 +0,0 @@
-# $Id$
-
-require 'rake/rdoctask'
-
-namespace :doc do
-
- desc 'Generate RDoc documentation'
- Rake::RDocTask.new do |rd|
- rd.main = PROJ.rdoc_main
- rd.rdoc_dir = PROJ.rdoc_dir
-
- incl = Regexp.new(PROJ.rdoc_include.join('|'))
- excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
- files = PROJ.files.find_all do |fn|
- case fn
- when excl; false
- when incl; true
- else false end
- end
- rd.rdoc_files.push(*files)
-
- title = "#{PROJ.name}-#{PROJ.version} Documentation"
- title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
-
- rd.options << "-t #{title}"
- rd.options.concat(PROJ.rdoc_opts)
- end
-
- desc 'Generate ri locally for testing'
- task :ri => :clobber_ri do
- sh "#{RDOC} --ri -o ri ."
- end
-
- task :clobber_ri do
- rm_r 'ri' rescue nil
- end
-
-end # namespace :doc
-
-desc 'Alias to doc:rdoc'
-task :doc => 'doc:rdoc'
-
-desc 'Remove all build products'
-task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
-
-remove_desc_for_task %w(doc:clobber_rdoc)
-
-# EOF
View
110 tasks/gem.rake
@@ -1,110 +0,0 @@
-# $Id$
-
-require 'rake/gempackagetask'
-
-namespace :gem do
-
- PROJ.spec = Gem::Specification.new do |s|
- s.name = PROJ.name
- s.version = PROJ.version
- s.summary = PROJ.summary
- s.authors = Array(PROJ.authors)
- s.email = PROJ.email
- s.homepage = Array(PROJ.url).first
- s.rubyforge_project = PROJ.rubyforge_name
- s.post_install_message = PROJ.post_install_message
-
- s.description = PROJ.description
-
- PROJ.dependencies.each do |dep|
- s.add_dependency(*dep)
- end
-
- s.files = PROJ.files
- s.executables = PROJ.executables.map {|fn| File.basename(fn)}
- s.extensions = PROJ.files.grep %r/extconf\.rb$/
-
- s.bindir = 'bin'
- dirs = Dir["{#{PROJ.libs.join(',')}}"]
- s.require_paths = dirs unless dirs.empty?
-
- incl = Regexp.new(PROJ.rdoc_include.join('|'))
- excl = PROJ.rdoc_exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
- excl = Regexp.new(excl.join('|'))
- rdoc_files = PROJ.files.find_all do |fn|
- case fn
- when excl; false
- when incl; true
- else false end
- end
- s.rdoc_options = PROJ.rdoc_opts + ['--main', PROJ.rdoc_main]
- s.extra_rdoc_files = rdoc_files
- s.has_rdoc = true
-
- if test ?f, PROJ.test_file
- s.test_file = PROJ.test_file
- else
- s.test_files = PROJ.tests.to_a
- end
-
- # Do any extra stuff the user wants
-# spec_extras.each do |msg, val|
-# case val
-# when Proc
-# val.call(s.send(msg))
-# else
-# s.send "#{msg}=", val
-# end
-# end
- end
-
- desc 'Show information about the gem'
- task :debug do
- puts PROJ.spec.to_ruby
- end
-
- pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
- pkg.need_tar = PROJ.need_tar
- pkg.need_zip = PROJ.need_zip
- pkg.package_files += PROJ.spec.files
- end
- Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
-
- gem_file = if PROJ.spec.platform == Gem::Platform::RUBY
- "#{pkg.package_name}.gem"
- else
- "#{pkg.package_name}-#{PROJ.spec.platform}.gem"
- end
-
- desc "Build the gem file #{gem_file}"
- task :package => "#{pkg.package_dir}/#{gem_file}"
-
- file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.spec.files do
- when_writing("Creating GEM") {
- Gem::Builder.new(PROJ.spec).build
- verbose(true) {
- mv gem_file, "#{pkg.package_dir}/#{gem_file}"
- }
- }
- end
-
- desc 'Install the gem'
- task :install => [:clobber, :package] do
- sh "#{SUDO} #{GEM} install pkg/#{PROJ.spec.full_name}"
- end
-
- desc 'Uninstall the gem'
- task :uninstall do
- sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -x #{PROJ.name}"
- end
-
-end # namespace :gem
-
-desc 'Alias to gem:package'
-task :gem => 'gem:package'
-
-task :clobber => 'gem:clobber_package'
-
-remove_desc_for_task %w(gem:clobber_package)
-
-# EOF
View
49 tasks/manifest.rake
@@ -1,49 +0,0 @@
-# $Id$
-
-require 'find'
-
-namespace :manifest do
-
- desc 'Verify the manifest'
- task :check do
- fn = PROJ.manifest_file + '.tmp'
- files = manifest_files
-
- File.open(fn, 'w') {|fp| fp.puts files}
- lines = %x(#{DIFF} -du #{PROJ.manifest_file} #{fn}).split("\n")
- if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
- lines.map! do |line|
- case line
- when %r/^(-{3}|\+{3})/; nil
- when %r/^@/; Console::ANSICode.blue line
- when %r/^\+/; Console::ANSICode.green line
- when %r/^\-/; Console::ANSICode.red line
- else line end
- end
- end
- puts lines.compact
- rm fn rescue nil
- end
-
- desc 'Create a new manifest'
- task :create do
- files = manifest_files
- unless test(?f, PROJ.manifest_file)
- files << PROJ.manifest_file
- files.sort!
- end
- File.open(PROJ.manifest_file, 'w') {|fp| fp.puts files}
- end
-
- task :assert do
- files = manifest_files
- manifest = File.read(PROJ.manifest_file).split($/)
- raise "ERROR: #{PROJ.manifest_file} is out of date" unless files == manifest
- end
-
-end # namespace :manifest
-
-desc 'Alias to manifest:check'
-task :manifest => 'manifest:check'
-
-# EOF
View
26 tasks/post_load.rake
@@ -1,26 +0,0 @@
-# $Id$
-
-# This file does not define any rake tasks. It is used to load some project
-# settings if they are not defined by the user.
-
-PROJ.rdoc_exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
-PROJ.exclude << "^#{Regexp.escape(PROJ.ann_file)}$"
-
-PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
-
-PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
-
-PROJ.summary ||= PROJ.description.split('.').first
-
-PROJ.files ||=
- if test(?f, PROJ.manifest_file)
- files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
- files.delete ''
- files
- else [] end
-
-PROJ.executables ||= PROJ.files.find_all {|fn| fn =~ %r/^bin/}
-
-PROJ.rdoc_main ||= PROJ.readme_file
-
-# EOF
View
205 tasks/setup.rb
@@ -1,205 +0,0 @@
-# $Id$
-
-require 'rubygems'
-require 'rake'
-require 'rake/clean'
-require 'fileutils'
-require 'ostruct'
-
-PROJ = OpenStruct.new
-
-PROJ.name = nil
-PROJ.summary = nil
-PROJ.description = nil
-PROJ.changes = nil
-PROJ.authors = nil
-PROJ.email = nil
-PROJ.url = nil
-PROJ.version = ENV['VERSION'] || '0.0.0'
-PROJ.rubyforge_name = nil
-PROJ.exclude = %w(tmp$ bak$ ~$ CVS site .svn/ ^pkg/ ^doc/ ^\. ^rails-example/)
-PROJ.release_name = ENV['RELEASE']
-PROJ.history_file = 'HISTORY.rdoc'
-PROJ.manifest_file = 'Manifest.txt'
-PROJ.readme_file = 'README.rdoc'
-
-# Test::Unit
-PROJ.tests = FileList['test/**/*_test.rb']
-PROJ.test_file = 'test/all.rb'
-PROJ.test_opts = []
-
-# Rcov
-PROJ.rcov_dir = 'coverage'
-PROJ.rcov_opts = ['--sort', 'coverage', '-T']
-PROJ.rcov_threshold = 90.0
-PROJ.rcov_threshold_exact = false
-
-# Rdoc
-PROJ.rdoc_opts = []
-PROJ.rdoc_include = %w(^lib/ ^bin/ ^ext/ .txt$)
-PROJ.rdoc_exclude = %w(extconf.rb$)
-PROJ.rdoc_main = nil
-PROJ.rdoc_dir = 'doc'
-PROJ.rdoc_remote_dir = nil
-
-# Gem Packaging
-PROJ.files = nil
-PROJ.executables = nil
-PROJ.dependencies = []
-PROJ.need_tar = true
-PROJ.need_zip = false
-PROJ.post_install_message = nil
-
-# Announce
-PROJ.ann_file = 'announcement.txt'
-PROJ.ann_text = nil
-PROJ.ann_paragraphs = []
-PROJ.ann_email = {
- :from => nil,
- :to => %w(ruby-talk@ruby-lang.org),
- :server => 'localhost',
- :port => 25,
- :domain => ENV['HOSTNAME'],
- :acct => nil,
- :passwd => nil,
- :authtype => :plain
-}
-
-# Load the other rake files in the tasks folder
-rakefiles = Dir.glob('tasks/*.rake').sort
-rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
-import(*rakefiles)
-
-# Setup some constants
-WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
-
-DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
-
-def quiet( &block )
- io = [STDOUT.dup, STDERR.dup]
- STDOUT.reopen DEV_NULL
- STDERR.reopen DEV_NULL
- block.call
-ensure
- STDOUT.reopen io.first
- STDERR.reopen io.last
-end
-
-DIFF = if WIN32 then 'diff.exe'
- else
- if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
- else 'diff' end
- end unless defined? DIFF
-
-SUDO = if WIN32 then ''
- else
- if quiet {system 'which sudo'} then 'sudo'
- else '' end
- end
-
-RCOV = WIN32 ? 'rcov.bat' : 'rcov'
-GEM = WIN32 ? 'gem.bat' : 'gem'
-
-%w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
- begin
- require lib
- Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
- rescue LoadError
- Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
- end
-end
-
-# Reads a file at +path+ and spits out an array of the +paragraphs+
-# specified.
-#
-# changes = paragraphs_of('History.txt', 0..1).join("\n\n")
-# summary, *description = paragraphs_of('README.txt', 3, 3..8)
-#
-def paragraphs_of( path, *paragraphs )
- title = String === paragraphs.first ? paragraphs.shift : nil
- ary = File.read(path).delete("\r").split(/\n\n+/)
-
- result = if title
- tmp, matching = [], false
- rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
- paragraphs << (0..-1) if paragraphs.empty?
-
- ary.each do |val|
- if val =~ rgxp
- break if matching
- matching = true
- rgxp = %r/^=+/i
- elsif matching
- tmp << val
- end
- end
- tmp
- else ary end
-
- result.values_at(*paragraphs)
-end
-
-# Adds the given gem _name_ to the current project's dependency list. An
-# optional gem _version_ can be given. If omitted, the newest gem version
-# will be used.
-#
-def depend_on( name, version = nil )
- spec = Gem.source_index.find_name(name).last
- version = spec.version.to_s if version.nil? and !spec.nil?
-
- PROJ.dependencies << case version
- when nil; [name]
- when %r/^\d/; [name, ">= #{version}"]
- else [name, version] end
-end
-
-# Adds the given arguments to the include path if they are not already there
-#
-def ensure_in_path( *args )
- args.each do |path|
- path = File.expand_path(path)
- $:.unshift(path) if test(?d, path) and not $:.include?(path)
- end
-end
-
-# Find a rake task using the task name and remove any description text. This
-# will prevent the task from being displayed in the list of available tasks.
-#
-def remove_desc_for_task( names )
- Array(names).each do |task_name|
- task = Rake.application.tasks.find {|t| t.name == task_name}
- next if task.nil?
- task.instance_variable_set :@comment, nil
- end
-end
-
-# Change working directories to _dir_, call the _block_ of code, and then
-# change back to the original working directory (the current directory when
-# this method was called).
-#
-def in_directory( dir, &block )
- curdir = pwd
- begin
- cd dir
- return block.call
- ensure
- cd curdir
- end
-end
-
-# Scans the current working directory and creates a list of files that are
-# candidates to be in the manifest.
-#
-def manifest_files
- files = []
- exclude = Regexp.new(PROJ.exclude.join('|'))
- Find.find '.' do |path|
- path.sub! %r/^(\.\/|\/)/o, ''
- next unless test ?f, path
- next if path =~ exclude
- files << path
- end
- files.sort!
-end
-
-# EOF
View
38 tasks/test.rake
@@ -1,38 +0,0 @@
-# $Id$
-
-require 'rake/testtask'
-
-namespace :test do
-
- Rake::TestTask.new(:run) do |t|
- t.libs = PROJ.libs
- t.test_files = if test(?f, PROJ.test_file) then [PROJ.test_file]
- else PROJ.tests end
- t.ruby_opts += PROJ.ruby_opts
- t.ruby_opts += PROJ.test_opts
- end
-
- if HAVE_RCOV
- desc 'Run rcov on the unit tests'
- task :rcov => :clobber_rcov do
- opts = PROJ.rcov_opts.dup << '-o' << PROJ.rcov_dir
- opts = opts.join(' ')
- files = if test(?f, PROJ.test_file) then [PROJ.test_file]
- else PROJ.tests end
- files = files.join(' ')
- sh "#{RCOV} #{files} #{opts}"
- end
-
- task :clobber_rcov do
- rm_r 'coverage' rescue nil
- end
- end
-
-end # namespace :test
-
-desc 'Alias to test:run'
-task :test => 'test:run'
-
-task :clobber => 'test:clobber_rcov' if HAVE_RCOV
-
-# EOF
View
106 test/document_test.rb
@@ -1,70 +1,74 @@
require File.dirname(__FILE__) << '/test_helper'
-context "Document Generation" do
+class DocumentTest < Test::Unit::TestCase
+
+ context "Document Generation" do
- def setup
- change_tmpdir_for_testing
- end
+ setup do
+ change_tmpdir_for_testing
+ end
- specify "documents have a to_pdf method" do
- assert document(:first).respond_to?(:to_pdf)
- end
+ should "have a to_pdf method" do
+ assert document(:first).respond_to?(:to_pdf)
+ end
- specify "can escape characters" do
- assert_equal '\textbackslash{}\textasciitilde{}', RTeX::Document.escape('\~')
- end
+ should "escape characters" do
+ assert_equal '\textbackslash{}\textasciitilde{}', RTeX::Document.escape('\~')
+ end
- specify "documents can use a to_pdf block to move a file to a relative path" do
- begin
- path = File.expand_path(File.dirname(__FILE__) << '/tmp/this_is_relative_to_pwd.pdf')
- document(:first).to_pdf do |filename|
- assert_nothing_raised do
- FileUtils.move filename, path
+ should "use a to_pdf block to move a file to a relative path" do
+ begin
+ path = File.expand_path(File.dirname(__FILE__) << '/tmp/this_is_relative_to_pwd.pdf')
+ document(:first).to_pdf do |filename|
+ assert_nothing_raised do
+ FileUtils.move filename, path
+ end
+ assert File.exists?(path)
end
- assert File.exists?(path)
+ ensure
+ FileUtils.rm path rescue nil
end
- ensure
- FileUtils.rm path rescue nil
end
- end
- specify "can generate PDF and return as a string" do
- @author = 'Foo'
- assert_equal '%PDF', document(:first).to_pdf(binding)[0, 4]
- end
+ should "generate PDF and return as a string" do
+ @author = 'Foo'
+ assert_equal '%PDF', document(:first).to_pdf(binding)[0, 4]
+ end
- specify "can generate TeX source and return as a string with debug option" do
- @author = 'Foo'
- assert_not_equal '%PDF', document(:first, :tex => true).to_pdf(binding)[0, 4]
- end
+ should "generate TeX source and return as a string with debug option" do
+ @author = 'Foo'
+ assert_not_equal '%PDF', document(:first, :tex => true).to_pdf(binding)[0, 4]
+ end
- specify "can generate PDF and give access to file directly" do
- @author = 'Foo'
- data_read = nil
- invocation_result = document(:first).to_pdf(binding) do |filename|
- data_read = File.open(filename, 'rb') { |f| f.read }
- :not_the_file_contents
+ should "generate PDF and give access to file directly" do
+ @author = 'Foo'
+ data_read = nil
+ invocation_result = document(:first).to_pdf(binding) do |filename|
+ data_read = File.open(filename, 'rb') { |f| f.read }
+ :not_the_file_contents
+ end
+ assert_equal '%PDF', data_read[0, 4]
+ assert_equal :not_the_file_contents, invocation_result
end
- assert_equal '%PDF', data_read[0, 4]
- assert_equal :not_the_file_contents, invocation_result
- end
- specify "can generate TeX source and give access to file directly" do
- @author = 'Foo'
- data_read = nil
- invocation_result = document(:first, :tex => true).to_pdf(binding) do |filename|
- data_read = File.open(filename, 'rb') { |f| f.read }
- :not_the_file_contents
+ should "generate TeX source and give access to file directly" do
+ @author = 'Foo'
+ data_read = nil
+ invocation_result = document(:first, :tex => true).to_pdf(binding) do |filename|
+ data_read = File.open(filename, 'rb') { |f| f.read }
+ :not_the_file_contents
+ end
+ assert_not_equal '%PDF', data_read[0, 4]
+ assert_equal :not_the_file_contents, invocation_result
+ end
+
+ should "wrap in a layout using `yield'" do
+ doc = document(:fragment, :layout => 'testing_layout[<%= yield %>]')
+ @name = 'ERB'
+ source = doc.source(binding)
+ assert source =~ /^testing_layout.*?ERB, Fragmented/
end
- assert_not_equal '%PDF', data_read[0, 4]
- assert_equal :not_the_file_contents, invocation_result
- end
- specify "can wrap in a layout using `yield'" do
- doc = document(:fragment, :layout => 'testing_layout[<%= yield %>]')
- @name = 'ERB'
- source = doc.source(binding)
- assert source =~ /^testing_layout.*?ERB, Fragmented/
end
end
View
32 test/filter_test.rb
@@ -1,20 +1,24 @@
require File.dirname(__FILE__) << '/test_helper'
-context "Filtering Documents" do
+class FilterTest < Test::Unit::TestCase
+
+ context "Filtering Documents" do
- specify "can filter through textile" do
- doc = document('text.textile', :filter => 'textile')
- source = doc.source(binding)
- assert source.include?('\item')
- end
+ should "filter through textile" do
+ doc = document('text.textile', :filter => 'textile')
+ source = doc.source(binding)
+ assert source.include?('\item')
+ end
- specify "does not affect layouts" do
- doc = document('text.textile',
- :filter => 'textile',
- :layout => "* layout\n* is\n<%= yield %>")
- source = doc.source(binding)
- assert source.include?("* layout"), "filtered layout"
- assert source.include?('\item'), "didn't filter content"
- end
+ should "not affect layouts" do
+ doc = document('text.textile',
+ :filter => 'textile',
+ :layout => "* layout\n* is\n<%= yield %>")
+ source = doc.source(binding)
+ assert source.include?("* layout"), "filtered layout"
+ assert source.include?('\item'), "didn't filter content"
+ end
+ end
+
end
View
92 test/tempdir_test.rb
@@ -1,63 +1,67 @@
require File.dirname(__FILE__) << '/test_helper'
-context "Creating a temporary directory" do
+class TempdirTest < Test::Unit::TestCase
+
+ context "Creating a temporary directory" do
- def setup
- change_tmpdir_for_testing
- end
+ setup do
+ change_tmpdir_for_testing
+ end
- specify "changes directory" do
- old_location = Dir.pwd
- block_location = nil
- RTeX::Tempdir.open do
- assert_not_equal old_location, Dir.pwd
- block_location = Dir.pwd
+ should "change directory" do
+ old_location = Dir.pwd
+ block_location = nil
+ RTeX::Tempdir.open do
+ assert_not_equal old_location, Dir.pwd
+ block_location = Dir.pwd
+ end
+ assert_equal old_location, Dir.pwd
+ assert !File.exists?(block_location)
end
- assert_equal old_location, Dir.pwd
- assert !File.exists?(block_location)
- end
- specify "uses a 'rtex' name prefix" do
- RTeX::Tempdir.open do
- assert_equal 'rtex-', File.basename(Dir.pwd)[0,5]
+ should "use a 'rtex' name prefix" do
+ RTeX::Tempdir.open do
+ assert_equal 'rtex-', File.basename(Dir.pwd)[0,5]
+ end
end
- end
- specify "by default, removes the directory after use if no exception occurs" do
- path = nil
- RTeX::Tempdir.open do
- path = Dir.pwd
- assert File.exists?(path)
+ should "remove the directory after use if no exception occurs by default" do
+ path = nil
+ RTeX::Tempdir.open do
+ path = Dir.pwd
+ assert File.exists?(path)
+ end
+ assert !File.exists?(path)
end
- assert !File.exists?(path)
- end
- specify "returns result of last statment if automatically removing the directory" do
- result = RTeX::Tempdir.open do
- :last
+ should "return the result of the last statement if automatically removing the directory" do
+ result = RTeX::Tempdir.open do
+ :last
+ end
+ assert_equal :last, :last
end
- assert_equal :last, :last
- end
- specify "returns result of last statment if not automatically removing the directory" do
- tempdir = nil # to capture value
- result = RTeX::Tempdir.open do |tempdir|
- :last
+ should "return the result of the last statment if not automatically removing the directory" do
+ tempdir = nil # to capture value
+ result = RTeX::Tempdir.open do |tempdir|
+ :last
+ end
+ tempdir.remove!
+ assert_equal :last, :last
end
- tempdir.remove!
- assert_equal :last, :last
- end
- specify "does not remove the directory after use if an exception occurs" do
- path = nil
- assert_raises RuntimeError do
- RTeX::Tempdir.open do
- path = Dir.pwd
- assert File.directory?(path)
- raise "Test exception!"
+ should "not remove the directory after use if an exception occurs" do
+ path = nil
+ assert_raises RuntimeError do
+ RTeX::Tempdir.open do
+ path = Dir.pwd
+ assert File.directory?(path)
+ raise "Test exception!"
+ end
end
+ assert File.directory?(path)
end
- assert File.directory?(path)
+
end
end
View
11 test/test_helper.rb
@@ -1,9 +1,12 @@
require 'test/unit'
-require 'rubygems' rescue nil
-require 'test/spec'
-require 'flexmock'
-require 'flexmock/test_unit'
+require 'rubygems'
+begin
+ require 'shoulda'
+ require 'flexmock/test_unit'
+rescue LoadError
+ abort "the `Shoulda' and `flexmock' gems are required for testing"
+end
require File.dirname(__FILE__) << '/../lib/rtex'
Please sign in to comment.
Something went wrong with that request. Please try again.