forked from timfjord/carrierwave-data-uri
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'bundler/setup' | ||
Bundler.setup | ||
|
||
require 'carrierwave-data-uri' |