summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2019-11-24 17:05:36 +0100
committerGitHub <noreply@github.com>2019-11-24 17:05:36 +0100
commit727747e5c07eafe6496123ea20fb671cd6c3ad5b (patch)
treeb8cba26f761aa7b3baa28501d312a9a5a740891f
parent77734f6cfa1d90b80c53ac71c880dc5978e58dd7 (diff)
parente0b08d754b205f9204415c8d08b93a30cb92c04b (diff)
downloadcoderay-727747e5c07eafe6496123ea20fb671cd6c3ad5b.tar.gz
Merge pull request #243 from rubychan/extend-specs
Add Specs
-rw-r--r--.travis.yml1
-rw-r--r--Gemfile2
-rw-r--r--rake_tasks/test.rake6
-rw-r--r--spec/coderay_spec.rb28
-rw-r--r--spec/spec_helper.rb6
5 files changed, 37 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml
index 19932b4..a8f407e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,7 @@ rvm:
- 2.4
- 2.5
- 2.6
+ - 2.7
- ruby-head
- jruby
matrix:
diff --git a/Gemfile b/Gemfile
index 0369afe..559648a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -12,8 +12,8 @@ group :development do
gem 'rdoc', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3') ? '~> 4.2.2' : Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2') ? '< 6' : '>= 6'
gem 'RedCloth', RUBY_PLATFORM == 'java' ? '= 4.2.9' : '>= 4.0.3'
gem 'rspec', '~> 3.9.0'
- gem 'simplecov', '~> 0.17.1'
gem 'shoulda-context', RUBY_VERSION < '1.9' ? '= 1.2.1' : '>= 1.2.1'
+ gem 'simplecov', '~> 0.17.1'
gem 'term-ansicolor', RUBY_VERSION < '2.0' ? '~> 1.3.2' : '>= 1.3.2'
gem 'test-unit', RUBY_VERSION < '1.9' ? '~> 2.0' : '>= 3.0'
gem 'tins', RUBY_VERSION < '2.0' ? '~> 1.6.0' : '>= 1.6.0'
diff --git a/rake_tasks/test.rake b/rake_tasks/test.rake
index 277bd33..e72c96b 100644
--- a/rake_tasks/test.rake
+++ b/rake_tasks/test.rake
@@ -79,7 +79,9 @@ Please rename or remove it and run again to use the GitHub repository:
end
end
-require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new(:spec)
+if RUBY_VERSION >= '1.9'
+ require 'rspec/core/rake_task'
+ RSpec::Core::RakeTask.new(:spec)
+end
task :test => %w(test:functional test:units test:exe spec)
diff --git a/spec/coderay_spec.rb b/spec/coderay_spec.rb
index 2c7b91e..88c9aec 100644
--- a/spec/coderay_spec.rb
+++ b/spec/coderay_spec.rb
@@ -1,9 +1,35 @@
require File.expand_path('../spec_helper', __FILE__)
RSpec.describe CodeRay do
- describe 'version' do
+ describe '::VERSION' do
it "returns the Gem's version" do
expect(CodeRay::VERSION).to match(/\A\d\.\d\.\d?\z/)
end
end
+
+ describe '.coderay_path' do
+ it 'returns an absolute file path to the given code file' do
+ base = File.expand_path('../..', __FILE__)
+ expect(CodeRay.coderay_path('file')).to eq("#{base}/lib/coderay/file")
+ end
+ end
+
+ describe '.scan' do
+ let(:code) { 'puts "Hello, World!"' }
+ let(:tokens) do
+ [
+ ['puts', :ident],
+ [' ', :space],
+ [:begin_group, :string],
+ ['"', :delimiter],
+ ['Hello, World!', :content],
+ ['"', :delimiter],
+ [:end_group, :string]
+ ].flatten
+ end
+
+ it 'returns tokens' do
+ expect(CodeRay.scan(code, :ruby).tokens).to eq(tokens)
+ end
+ end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 66f4127..78a60b2 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,5 +1,7 @@
-require 'simplecov'
-SimpleCov.start
+unless RUBY_VERSION[/^2.3/]
+ require 'simplecov'
+ SimpleCov.start
+end
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.