Skip to content

Commit

Permalink
Merge pull request #243 from rubychan/extend-specs
Browse files Browse the repository at this point in the history
Add Specs
  • Loading branch information
korny authored Nov 24, 2019
2 parents 77734f6 + e0b08d7 commit 727747e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rvm:
- 2.4
- 2.5
- 2.6
- 2.7
- ruby-head
- jruby
matrix:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 4 additions & 2 deletions rake_tasks/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
28 changes: 27 additions & 1 deletion spec/coderay_spec.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down

0 comments on commit 727747e

Please sign in to comment.