Skip to content

Add Specs #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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