-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
executable file
·62 lines (52 loc) · 1.46 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'cucumber'
require 'json'
require 'cucumber/rake/task'
require 'mongo'
require 'csv'
base = File.dirname(__FILE__)
Dir.glob(base + '/lib/*.rb').each { |f| require f }
include Mongo
desc "Roda todos os testes (javascript e cucumber)"
task :test => [:spec, :features, :jstest]
desc "Roda os testes em CI (excluindo JS por enquanto)"
task :ci => [:spec, :features]
desc "Roda os testes de pepino"
task :features do
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format pretty --tag ~@pending"
end
end
desc "Roda os testes de javascript"
task :jstest do
puts "===== Testes de Javascript ====="
sh 'karma start'
end
desc "Roda os testes de unidade"
task :spec do
puts "===== Testes de Unidade ====="
sh 'bundle exec rspec test/ruby/lib/*_spec.rb'
end
task :environment do
require './environment'
end
desc "Puxa os dados de sessão"
task :puxar_sessoes => :environment do
LeitorSessoes.puxar_sessoes
end
desc "Importa dados da planilha (db/vereadores.csv)"
task :importar_vereadores do
puts "Deletando vereadores..."
uri = ENV['MONGOLAB_URI'] || 'mongodb://localhost/pcv'
db_name = uri[%r{/([^/\?]+)(\?|$)}, 1]
client = MongoClient.from_uri(uri)
db = client.db(db_name)
puts db_name
db.drop_collection('vereadors')
puts "Importando planilha"
data = CSV.read("db/vereadores.csv", :headers => true, :encoding => "UTF-8")
col = db.collection('vereadors')
data.each do |row|
h = row.to_hash
col.save(h)
end
end