Sha256: d8dc0b0be4a55e0e479bfd44947165352755170611a1de3e377186456a82fec5

Contents?: true

Size: 936 Bytes

Versions: 5

Compression:

Stored size: 936 Bytes

Contents

# -*- encoding: utf-8 -*-
require 'helper'
init_database

class StateBlue < ActiveRecord::Base
  self.table_name = 'states'
  self.primary_key = 'postal_abbreviation'
  data_miner do
    sql "Brighter Planet's list of states (as a URL)", 'http://data.brighterplanet.com/states.sql'
  end
end

class StateRed < ActiveRecord::Base
  self.table_name = 'states'
  self.primary_key = 'postal_abbreviation'
  data_miner do
    sql "Brighter Planet's list of states (as a URL)", 'http://data.brighterplanet.com/states.sql'
    sql "Mess up weights", %{UPDATE states SET name = 'Foobar'}
  end
end

describe DataMiner::Step::Sql do
  before do
    StateBlue.delete_all rescue nil
  end
  it "can be provided as a URL" do
    StateBlue.run_data_miner!
    StateBlue.where(:name => 'Wisconsin').count.must_equal 1
  end
  it "can be provided as a string" do
    StateRed.run_data_miner!
    StateRed.find('NJ').name.must_equal 'Foobar'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
data_miner-3.0.0 test/data_miner/step/test_sql.rb
data_miner-3.0.0.rc2 test/data_miner/step/test_sql.rb
data_miner-3.0.0.rc1 test/data_miner/step/test_sql.rb
data_miner-3.0.0.beta test/data_miner/step/test_sql.rb
data_miner-3.0.0.alpha test/data_miner/step/test_sql.rb