cuculungwa 0.0.78 → 0.0.79

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef09045998794ccfb48c414d3e799e8017e09f8d
4
- data.tar.gz: eff736ccfaff8127835f2e9fa68a8ef6b17b27e0
3
+ metadata.gz: 829d80f72080770a78be83b0055111b17ac79835
4
+ data.tar.gz: 49a049fba5d073d9b73afc6a857508e9bcb424e8
5
5
  SHA512:
6
- metadata.gz: 6553a91f407ff911506cd1a688387b9afb6f77cacc5478cc9a53fcb7de406eb025b87cbbee7a2ca993583940ac69ec147f3dc9a4af82ace80a0232dbe3aefb68
7
- data.tar.gz: 8d63426c47ff3327026d641b431cd442bb28b8c1be6c3fdbfb3d249239162dd1d8b718ba4aa3bc29fb60e87d3f0ba35081e94cdbbf44afd820f13a93274c96ce
6
+ metadata.gz: dfdbe33217c430f03dd84298f4ad9808efb49c48c309a315d44ec99f49c65a0496cf5a996f1202a325a175b2aecc24715eaf4c503e4818caf38db4e523788b53
7
+ data.tar.gz: 89bf17fc3dc325040730d559e074b4aac0044ca08b08c735e0d6dd25a9db8df856749015a675fa9f99095bc1959d05783a77dd850dafd4568a6e4f7cf6f29b86
@@ -10,15 +10,12 @@ require 'capybara-screenshot/cucumber'
10
10
  require 'rspec/expectations'
11
11
  require 'site_prism'
12
12
  require 'yaml'
13
-
14
13
  require 'cuculungwa/generators'
15
14
  require 'cuculungwa/utils'
16
15
  require 'cuculungwa/formatters'
17
16
 
18
- config = YAML::load(File.open('config/config.yml'))
19
- if ENV['CONFIG']
20
- config.merge!(YAML::load(File.open(ENV['CONFIG'])))
21
- end
17
+ config = YAML.load(File.open('config/config.yml'))
18
+ config.merge!(YAML.load(File.open(ENV['CONFIG']))) if ENV['CONFIG']
22
19
  config['project']['default_host'] = config['project'][ENV['PROJECT'] || 'development']
23
20
  config['framework']['i18n']['locale'] = ENV['LOCALE'] || config['framework']['i18n']['locale']
24
21
 
@@ -26,44 +23,44 @@ I18n.enforce_available_locales = false
26
23
  I18n.locale = config['framework']['i18n']['locale'].to_sym
27
24
  I18n.load_path = Dir[config['framework']['i18n']['load_path']]
28
25
 
29
- if config['capybara']['browser']=='phantomjs'
26
+ if config['capybara']['browser'] == 'phantomjs'
30
27
  Capybara.register_driver :poltergeist do |app|
31
28
  Capybara::Poltergeist::Driver.new app,
32
- phantomjs_options: config['capybara']['phantomjs_specific']['options'],
33
- window_size: config['capybara']['phantomjs_specific']['window_size']
29
+ phantomjs_options: config['capybara']['phantomjs_specific']['options'],
30
+ window_size: config['capybara']['phantomjs_specific']['window_size']
34
31
  end
35
32
  Capybara.default_driver = :poltergeist
36
- elsif config['capybara']['browser']=='capybara-webkit'
33
+ elsif config['capybara']['browser'] == 'capybara-webkit'
37
34
  headless = Headless.new
38
35
  headless.start
39
36
  Capybara.default_driver = :webkit
40
- elsif config['capybara']['browser']=='seleniumRC'
37
+ elsif config['capybara']['browser'] == 'seleniumRC'
41
38
  require 'selenium-webdriver'
42
39
  client = Selenium::WebDriver::Remote::Http::Default.new
43
- client.timeout = ENV['CLIENT_TIMEOUT'] ? ENV['CLIENT_TIMEOUT'].to_i : 60
40
+ client.timeout = ENV['CLIENT_TIMEOUT'] ? ENV['CLIENT_TIMEOUT'].to_i : 60
44
41
  capabilities = Selenium::WebDriver::Remote::Capabilities.new
45
42
  capabilities[:introduce_flakiness_by_ignoring_security_domains] = true
46
43
  capabilities[:javascript_enabled] = true
47
44
  capabilities[:css_selectors_enabled] = true
48
45
  capabilities[:ignore_protected_mode_settings] = true
49
46
  Capybara.register_driver :selenium do |app|
50
- Capybara::Selenium::Driver.new(app, :browser => :remote, :url => config['capybara']['seleniumRC_specific']['hub'], :http_client => client, :desired_capabilities => capabilities)
47
+ Capybara::Selenium::Driver.new(app, browser: :remote, url: config['capybara']['seleniumRC_specific']['hub'], http_client: client, desired_capabilities: capabilities)
51
48
  end
52
49
  Capybara.default_driver = :selenium
53
50
  else
54
51
  Capybara.register_driver :selenium do |app|
55
- Capybara::Selenium::Driver.new(app, :browser => config['capybara']['browser'].to_sym)
52
+ Capybara::Selenium::Driver.new(app, browser: config['capybara']['browser'].to_sym)
56
53
  end
57
54
  Capybara.default_driver = :selenium
58
55
  end
59
56
 
60
57
  Capybara.save_and_open_page_path = config['capybara']['save_and_open_page_path']
61
58
  Capybara.app_host = config['project']['default_host']['front']
62
- Capybara.default_wait_time = config['capybara']['default_wait_time']
59
+ Capybara.default_max_wait_time = config['capybara']['default_wait_time']
63
60
 
64
- #Quick finish after first fail
61
+ # Quick finish after first fail
65
62
  After do |scenario|
66
- Cucumber.wants_to_quit = ENV['STOP_ON_FAIL']=='true' && scenario.failed?
63
+ Cucumber.wants_to_quit = ENV['STOP_ON_FAIL'] == 'true' && scenario.failed?
67
64
  end
68
65
 
69
66
  World(Capybara)
@@ -79,9 +76,9 @@ AfterConfiguration do |configuration|
79
76
  potential_feature_files = with_default_features_path(paths).map do |path|
80
77
  path = path.chomp('/')
81
78
  if File.directory?(path)
82
- Dir["#{path}" + config['framework']['features_regexp']].sort
83
- elsif path[0..0] == '@' and
84
- File.file?(path[1..-1])
79
+ Dir[path.to_s + config['framework']['features_regexp']].sort
80
+ elsif path[0..0] == '@' &&
81
+ File.file?(path[1..-1])
85
82
  IO.read(path[1..-1]).split
86
83
  else
87
84
  path
@@ -6,17 +6,17 @@ module Formatters
6
6
  splits = number_str.split('.')
7
7
 
8
8
  unless splits.length == 2
9
- raise Exception.new("#{number_str} doesn't contain dot.")
9
+ fail Exception.new("#{number_str} doesn't contain dot.")
10
10
  end
11
11
 
12
12
  whole_part = splits[0]
13
13
  fractional_part = splits[1]
14
14
  separator = locale_spec[:separator]
15
15
 
16
- unless fractional_part.empty?
17
- delimiter = locale_spec[:delimiter]
18
- else
19
- delimiter = ''
16
+ delimiter = unless fractional_part.empty?
17
+ locale_spec[:delimiter]
18
+ else
19
+ ''
20
20
  end
21
21
 
22
22
  negative = false
@@ -29,11 +29,9 @@ module Formatters
29
29
  for i in whole_part.length.downto(1)
30
30
  j = whole_part.length - i
31
31
 
32
- if j % 3 == 0 and j > 0
33
- whole_part_result = separator + whole_part_result
34
- end
32
+ whole_part_result = separator + whole_part_result if j % 3 == 0 && j > 0
35
33
 
36
- whole_part_result = whole_part[i-1] + whole_part_result
34
+ whole_part_result = whole_part[i - 1] + whole_part_result
37
35
  end
38
36
 
39
37
  unless negative
@@ -45,20 +43,20 @@ module Formatters
45
43
 
46
44
  def short_iban(iban)
47
45
  if iban.length >= 15
48
- first_part = iban[0..1]+" "+iban[2..3]+" "+iban[4..7]
49
- middle_part=" ... "
50
- last_part=iban[-4..-1]
51
- iban_number=first_part+middle_part + last_part
46
+ first_part = iban[0..1] + ' ' + iban[2..3] + ' ' + iban[4..7]
47
+ middle_part = ' ... '
48
+ last_part = iban[-4..-1]
49
+ iban_number = first_part + middle_part + last_part
52
50
  else
53
- iban_number = add_space = iban[0..1]+" "+iban[2..iban.length]
51
+ iban_number = add_space = iban[0..1] + ' ' + iban[2..iban.length]
54
52
  end
55
53
  return iban_number
56
54
  end
57
55
 
58
56
  def pl_iban_formatter(number)
59
- number = number.gsub(/\s+/, "").gsub('PL','')
57
+ number = number.gsub(/\s+/, '').gsub('PL', '')
60
58
  number = number[0..1] + ' ' + number[2..-1].gsub(/(.{4})/, '\1 ').strip
61
59
  return number
62
60
  end
63
61
  end
64
- World(Formatters)
62
+ World(Formatters)
@@ -1,7 +1,7 @@
1
1
  module GenerateData
2
2
  def get_unique_email(prefix = 'email', domain = 'test.com')
3
3
  # returns unique test email
4
- "#{prefix}-#{(Time.now.to_f * 1000000).to_i}@#{domain}"
4
+ "#{prefix}-#{(Time.now.to_f * 1_000_000).to_i}@#{domain}"
5
5
  end
6
6
 
7
7
  def get_test_password
@@ -10,9 +10,8 @@ module GenerateData
10
10
  end
11
11
 
12
12
  def get_random_currency_symbol
13
- currencies = [
14
- 'PLN', 'EUR', 'USD', 'GBP', 'CZK'
15
- ]
13
+ currencies = %w(
14
+ PLN EUR USD GBP CZK)
16
15
  currencies.sample
17
16
  end
18
17
 
@@ -22,18 +21,18 @@ module GenerateData
22
21
  # returns polish registration number of the population
23
22
  if data_type.eql? 'positive_data_set'
24
23
  weights = Array[1, 3, 7, 9, 1, 3, 7, 9, 1, 3]
25
- year = rand()*100
26
- month = rand()*12+1
27
- day = rand()*28+1
28
- evidence_number = rand()*999
29
- sex=rand()*9
30
- pesel="%02d%02d%02d%03d%d"%[year,month,day,evidence_number,sex]
24
+ year = rand * 100
25
+ month = rand * 12 + 1
26
+ day = rand * 28 + 1
27
+ evidence_number = rand * 999
28
+ sex = rand * 9
29
+ pesel = '%02d%02d%02d%03d%d' % [year, month, day, evidence_number, sex]
31
30
  temp_cs = 0
32
- pesel_elem = pesel.each_char.map {|c| c.to_i}
33
- for i in 0..weights.length-1
34
- temp_cs +=weights[i]*pesel_elem[i]
31
+ pesel_elem = pesel.each_char.map(&:to_i)
32
+ for i in 0..weights.length - 1
33
+ temp_cs += weights[i] * pesel_elem[i]
35
34
  end
36
- control_sum = (10-(temp_cs%10))%10
35
+ control_sum = (10 - (temp_cs % 10)) % 10
37
36
  return pesel + control_sum.to_s
38
37
  elsif data_type.eql? 'negative_data_set'
39
38
  return '00000000000'
@@ -46,12 +45,12 @@ module GenerateData
46
45
  # returns polish business registration number
47
46
  if data_type.eql? 'positive_data_set'
48
47
  weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]
49
- code = rand(998-101) + 101
50
- number = rand(1000000)
48
+ code = rand(998 - 101) + 101
49
+ number = rand(1_000_000)
51
50
  nip = code.to_s + number.to_s.rjust(6, '0')
52
51
 
53
- c = nip.split(//).map! {|x| x.to_i}
54
- sum = c.zip(weights).map! {|x| x[0]*x[1]}.reduce(:+) % 11
52
+ c = nip.split(//).map!(&:to_i)
53
+ sum = c.zip(weights).map! { |x| x[0] * x[1] }.reduce(:+) % 11
55
54
 
56
55
  sum = sum == 10 ? 0 : sum
57
56
  return nip + sum.to_s
@@ -68,19 +67,15 @@ module GenerateData
68
67
  # bank_prefix: if you want specify bank prefix (minimum 4 and maximum 8 digits)
69
68
  # polish_format: if you want add spaces for readability
70
69
  bank_prefix ||= sprintf('%08d', rand(10**8))
71
- bank_prefix = bank_prefix.to_s.gsub(/\s+/, "")
70
+ bank_prefix = bank_prefix.to_s.gsub(/\s+/, '')
72
71
 
73
- if bank_prefix.length < 4
74
- raise 'Bank prefix error!'
75
- end
72
+ fail 'Bank prefix error!' if bank_prefix.length < 4
76
73
 
77
- if bank_prefix.length == 4
78
- bank_prefix << '0001'
79
- end
74
+ bank_prefix << '0001' if bank_prefix.length == 4
80
75
 
81
- if (data_type.eql? 'positive_set')
76
+ if data_type.eql? 'positive_set'
82
77
  account_no = sprintf('%016d', rand(10**16))
83
- num = bank_prefix + account_no + "252100"
78
+ num = bank_prefix + account_no + '252100'
84
79
  control_digit = sprintf('%02d', 98 - (num.to_i % 97))
85
80
  number = control_digit + bank_prefix + account_no
86
81
  else
@@ -94,4 +89,4 @@ module GenerateData
94
89
  end
95
90
  end
96
91
  end
97
- World(GenerateData)
92
+ World(GenerateData)
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  def click(element)
3
- if @app.config['capybara']['browser']=='phantomjs'
3
+ if @app.config['capybara']['browser'] == 'phantomjs'
4
4
  element.trigger('click')
5
5
  else
6
6
  element.click
@@ -12,36 +12,33 @@ module Utils
12
12
  end
13
13
 
14
14
  def take_screenshot
15
- save_screenshot(@app.config['capybara']['save_and_open_page_path'] + "/manual_screenshots/#{Time.now.to_i}.png", :full => true)
16
15
  end
17
16
 
18
17
  def wait_for_expected_result(timespan = @app.config['capybara']['default_wait_time'], exception_type = RSpec::Expectations::ExpectationNotMetError)
19
18
  # Default setting: get default wait time from config.yml
20
19
  _then = Time.now
21
- while true
20
+ loop do
22
21
  begin
23
22
  yield
24
23
  break
25
24
  rescue exception_type => e
26
25
  # Expectations were not met, check if we timed out, otherwise try one more time after 10ms
27
- if Time.now > _then + timespan then
28
- puts "Timeout."
26
+ if Time.now > _then + timespan
27
+ puts 'Timeout.'
29
28
  raise e
30
29
  end
31
30
  sleep 0.01
32
31
  end
33
32
  end
34
- #for debug purpose
35
- #puts "Waiting for expected result took #{Time.now - _then}s."
33
+ # for debug purpose
34
+ # puts "Waiting for expected result took #{Time.now - _then}s."
36
35
  end
37
36
 
38
37
  def I18n_first(text)
39
- begin
40
- text = I18n.t(text, :raise => I18n::MissingTranslationData)
41
- return text
42
- rescue I18n::MissingTranslationData
43
- return text
44
- end
38
+ text = I18n.t(text, raise: I18n::MissingTranslationData)
39
+ return text
40
+ rescue I18n::MissingTranslationData
41
+ return text
45
42
  end
46
43
 
47
44
  def wait_for_ajax
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuculungwa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.78
4
+ version: 0.0.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kaftanski
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-01-27 00:00:00.000000000 Z
14
+ date: 2016-02-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: aruba
@@ -271,3 +271,4 @@ signing_key:
271
271
  specification_version: 4
272
272
  summary: Cuculungwa testing framework
273
273
  test_files: []
274
+ has_rdoc: