Sha256: a4a46e52211a6798f47bb24907396a3e084e3a7379a58146ec377835b1c533d9

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

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|
  Then %{I should see "#{format_type}" within "#index_footer a"}
end

# Check first rows of the displayed CSV.
Then /^I should download a CSV file for "([^"]*)" containing:$/ do |resource_name, table|
  page.response_headers['Content-Type'].should == 'text/csv; charset=utf-8'
  csv_filename = "#{resource_name}-#{Time.now.strftime("%Y-%m-%d")}.csv"
  page.response_headers['Content-Disposition'].should == %{attachment; filename="#{csv_filename}"}

  begin
    csv = CSV.parse(page.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
        else
          (cell || '').should match(/#{expected_cell}/)
        end
      end
    end
  rescue
    puts "Expecting:"
    p table.raw
    puts "to match:"
    p csv
    raise $!
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saulolso-activeadmin-0.2.2.1 features/step_definitions/format_steps.rb
saulolso-activeadmin-0.2.2 features/step_definitions/format_steps.rb