Skip to content

Commit

Permalink
Add SimpleCov
Browse files Browse the repository at this point in the history
  • Loading branch information
janko committed Nov 18, 2015
1 parent 874ce73 commit 2a60064
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pkg/
.env
.sass-cache
www/build
coverage/
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ source 'https://rubygems.org'
gemspec

gem "pry"
gem "simplecov"
9 changes: 6 additions & 3 deletions lib/shrine/plugins/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ def _log_message_heroku(data)
# hashes.
def count(object)
case object
when Hash then object.count
when Array then object.inject(0) { |sum, o| sum += count(o) }
else 1
when Hash
object.count
when Array
object.inject(0) { |sum, o| sum += count(o) }
else
1
end
end

Expand Down
3 changes: 2 additions & 1 deletion test/plugin/versions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def process(io, context)
end
end

assert_raises(Shrine::InvalidFile) { @uploader.upload(fakeio) }
error = assert_raises(Shrine::InvalidFile) { @uploader.upload(fakeio) }
assert_match /is not a valid IO object/, error.message
end
end
14 changes: 14 additions & 0 deletions test/shrine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@
end
end

describe ".find_storage" do
it "finds by symbol names" do
assert_equal @uploader.storage, @uploader.class.find_storage(:store)
end

it "finds by string names" do
assert_equal @uploader.storage, @uploader.class.find_storage("store")
end

it "raises an error if storage wasn't found" do
assert_raises(Shrine::Error) { @uploader.class.find_storage(:foo) }
end
end

describe "#initialize" do
it "symbolizes storage key" do
shrine = Class.new(Shrine)
Expand Down
7 changes: 7 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
require "bundler/setup"

if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start do
add_filter "/test/"
end
end

require "minitest/autorun"
require "minitest/pride"
require "minitest/hooks/default"
Expand Down

0 comments on commit 2a60064

Please sign in to comment.