summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/coderay_spec.rb28
-rw-r--r--spec/spec_helper.rb6
2 files changed, 31 insertions, 3 deletions
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`.