spec/fabricators/manifest_fabricator.rb in polytrix-0.1.2 vs spec/fabricators/manifest_fabricator.rb in polytrix-0.1.3
- old
+ new
@@ -1,14 +1,8 @@
require 'hashie/mash'
# Fabricates test manifests (.polytrix.yml files)
-LANGUAGES = %w(java ruby python nodejs c# golang php)
-SAMPLE_NAMES = [
- 'hello world',
- 'quine',
- 'my_kata'
-]
Fabricator(:manifest, from: Polytrix::Manifest) do
initialize_with { @_klass.new to_hash } # Hash based initialization
transient suite_count: 3
transient samples_per_suite: 3
@@ -22,14 +16,13 @@
}
end
suites do |attr|
suite_count = attr[:suite_count]
if suite_count
- suites = attr[:suite_count].times.reduce({}) do |h, i|
+ suites = attr[:suite_count].times.each_with_object({}) do |i, h|
name = LANGUAGES[i] ||= "suite_#{i}"
h[name] = Fabricate(:suite, name: name, sample_count: attr[:samples_per_suite])
- h
end
suites
else
nil
end
@@ -42,10 +35,10 @@
transient sample_count: 3
samples do |attr|
sample_count = attr[:sample_count]
if sample_count
attr[:sample_count].times.map do |i|
- SAMPLE_NAMES[i] ||= "sample_#{i}"
+ SCENARIO_NAMES[i] ||= "sample_#{i}"
end
else
nil
end
end