spec/integration_spec.rb in cloudxls-rails-0.4.3 vs spec/integration_spec.rb in cloudxls-rails-0.5.0
- old
+ new
@@ -12,19 +12,34 @@
:expired_at => DateTime.new(2013,12,25,12,30,30),
:unix_timestamp => DateTime.new(2013,12,25,12,30,30),
:published => false)
end
+ it "#as_csv" do
+ expect( @post.as_csv(except: [:unix_timestamp, :created_at, :updated_at]) ).to eq([@post.id, "hello world", 12_032, 0.24, "2013-12-24", "2013-12-25T12:30:30.000+0000", false])
+ expect( @post.as_csv(only: [:title]) ).to eq(["hello world"])
+ expect( @post.as_csv(only: [:title, :visits]) ).to eq(["hello world", 12_032])
+ expect( @post.as_csv(only: [:expired_at]) ).to eq(["2013-12-25T12:30:30.000+0000"])
+ end
+
it "has a working test_app" do
visit '/'
page.should have_content "Users"
end
it "/posts.csv has a working csv export" do
visit '/posts.csv'
page.should have_content [
"Title,Visits,Conversion Rate,Published On,Published,Expired At",
"hello world,12032,0.24,2013-12-24,false,2013-12-25T12:30:30.000+0000"
+ ].join("\n")
+ end
+
+ it "/posts/all_columns.csv streams csv" do
+ visit '/posts/all_columns.csv'
+ page.should have_content [
+ "Id,Title,Visits,Conversion Rate,Published On,Expired At,Published,Unix Timestamp,Created At,Updated At",
+ "1,hello world,12032,0.24,2013-12-24,2013-12-25T12:30:30.000+0000,false,2013-12-25T12:30:30.000+0000,#{@post.created_at.as_csv},#{@post.updated_at.as_csv}"
].join("\n")
end
it "/posts/stream.csv streams csv" do
visit '/posts/stream.csv'