Skip to content

Commit 727747e

Browse files
authored
Merge pull request #243 from rubychan/extend-specs
Add Specs
2 parents 77734f6 + e0b08d7 commit 727747e

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rvm:
1414
- 2.4
1515
- 2.5
1616
- 2.6
17+
- 2.7
1718
- ruby-head
1819
- jruby
1920
matrix:

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ group :development do
1212
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'
1313
gem 'RedCloth', RUBY_PLATFORM == 'java' ? '= 4.2.9' : '>= 4.0.3'
1414
gem 'rspec', '~> 3.9.0'
15-
gem 'simplecov', '~> 0.17.1'
1615
gem 'shoulda-context', RUBY_VERSION < '1.9' ? '= 1.2.1' : '>= 1.2.1'
16+
gem 'simplecov', '~> 0.17.1'
1717
gem 'term-ansicolor', RUBY_VERSION < '2.0' ? '~> 1.3.2' : '>= 1.3.2'
1818
gem 'test-unit', RUBY_VERSION < '1.9' ? '~> 2.0' : '>= 3.0'
1919
gem 'tins', RUBY_VERSION < '2.0' ? '~> 1.6.0' : '>= 1.6.0'

rake_tasks/test.rake

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ Please rename or remove it and run again to use the GitHub repository:
7979
end
8080
end
8181

82-
require 'rspec/core/rake_task'
83-
RSpec::Core::RakeTask.new(:spec)
82+
if RUBY_VERSION >= '1.9'
83+
require 'rspec/core/rake_task'
84+
RSpec::Core::RakeTask.new(:spec)
85+
end
8486

8587
task :test => %w(test:functional test:units test:exe spec)

spec/coderay_spec.rb

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
require File.expand_path('../spec_helper', __FILE__)
22

33
RSpec.describe CodeRay do
4-
describe 'version' do
4+
describe '::VERSION' do
55
it "returns the Gem's version" do
66
expect(CodeRay::VERSION).to match(/\A\d\.\d\.\d?\z/)
77
end
88
end
9+
10+
describe '.coderay_path' do
11+
it 'returns an absolute file path to the given code file' do
12+
base = File.expand_path('../..', __FILE__)
13+
expect(CodeRay.coderay_path('file')).to eq("#{base}/lib/coderay/file")
14+
end
15+
end
16+
17+
describe '.scan' do
18+
let(:code) { 'puts "Hello, World!"' }
19+
let(:tokens) do
20+
[
21+
['puts', :ident],
22+
[' ', :space],
23+
[:begin_group, :string],
24+
['"', :delimiter],
25+
['Hello, World!', :content],
26+
['"', :delimiter],
27+
[:end_group, :string]
28+
].flatten
29+
end
30+
31+
it 'returns tokens' do
32+
expect(CodeRay.scan(code, :ruby).tokens).to eq(tokens)
33+
end
34+
end
935
end

spec/spec_helper.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
require 'simplecov'
2-
SimpleCov.start
1+
unless RUBY_VERSION[/^2.3/]
2+
require 'simplecov'
3+
SimpleCov.start
4+
end
35

46
# This file was generated by the `rspec --init` command. Conventionally, all
57
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.

0 commit comments

Comments
 (0)