Skip to content

Commit

Permalink
add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
timfjord committed Feb 6, 2015
1 parent 65fc817 commit 5f865a8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions carrierwave-data-uri.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ Gem::Specification.new do |spec|

spec.add_development_dependency 'bundler', '~> 1.7'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'activerecord'
end
28 changes: 28 additions & 0 deletions spec/parser_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'spec_helper'

RSpec.describe CarrierWave::DataUri::Parser do
let(:data_uri) do
'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP////8AAP///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
end

describe 'initialization' do
it 'should raise error when data is invalid' do
expect { CarrierWave::DataUri::Parser.new 'invadli_data' }.to raise_error
end

it 'should parse data on init' do
parsed = CarrierWave::DataUri::Parser.new data_uri

expect(parsed.extension).to eql 'gif'
end
end

describe '#to_file' do
it 'should generate temp file based on data' do
parsed = CarrierWave::DataUri::Parser.new data_uri
file = parsed.to_file

expect(file).to be_a_kind_of Tempfile
end
end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'bundler/setup'
Bundler.setup

require 'carrierwave-data-uri'

0 comments on commit 5f865a8

Please sign in to comment.