Top Level Namespace

Defined Under Namespace

Modules: HTMLReport, ParallelTests, Utilities Classes: CapybaraHtmlFormatter, CustomParallelHtmlFormatter, ParallelHtmlFormatter

Instance Method Summary collapse

Instance Method Details

#alphabetize_names(filename) ⇒ Object



5
6
7
# File 'lib/sim/support/rspec_util.rb', line 5

def alphabetize_names(filename)
  example.[:snapshot_count] + '-' + filename
end

#dealphabetize_names(filename) ⇒ Object



9
10
11
# File 'lib/sim/support/rspec_util.rb', line 9

def dealphabetize_names(filename)
  filename[4..filename.length]
end

#is_cucumberObject



1
2
3
# File 'lib/sim/support/sim_util.rb', line 1

def is_cucumber()
  respond_to? :After
end

#is_rspecObject



5
6
7
# File 'lib/sim/support/sim_util.rb', line 5

def is_rspec()
  RSpec.respond_to? :configure
end

#path_of_example_groups(example, desc) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sim/support/rspec_util.rb', line 49

def path_of_example_groups(example, desc)
  # metadata maintains example_group structure as nested example_groups from inner to outer
  # so we build array from inner to outer and then reverse it
  groups = []
  groups << desc
  current_group = example.[:example_group]
  while (!current_group.nil?) do
    groups << current_group[:description]
    current_group = current_group[:example_group]
  end

  groups << $base_screenshot_dir

  groups.reverse.join('/')
  
end

#path_to_screenshot(example) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/sim/support/rspec_util.rb', line 40

def path_to_screenshot(example)
  if example.[:screenshot_path]
    return example.[:screenshot_path]
  end
  desc = example.[:description_args].empty? ? example.[:id] : example.[:description_args].first.gsub('"',"'").gsub('|', '')
  example.[:screenshot_path] = path_of_example_groups(example, desc)
  example.[:screenshot_path]
end

#path_to_tmp(example) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/sim/support/rspec_util.rb', line 32

def path_to_tmp(example)
  if example.[:tmp_path]
    return example.[:tmp_path]
  end
  example.[:tmp_path] = path_to_screenshot(example)
  example.[:tmp_path]
end

#save_html_to_file(example, filename) ⇒ Object



24
25
26
# File 'lib/sim/support/rspec_util.rb', line 24

def save_html_to_file(example, filename)
  File.open("#{path_to_tmp(example)}/#{filename}.html", 'w') {|f| f.write(page.html) }
end

#save_screenshot_to_file(example, filename) ⇒ Object



28
29
30
# File 'lib/sim/support/rspec_util.rb', line 28

def save_screenshot_to_file(example, filename)
  page.save_screenshot("#{path_to_tmp(example)}/#{filename}.png")
end

#save_snapshot(example, filename) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/sim/support/rspec_util.rb', line 13

def save_snapshot(example,filename)

    ordered_filename = alphabetize_names(filename)
    save_html_to_file(example, ordered_filename)

    if example.[:js]
      save_screenshot_to_file(example, ordered_filename)
    end
    example.[:snapshot_count] = (example.[:snapshot_count].to_i + 1).to_s.rjust($filename_padding, '0')
end

#set_app_addressObject



9
10
11
12
13
14
15
# File 'lib/sim/remote.rb', line 9

def set_app_address()
    require 'system/getifaddrs'
    ip = $webserver_ip != nil ? $webserver_ip : System.get_ifaddrs.find{ |socket| socket[1][:inet_addr] != "127.0.0.1" } [1][:inet_addr]
    port = $webserver_port != nil ? $webserver_port : Capybara.current_session.server.port
    Capybara.app_host = "http://#{ip}:#{port}"
    puts "Registering http://#{ip}:#{port} as root server"
end