-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path-f
76 lines (64 loc) · 2.35 KB
/
-f
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
75
require 'rubygems'
require 'colorize'
require 'fileutils'
require 'ruby-debug'
require 'chronic'
require 'rspec'
require 'nokogiri'
require 'open-uri'
require 'openssl'
require 'active_support/inflector'
require 'test/unit/assertions'
require 'features/support/read_config'
require 'features/support/create_screenshot_folder'
require 'features/support/screenshot'
require 'features/support/check_missing_translations'
require 'cucumber/formatter/unicode'
require 'features/support/select_browser'
require 'vendor/plugins/cucumber_fm/app/models/watircuke'
include Test::Unit::Assertions
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
begin
#read the config.yml file found in config/config.yml
##--------------------------------------------------
read_config
BROWSER = ENV['BROWSER'].nil? ?
(Watircuke.is_windows? ? select_browser("ie") : select_browser("firefox")) :
select_browser(ENV['BROWSER'])
CHECK_TRANSLATIONS = @check_translation
TRANSLATION_TAG = @translation_tag
LANGUAGES = @fixtures if ENV['DEF_TEST']
##-------------------------------------------------
folder_prefix = "public/test_results"
if Dir["#{folder_prefix}/*"].select{|x| File.directory?(x)}.map{|x| [File.ctime(x), x]}.sort_by{|x| x.first}.last
screenshot_path = (Dir["#{folder_prefix}/*"].select{|x| File.directory?(x)}.map{|x| [File.ctime(x), x]}.sort_by{|x| x.first}.last.last.inspect + "/screenshots/").gsub!("\"","")
else
screenshot_path = "#{folder_prefix}/screenshots/"
end
browser = BROWSER
# "before all"
Before do
@table = {}
@screenshot_path = screenshot_path
@browser = browser
LANGUAGES.each { |table| @table.merge! YAML.load_file("features/fixtures/#{table}.yml") } if ENV['DEF_TEST']
@table.merge! YAML.load_file("config/config.yml")
@environment = "http://"
@time = Time.now
end
#after each scenario: checking for missing translation on page, count scenario time, makes screenshot if failed
After do |scenario|
check_missing_translations if CHECK_TRANSLATIONS
create_screenshot(ENV['DEF_TEST'] || ENV['CMD']) if scenario.failed?
scenario_time(@time)
end
# after each step which is called '@new_feature' make a screenshot
AfterStep('@new_feature') do
create_screenshot(ENV['DEF_TEST'] || ENV['CMD'])
end
at_exit do
browser.close
end
rescue Exception => ex
puts "#{ex}".red
end