more code coverage for some patches (liquid + String) + send code coverage reports to coveralls

did committed Feb 08, 2015
commit d19170b238f76fbe5c92425f12c968b6c6b8f17c
Showing 6 changed files with 105 additions and 2 deletions
.travis.yml +1 -0
@@ @@ -3,6 +3,7 @@ rvm:
- 2.1.3
env:
- CODECLIMATE_REPO_TOKEN=8d9c25de4eff1cd06d3accdc09775397e1a81be67e2a159453ba4e4408acae16
+ - COVERALLS_REPO_TOKEN=K7iSITlpmmpgh2uanmudoO5Hv62coULxy
addons:
code_climate:
repo_token: 8d9c25de4eff1cd06d3accdc09775397e1a81be67e2a159453ba4e4408acae16
Gemfile +1 -0
@@ @@ -18,6 +18,7 @@ group :test do
gem 'pry-byebug'
gem 'codeclimate-test-reporter', require: false
+ gem 'coveralls', require: false
end
platform :ruby do
Gemfile.lock +15 -0
@@ @@ -73,6 +73,12 @@ GEM
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
+ coveralls (0.7.3)
+ multi_json (~> 1.10)
+ rest-client (~> 1.7)
+ simplecov (~> 0.9.1)
+ term-ansicolor (~> 1.3)
+ thor (~> 0.19.1)
debugger-linecache (1.2.0)
diff-lcs (1.2.5)
docile (1.1.5)
@@ @@ -118,6 +124,7 @@ GEM
morphine (0.1.1)
multi_json (1.10.1)
multi_xml (0.5.5)
+ netrc (0.10.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
pry (0.10.1)
@@ @@ -146,6 +153,9 @@ GEM
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
+ rest-client (1.7.2)
+ mime-types (>= 1.16, < 3.0)
+ netrc (~> 0.7)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
@@ @@ -173,8 +183,12 @@ GEM
sprockets-sass (1.3.1)
sprockets (~> 2.0)
tilt (~> 1.1)
+ term-ansicolor (1.3.0)
+ tins (~> 1.0)
+ thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
+ tins (1.3.3)
tzinfo (1.2.2)
thread_safe (~> 0.1)
@@ @@ -184,6 +198,7 @@ PLATFORMS
DEPENDENCIES
bundler (~> 1.7)
codeclimate-test-reporter
+ coveralls
i18n-spec (~> 0.6.0)
json_spec (~> 1.1.4)
locomotivecms_steam!
spec/spec_helper.rb +4 -2
@@ @@ -1,10 +1,12 @@
+ require 'simplecov'
require 'codeclimate-test-reporter'
+ require 'coveralls'
- require 'simplecov'
SimpleCov.start do
formatter SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
- CodeClimate::TestReporter::Formatter
+ CodeClimate::TestReporter::Formatter,
+ Coveralls::SimpleCov::Formatter
]
add_filter 'spec/'
spec/unit/core_ext/string_spec.rb +34 -0
@@ @@ -0,0 +1,34 @@
+ require 'spec_helper'
+
+ describe String do
+
+ describe '#to_bool' do
+
+ subject { string.to_bool }
+
+ describe 'true values' do
+
+ %w(true t yes y 1).each do |val|
+ let(:string) { val }
+ it { is_expected.to eq true }
+ end
+
+ end
+
+ describe 'false values' do
+
+ (%w(false f no n 0) + ['']).each do |val|
+ let(:string) { val }
+ it { is_expected.to eq false }
+ end
+
+ end
+
+ describe 'no truthy or falsy' do
+ let(:string) { 'foo' }
+ it { expect { subject }.to raise_error(%(invalid value for Boolean: "foo")) }
+ end
+
+ end
+
+ end
spec/unit/liquid/patches_spec.rb +50 -0
@@ @@ -0,0 +1,50 @@
+ require 'spec_helper'
+
+ describe Liquid::StandardFilters do
+
+ describe '#to_number' do
+
+ subject { SimpleFilters.new.send(:to_number, obj) }
+
+ context 'Integer' do
+ let(:obj) { 42 }
+ it { is_expected.to eq 42 }
+ end
+
+ context 'String (Integer)' do
+ let(:obj) { '42' }
+ it { is_expected.to eq 42 }
+ end
+
+ context 'String (Float)' do
+ let(:obj) { '42.00' }
+ it { is_expected.to eq 42.0 }
+ end
+
+ context 'Date' do
+ let(:obj) { Date.parse('2007/06/29') }
+ it { is_expected.to eq 1183068000 }
+ end
+
+ context 'Time' do
+ let(:obj) { Time.parse('2007/06/29 00:00:00') }
+ it { is_expected.to eq 1183068000 }
+ end
+
+ context 'DateTime' do
+ let(:obj) { DateTime.parse('2007/06/29 00:00:00+0000') }
+ it { is_expected.to eq 1183075200 }
+ end
+
+ context 'Other object' do
+ let(:obj) { nil }
+ it { is_expected.to eq 0 }
+ end
+
+ end
+
+ class SimpleFilters
+ include Liquid::StandardFilters
+ end
+
+ end