-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
61 lines (46 loc) · 1.51 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
#!/usr/bin/env rake
require "bundler/gem_tasks"
require "rspec/core/rake_task"
Dir.glob('benchmarks/*.rake').each { |r| import r }
desc "Run all benchmarks."
task :benchmark, :count, :fields do |t, args|
args.with_defaults(:count => 1000, :fields => 20)
Rake::Task["benchmark_setup"].invoke
Rake::Task["benchmark_tire"].reenable
Rake::Task["benchmark_tire"].invoke
puts "====================================================================\n\n"
Rake::Task["benchmark_changeling"].reenable
Rake::Task["benchmark_changeling"].invoke
end
RSpec::Core::RakeTask.new("spec") do |spec|
spec.pattern = "spec/**/*_spec.rb"
end
RSpec::Core::RakeTask.new('spec:progress') do |spec|
spec.rspec_opts = %w(--format progress)
spec.pattern = "spec/**/*_spec.rb"
end
task :default => :spec
# Helper methods
def generate_loglings(count, fields)
hashes = generate_logling_hashes(count, fields)
loglings = []
hashes.each { |hash| loglings << Changeling::Models::Logling.new(hash) }
loglings
end
def generate_logling_hashes(count, fields)
hashes = []
count.times do
hash = {}
hash['klass'] = "Object"
hash['oid'] = BSON::ObjectId.new.to_s
hash['modified_by'] = BSON::ObjectId.new.to_s
hash['modified_at'] = Time.now.to_s
hash['modifications'] = {}
fields.times do |time|
hash['modifications']["name_of_field_#{time}"] = ["value_of_field_before_#{time}", "value_of_field_after_#{time}"]
end
hash['modifications'] = hash['modifications'].to_json
hashes << hash
end
hashes
end