-
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
Võ Anh Duy
committed
Oct 13, 2013
1 parent
77956cd
commit 6162485
Showing
3 changed files
with
67 additions
and
34 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,55 @@ | ||
require "spec_helper" | ||
|
||
describe Exporter do | ||
|
||
before(:all) {FactoryGirl.create(:user)} | ||
|
||
let(:data){ User.all } | ||
|
||
describe '.export' do | ||
context 'ActiveRecord::Relation' do | ||
it 'can export to csv' do | ||
expect(Exporter.configuration.can_export?(data, :csv)).to eql(true) | ||
end | ||
|
||
it 'can export to excel' do | ||
expect(Exporter.configuration.can_export?(data, :excel)).to eql(true) | ||
end | ||
|
||
it 'can\'t export not register type' do | ||
This comment has been minimized.
Sorry, something went wrong. |
||
expect(Exporter.configuration.can_export?(data, :some_weird_type)).to eql(false) | ||
end | ||
|
||
context ':csv' do | ||
it 'return an Exporter::Document subclass' do | ||
document = Exporter.export(data, :csv) | ||
expect(document).to be_kind_of(Exporter::Document) | ||
end | ||
|
||
it 'write to file correct' do | ||
document = Exporter.export(data, :csv) | ||
document.to_file('dummy.csv') | ||
content = File.read('dummy.csv') | ||
expect(content.length).to eql(document.data.length) | ||
File.delete('dummy.csv') | ||
end | ||
end | ||
|
||
context ':excel' do | ||
it 'return an Exporter::Document subclass' do | ||
document = Exporter.export(data, :excel) | ||
expect(document).to be_kind_of(Exporter::Document) | ||
end | ||
|
||
it 'write to file correct' do | ||
document = Exporter.export(data, :excel) | ||
document.to_file('dummy.xls') | ||
content = Spreadsheet.open('dummy.xls') | ||
expect(content.worksheet(0).last_row_index).to eql(document.data.worksheet(0).last_row_index) | ||
expect(content.worksheet(0).row(1)).to eql(document.data.worksheet(0).row(1)) | ||
File.delete('dummy.xls') | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
You can use double quote here:
"can't export not register type"