features/step_definitions/format_steps.rb in activeadmin-0.3.4 vs features/step_definitions/format_steps.rb in activeadmin-0.4.0
- old
+ new
@@ -1,5 +1,13 @@
+CSVLib = if RUBY_VERSION =~ /^1.8/
+ require 'fastercsv'
+ FasterCSV
+ else
+ require 'csv'
+ CSV
+ end
+
Then "I should see nicely formatted datetimes" do
page.body.should =~ /\w+ \d{1,2}, \d{4} \d{2}:\d{2}/
end
Then /^I should see a link to download "([^"]*)"$/ do |format_type|
@@ -12,10 +20,10 @@
csv_filename = "#{resource_name}-#{Time.now.strftime("%Y-%m-%d")}.csv"
page.response_headers['Content-Disposition'].should == %{attachment; filename="#{csv_filename}"}
body = page.driver.response.body
begin
- csv = CSV.parse(body)
+ csv = CSVLib.parse(body)
table.raw.each_with_index do |expected_row, row_index|
expected_row.each_with_index do |expected_cell, col_index|
cell = csv.try(:[], row_index).try(:[], col_index)
if expected_cell.blank?
cell.should be_nil