prestashop-automation-tool 0.4 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/pat +21 -3
- data/bin/pat-runner-invoice.rb +1 -1
- data/lib/prestashop-automation-tool/helper.rb +2 -2
- data/lib/prestashop-automation-tool.rb +24 -0
- metadata +1 -1
data/bin/pat
CHANGED
@@ -38,8 +38,11 @@ elsif ARGV[0] == 'init'
|
|
38
38
|
unless File.exists? 'tests-available'
|
39
39
|
`git clone #{conf.config[:tests_repository]} tests-available`
|
40
40
|
end
|
41
|
+
unless File.exists? 'tests-output'
|
42
|
+
Dir.mkdir 'tests-output'
|
43
|
+
end
|
41
44
|
elsif ARGV[0] == 'purge'
|
42
|
-
`rm -Rf pat.conf.json tests-enabled tests-available`
|
45
|
+
`rm -Rf pat.conf.json tests-enabled tests-available tests-output`
|
43
46
|
elsif ARGV[0] == 'install'
|
44
47
|
withConfig do |conf|
|
45
48
|
ps = PrestaShopAutomation::PrestaShop.new(conf[:shop])
|
@@ -74,14 +77,29 @@ elsif ARGV[0] == 'test'
|
|
74
77
|
list.sort!
|
75
78
|
|
76
79
|
list.each do |file|
|
80
|
+
|
81
|
+
env = {
|
82
|
+
'PAT_NO_RESTORE' => (options[:no_restore] ? '1' : '0'),
|
83
|
+
'PAT_OUTPUT_PREFIX' => 'tests-output/' + File.basename(file, File.extname(file))
|
84
|
+
}
|
85
|
+
|
77
86
|
ok = if file =~ /\.rb$/
|
78
87
|
puts "Running #{file}..."
|
79
|
-
system(
|
88
|
+
system(env, 'rspec', file)
|
80
89
|
elsif file =~ /\.json$/
|
81
90
|
puts "Running #{file}..."
|
82
91
|
data = JSON.parse File.read(file)
|
92
|
+
|
93
|
+
tempfile = nil
|
94
|
+
if base = data['spec']['extend']
|
95
|
+
baseData = JSON.parse File.read(File.join File.dirname(file), "#{base}.json")
|
96
|
+
data = PrestaShopAutomationTool.merge baseData, data
|
97
|
+
file = env['PAT_OUTPUT_PREFIX'] + '.json'
|
98
|
+
File.write file, JSON.pretty_generate(data)
|
99
|
+
end
|
100
|
+
|
83
101
|
runner = "pat-runner-#{data['spec']['runner']}.rb"
|
84
|
-
system({'PAT_SOURCE' => file
|
102
|
+
system(env.merge({'PAT_SOURCE' => file}), runner)
|
85
103
|
else
|
86
104
|
:not_runnable
|
87
105
|
end
|
data/bin/pat-runner-invoice.rb
CHANGED
@@ -105,6 +105,6 @@ scenario = JSON.parse File.read(ENV['PAT_SOURCE'])
|
|
105
105
|
|
106
106
|
describe 'Invoice test' do
|
107
107
|
it 'should work' do
|
108
|
-
test_invoice @shop, scenario, :dump_pdf_to => ENV['
|
108
|
+
test_invoice @shop, scenario, :dump_pdf_to => (ENV['PAT_OUTPUT_PREFIX'] + '.pdf')
|
109
109
|
end
|
110
110
|
end
|
@@ -7,13 +7,13 @@ RSpec.configure do |config|
|
|
7
7
|
config.before :all do
|
8
8
|
conf = JSON.parse(File.read('pat.conf.json'), :symbolize_names => true)
|
9
9
|
@shop = PrestaShopAutomation::PrestaShop.new conf[:shop]
|
10
|
-
unless ENV['
|
10
|
+
unless ENV['PAT_NO_RESTORE'] == '1'
|
11
11
|
dump = @shop.save
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
config.after :all do
|
16
|
-
unless ENV['
|
16
|
+
unless ENV['PAT_NO_RESTORE'] == '1'
|
17
17
|
@shop.restore dump
|
18
18
|
end
|
19
19
|
end
|
@@ -8,6 +8,30 @@ module PrestaShopAutomationTool
|
|
8
8
|
File.expand_path '../..', __FILE__
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.merge a, b
|
12
|
+
if a.is_a? Hash and b.is_a? Hash
|
13
|
+
merged = {}
|
14
|
+
|
15
|
+
a.each_pair do |ka, va|
|
16
|
+
if b.has_key? ka
|
17
|
+
merged[ka] = merge va, b[ka]
|
18
|
+
else
|
19
|
+
merged[ka] = va
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
b.each_pair do |kb, vb|
|
24
|
+
unless a.has_key? kb
|
25
|
+
merged[kb] = vb
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
return merged
|
30
|
+
else
|
31
|
+
return b
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
11
35
|
class ConfigurationParser
|
12
36
|
|
13
37
|
attr_reader :config
|