This repository has been archived by the owner on Mar 14, 2021. It is now read-only.
forked from bitpay/ruby-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
74 lines (62 loc) · 2.16 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
63
64
65
66
67
68
69
70
71
72
73
74
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
require 'capybara'
require 'capybara/poltergeist'
require 'mongo'
require 'cucumber'
require 'cucumber/rake/task'
require_relative 'config/constants.rb'
require_relative 'config/capybara.rb'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format pretty"
end
desc "Bitpay Tasks"
namespace :bitpay do
desc "Clear all claim codes from the test server."
task :clear_claim_codes do
puts "clearing claim codes"
client = Mongo::MongoClient.new
db = client['bitpay-dev']
coll = db['tokenaccesses']
coll.remove()
puts "claim codes cleared"
end
desc "Clear rate limiters from local mongo host"
task :clear_rate_limiters do
puts "clearing rate limiters"
client = Mongo::MongoClient.new
db = client['bitpay-dev']
coll = db['ratelimiters']
coll.remove()
puts "rate limiters cleared"
end
desc "Clear local pem and token file"
task :clear_local_files do
puts "clearing local files"
HOME_DIR = File.join(Dir.home, '.bitpay')
KEY_FILE = File.join(HOME_DIR, 'bitpay.pem')
TOKEN_FILE = File.join(HOME_DIR, 'tokens.json')
File.delete(KEY_FILE) if File.file?(KEY_FILE)
File.delete(TOKEN_FILE) if File.file?(TOKEN_FILE)
puts "local files cleared"
end
desc "Clear tokens, rate limiters, and local files."
task :clear do
["bitpay:clear_local_files", "bitpay:clear_rate_limiters", "bitpay:clear_claim_codes"].each{|task| Rake::Task[task].reenable}
["bitpay:clear_local_files", "bitpay:clear_rate_limiters", "bitpay:clear_claim_codes"].each{|task| Rake::Task[task].invoke}
end
desc "Run specs and clear claim codes and rate_limiters."
task :spec_clear => ['spec', 'clear_claim_codes', 'clear_rate_limiters']
desc "Run specs, clear data, run cukes, clear data"
task :tests_clear do
Rake::Task["bitpay:clear"].invoke
Rake::Task["spec"].invoke
Rake::Task["bitpay:clear"].reenable
Rake::Task["bitpay:clear"].invoke
Rake::Task["features"].invoke
Rake::Task["bitpay:clear"].reenable
Rake::Task["bitpay:clear"].invoke
end
end