summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/coderay.rb2
-rw-r--r--lib/coderay/helpers/plugin.rb6
-rw-r--r--rake_tasks/statistic.rake7
-rwxr-xr-xtest/functional/basic.rb58
-rwxr-xr-xtest/functional/suite.rb8
5 files changed, 74 insertions, 7 deletions
diff --git a/lib/coderay.rb b/lib/coderay.rb
index c7b5e7f..be88a90 100644
--- a/lib/coderay.rb
+++ b/lib/coderay.rb
@@ -133,7 +133,7 @@ module CodeRay
# Minor: odd for beta, even for stable
# Teeny: development state
# Revision: Subversion Revision number (generated on rake)
- Version = '0.7.2'
+ VERSION = '0.7.4'
require 'coderay/tokens'
require 'coderay/scanner'
diff --git a/lib/coderay/helpers/plugin.rb b/lib/coderay/helpers/plugin.rb
index aba6ff7..445d500 100644
--- a/lib/coderay/helpers/plugin.rb
+++ b/lib/coderay/helpers/plugin.rb
@@ -32,9 +32,9 @@ module PluginHost
PLUGIN_HOSTS = []
PLUGIN_HOSTS_BY_ID = {} # dummy hash
- # Loads all plugins using all_plugin_names and load.
+ # Loads all plugins using list and load.
def load_all
- for plugin in all_plugin_names
+ for plugin in list
load plugin
end
end
@@ -160,7 +160,7 @@ module PluginHost
# Returns an array of all .rb files in the plugin path.
#
# The extension .rb is not included.
- def all_plugin_names
+ def list
Dir[path_to('*')].select do |file|
File.basename(file)[/^(?!_)\w+\.rb$/]
end.map do |file|
diff --git a/rake_tasks/statistic.rake b/rake_tasks/statistic.rake
index 4923ed1..1343cd2 100644
--- a/rake_tasks/statistic.rake
+++ b/rake_tasks/statistic.rake
@@ -8,8 +8,9 @@ task :stats do
[' Encoders', 'lib/coderay/encoders/**'],
[' Helpers', 'lib/coderay/helpers/**'],
[' Styles', 'lib/coderay/styles/**'],
- ['Test', 'test'],
- [' Test Data', 'test/*/**', /\.in\./, false],
- ['Demo Tests', 'demo/**']
+ ['Functional Tests', 'test/functional/**'],
+ ['Scanner Tests', 'test/scanners/**', /suite\.rb$/],
+ #[' Test Data', 'test/scanners/**', /\.in\./, false],
+ ['Demo Tests', 'sample/**']
).print
end
diff --git a/test/functional/basic.rb b/test/functional/basic.rb
new file mode 100755
index 0000000..f5699ae
--- /dev/null
+++ b/test/functional/basic.rb
@@ -0,0 +1,58 @@
+require "test/unit"
+
+require "coderay"
+
+class Basic < Test::Unit::TestCase
+ def test_version
+ assert_nothing_raised do
+ CodeRay::VERSION
+ end
+ end
+
+ def test_classes_exist
+ assert_nothing_raised do
+ CodeRay
+ CodeRay::Encoders::Encoder
+ CodeRay::Encoders
+ CodeRay::Scanners::Scanner
+ CodeRay::Scanners
+ CodeRay::Tokens
+ CodeRay::TokenStream
+ Plugin
+ WordList
+ end
+ end
+
+ RUBY_TEST_CODE = 'puts "Hello, World!"'
+
+ def test_simple_scan
+ assert_nothing_raised do
+ CodeRay.scan(RUBY_TEST_CODE, :ruby)
+ end
+ end
+
+ def test_simple_highlight
+ assert_nothing_raised do
+ CodeRay.scan(RUBY_TEST_CODE, :ruby).html
+ end
+ end
+
+ def test_duo
+ assert_equal(RUBY_TEST_CODE,
+ CodeRay::Duo[:plain, :plain].highlight(RUBY_TEST_CODE))
+ end
+
+ ENCODERS_LIST = %w(
+ count debug div html null page span statistic text tokens xml yaml
+ )
+ def test_list_of_encoders
+ assert_equal(ENCODERS_LIST, CodeRay::Encoders.list)
+ end
+
+ SCANNERS_LIST = %w(
+ c delphi html nitro_xhtml plaintext rhtml ruby xml
+ )
+ def test_list_of_encoders
+ assert_equal(SCANNERS_LIST, CodeRay::Scanners.list)
+ end
+end \ No newline at end of file
diff --git a/test/functional/suite.rb b/test/functional/suite.rb
new file mode 100755
index 0000000..51f9a59
--- /dev/null
+++ b/test/functional/suite.rb
@@ -0,0 +1,8 @@
+require 'test/unit'
+require 'pathname'
+
+MYDIR = File.dirname(__FILE__)
+LIBDIR = Pathname.new(MYDIR).join('..', '..', 'lib').cleanpath
+$LOAD_PATH.unshift MYDIR, LIBDIR
+
+require 'basic' \ No newline at end of file