Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Kane committed Feb 5, 2012
1 parent d3c6ad8 commit be3574d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .rspec
@@ -0,0 +1,2 @@
--color
--format documentation
3 changes: 3 additions & 0 deletions Rakefile
@@ -1,2 +1,5 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new("spec")
2 changes: 2 additions & 0 deletions cld.gemspec
Expand Up @@ -17,4 +17,6 @@ Gem::Specification.new do |gem|
gem.version = CLD::VERSION

gem.add_dependency "ffi"

gem.add_development_dependency "rspec"
end
30 changes: 30 additions & 0 deletions spec/cld_spec.rb
@@ -0,0 +1,30 @@
# encoding: UTF-8
require "spec_helper"

describe CLD do

context "English text" do
subject { CLD.detect_language("This is a test") }

it { subject[:name].should eq("ENGLISH") }
it { subject[:code].should eq("en") }
it { subject[:reliable].should be_true }
end

context "French text" do
subject { CLD.detect_language("plus ça change, plus c'est la même chose") }

it { subject[:name].should eq("FRENCH") }
it { subject[:code].should eq("fr") }
it { subject[:reliable].should be_true }
end

context "Unknown text" do
subject { CLD.detect_language("") }

it { subject[:name].should eq("Unknown") }
it { subject[:code].should eq("un") }
it { subject[:reliable].should be_true }
end

end
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,6 @@
require "rubygems"
require "bundler/setup"
Bundler.require(:default)

RSpec.configure do |config|
end

0 comments on commit be3574d

Please sign in to comment.