cuculungwa 0.0.66 → 0.0.70

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20829731cea8264a1a5c80a9598f90ddc34bd3a5
4
- data.tar.gz: a4b83c54f362129a640539fd19f9d8c0ced8d407
3
+ metadata.gz: 5ef31328c71a6f8e202ad29d63a6df61a976c4d2
4
+ data.tar.gz: 193b2af612793570373e5ed64b0157abfd8f23e2
5
5
  SHA512:
6
- metadata.gz: f67b6ffa5aca577d369fdc81d90194960ffb145a5c738b7874450a320baf92bbeee713aff050b0066347d5cd5e1cf5df18997ee19f4fd5f1c17996864589f7e4
7
- data.tar.gz: d486596f8434a660a0dafe47a5c1dff9dbe8455e9f6220d6dc74e068add52219f5a1ec385b8b1350ee80222892736dba54ed27146f9b6273af27139e980a2b21
6
+ metadata.gz: 491fd78a49611a0e6ea55200bb63bc8f9a7891c1785d53d86456581ef026dddc3a527aa20ee0faebd5b1b79e2a56f05c90c530a03c5a0d12c4076f048af4188a
7
+ data.tar.gz: fef4c75c5d1d32996225bd69d6357a4b7bf5fcdc1cc37994514df9c1b0b6dc2b74db9d76a9ada1b76d26d76bd8b2d62b7c661da4e5e22969932e82d18624f5db
@@ -11,6 +11,10 @@ require 'rspec/expectations'
11
11
  require 'site_prism'
12
12
  require 'yaml'
13
13
 
14
+ require 'cuculungwa/generators'
15
+ require 'cuculungwa/utils'
16
+ require 'cuculungwa/formatters'
17
+
14
18
  config = YAML::load(File.open('config/config.yml'))
15
19
  if ENV['CONFIG']
16
20
  config.merge!(YAML::load(File.open(ENV['CONFIG'])))
@@ -87,188 +91,3 @@ AfterConfiguration do |configuration|
87
91
  potential_feature_files.shuffle
88
92
  end
89
93
  end
90
-
91
- module GenerateData
92
- def pesel_generator(data_type)
93
- if (data_type.eql? 'positive_data_set')
94
- weights = Array[1, 3, 7, 9, 1, 3, 7, 9, 1, 3]
95
- year = rand()*100
96
- month = rand()*12+1
97
- day = rand()*28+1
98
- evidence_number = rand()*999
99
- sex=rand()*9
100
- pesel="%02d%02d%02d%03d%d"%[year,month,day,evidence_number,sex]
101
- temp_cs = 0
102
- pesel_elem = pesel.each_char.map {|c| c.to_i}
103
- for i in 0..weights.length-1
104
- temp_cs +=weights[i]*pesel_elem[i]
105
- end
106
- control_sum = (10-(temp_cs%10))%10
107
- return pesel + control_sum.to_s
108
- elsif (data_type.eql? 'negative_data_set')
109
- return "00000000000"
110
- else
111
- return ""
112
- end
113
- end
114
-
115
- def nip_generator(data_type)
116
- if (data_type.eql? 'positive_data_set')
117
- weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]
118
- code = rand(998-101) + 101
119
- number = rand(1000000)
120
- nip = code.to_s + number.to_s.rjust(6, '0')
121
-
122
- c = nip.split(//).map! {|x| x.to_i}
123
- sum = c.zip(weights).map! {|x| x[0]*x[1]}.reduce(:+) % 11
124
-
125
- sum = sum == 10 ? 0 : sum
126
- return nip + sum.to_s
127
- elsif (data_type.eql? 'negative_data_set')
128
- return "000"
129
- else
130
- return ""
131
- end
132
- end
133
-
134
- def pl_iban_formatter(number)
135
- number = number.gsub(/\s+/, "").gsub('PL','')
136
- number = number[0..1] + ' ' + number[2..-1].gsub(/(.{4})/, '\1 ').strip
137
- return number
138
- end
139
-
140
- def pl_iban_generator(data_type = 'positive_set', bank_prefix = nil, polish_format = false)
141
- # data_type: if you want correct iban use positive_set, anything else will return 00111122223333444455556666
142
- # bank_prefix: if you want specify bank prefix (minimum 4 and maximum 8 digits)
143
- # polish_format: if you want add spaces for readability
144
- bank_prefix ||= sprintf('%08d', rand(10**8))
145
- bank_prefix = bank_prefix.to_s.gsub(/\s+/, "")
146
-
147
- if bank_prefix.length < 4
148
- raise 'Bank prefix error!'
149
- end
150
-
151
- if bank_prefix.length == 4
152
- bank_prefix << '0001'
153
- end
154
-
155
- if (data_type.eql? 'positive_set')
156
- account_no = sprintf('%016d', rand(10**16))
157
- num = bank_prefix + account_no + "252100"
158
- control_digit = sprintf('%02d', 98 - (num.to_i % 97))
159
- number = control_digit + bank_prefix + account_no
160
- else
161
- number = '00111122223333444455556666'
162
- end
163
-
164
- if polish_format
165
- pl_iban_formatter(number)
166
- else
167
- number
168
- end
169
- end
170
- end
171
- World(GenerateData)
172
-
173
- module Utils
174
- def click(element)
175
- if (@app.config['capybara']['browser']=='phantomjs')
176
- element.trigger('click')
177
- else
178
- element.click
179
- end
180
- end
181
-
182
- def set_app(app)
183
- Capybara.app_host = @app.config['project']['default_host'][app]
184
- end
185
-
186
- def take_screenshot
187
- save_screenshot(@app.config['capybara']['save_and_open_page_path'] + "/manual_screenshots/#{Time.now.to_i}.png", :full => true)
188
- end
189
-
190
- def short_iban(iban)
191
- if iban.length >= 15
192
- first_part = iban[0..1]+" "+iban[2..3]+" "+iban[4..7]
193
- middle_part=" ... "
194
- last_part=iban[-4..-1]
195
- iban_number=first_part+middle_part + last_part
196
- else
197
- iban_number = add_space = iban[0..1]+" "+iban[2..iban.length]
198
- end
199
- return iban_number
200
- end
201
-
202
- def wait_for_expected_result(timespan = @app.config['capybara']['default_wait_time'], exception_type = RSpec::Expectations::ExpectationNotMetError)
203
- # Default setting: get default wait time from config.yml
204
- _then = Time.now
205
- while true
206
- begin
207
- yield
208
- break
209
- rescue exception_type => e
210
- # Expectations were not met, check if we timed out, otherwise try one more time
211
- if Time.now > _then + timespan then
212
- puts "Timeout."
213
- raise e
214
- end
215
- end
216
- end
217
- #for debug purpose
218
- #puts "Waiting for expected result took #{Time.now - _then}s."
219
- end
220
-
221
- def I18n_first(text)
222
- begin
223
- text = I18n.t(text, :raise => I18n::MissingTranslationData)
224
- return text
225
- rescue I18n::MissingTranslationData
226
- return text
227
- end
228
- end
229
-
230
- # Function creates localalized version of a number represented by a string based on locale_spec
231
- # eg. 123456.55 -> 123,45.55 (with locale_spec = {:separator : ',', :delimiter '.'}
232
- # 5123456.55 -> 5 123 45,55 (with locale_spec = {:separator : ' ', :delimiter '.'}
233
- def i18n_number(number_str, locale_spec)
234
- splits = number_str.split('.')
235
-
236
- unless splits.length == 2
237
- raise Exception.new("#{number_str} doesn't contain dot.")
238
- end
239
-
240
- whole_part = splits[0]
241
- fractional_part = splits[1]
242
- separator = locale_spec[:separator]
243
-
244
- unless fractional_part.empty?
245
- delimiter = locale_spec[:delimiter]
246
- else
247
- delimiter = ''
248
- end
249
-
250
- negative = false
251
- if whole_part[0] == '-'
252
- negative = true
253
- whole_part = whole_part[1..-1]
254
- end
255
-
256
- whole_part_result = ''
257
- for i in whole_part.length.downto(1)
258
- j = whole_part.length - i
259
-
260
- if j % 3 == 0 and j > 0
261
- whole_part_result = separator + whole_part_result
262
- end
263
-
264
- whole_part_result = whole_part[i-1] + whole_part_result
265
- end
266
-
267
- unless negative
268
- return whole_part_result + delimiter + fractional_part
269
- else
270
- return '-' + whole_part_result + delimiter + fractional_part
271
- end
272
- end
273
- end
274
- World(Utils)
@@ -0,0 +1,64 @@
1
+ module Formatters
2
+ # Function creates localized version of a number represented by a string based on locale_spec
3
+ # eg. 123456.55 -> 123,45.55 (with locale_spec = {:separator : ',', :delimiter '.'}
4
+ # 5123456.55 -> 5 123 45,55 (with locale_spec = {:separator : ' ', :delimiter '.'}
5
+ def i18n_number(number_str, locale_spec)
6
+ splits = number_str.split('.')
7
+
8
+ unless splits.length == 2
9
+ raise Exception.new("#{number_str} doesn't contain dot.")
10
+ end
11
+
12
+ whole_part = splits[0]
13
+ fractional_part = splits[1]
14
+ separator = locale_spec[:separator]
15
+
16
+ unless fractional_part.empty?
17
+ delimiter = locale_spec[:delimiter]
18
+ else
19
+ delimiter = ''
20
+ end
21
+
22
+ negative = false
23
+ if whole_part[0] == '-'
24
+ negative = true
25
+ whole_part = whole_part[1..-1]
26
+ end
27
+
28
+ whole_part_result = ''
29
+ for i in whole_part.length.downto(1)
30
+ j = whole_part.length - i
31
+
32
+ if j % 3 == 0 and j > 0
33
+ whole_part_result = separator + whole_part_result
34
+ end
35
+
36
+ whole_part_result = whole_part[i-1] + whole_part_result
37
+ end
38
+
39
+ unless negative
40
+ return whole_part_result + delimiter + fractional_part
41
+ else
42
+ return '-' + whole_part_result + delimiter + fractional_part
43
+ end
44
+ end
45
+
46
+ def short_iban(iban)
47
+ 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
52
+ else
53
+ iban_number = add_space = iban[0..1]+" "+iban[2..iban.length]
54
+ end
55
+ return iban_number
56
+ end
57
+
58
+ def pl_iban_formatter(number)
59
+ number = number.gsub(/\s+/, "").gsub('PL','')
60
+ number = number[0..1] + ' ' + number[2..-1].gsub(/(.{4})/, '\1 ').strip
61
+ return number
62
+ end
63
+ end
64
+ World(Formatters)
@@ -0,0 +1,97 @@
1
+ module GenerateData
2
+ def get_unique_email(prefix = 'email', domain = 'test.com')
3
+ # returns unique test email
4
+ "#{prefix}-#{(Time.now.to_f * 1000000).to_i}@#{domain}"
5
+ end
6
+
7
+ def get_test_password
8
+ # returns standard test password
9
+ 'q1w2e3r4'
10
+ end
11
+
12
+ def get_random_currency_symbol
13
+ currencies = [
14
+ 'PLN', 'EUR', 'USD', 'GBP', 'CZK'
15
+ ]
16
+ currencies.sample
17
+ end
18
+
19
+ # generators below perform typical polish data
20
+
21
+ def pesel_generator(data_type)
22
+ # returns polish registration number of the population
23
+ if data_type.eql? 'positive_data_set'
24
+ 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]
31
+ 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]
35
+ end
36
+ control_sum = (10-(temp_cs%10))%10
37
+ return pesel + control_sum.to_s
38
+ elsif data_type.eql? 'negative_data_set'
39
+ return '00000000000'
40
+ else
41
+ return ''
42
+ end
43
+ end
44
+
45
+ def nip_generator(data_type)
46
+ # returns polish business registration number
47
+ if data_type.eql? 'positive_data_set'
48
+ weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]
49
+ code = rand(998-101) + 101
50
+ number = rand(1000000)
51
+ nip = code.to_s + number.to_s.rjust(6, '0')
52
+
53
+ c = nip.split(//).map! {|x| x.to_i}
54
+ sum = c.zip(weights).map! {|x| x[0]*x[1]}.reduce(:+) % 11
55
+
56
+ sum = sum == 10 ? 0 : sum
57
+ return nip + sum.to_s
58
+ elsif data_type.eql? 'negative_data_set'
59
+ return '000'
60
+ else
61
+ return ''
62
+ end
63
+ end
64
+
65
+ def pl_iban_generator(data_type = 'positive_set', bank_prefix = nil, polish_format = false)
66
+ # return polish fashioned iban bank account number
67
+ # data_type: if you want correct iban use positive_set, anything else will return 00111122223333444455556666
68
+ # bank_prefix: if you want specify bank prefix (minimum 4 and maximum 8 digits)
69
+ # polish_format: if you want add spaces for readability
70
+ bank_prefix ||= sprintf('%08d', rand(10**8))
71
+ bank_prefix = bank_prefix.to_s.gsub(/\s+/, "")
72
+
73
+ if bank_prefix.length < 4
74
+ raise 'Bank prefix error!'
75
+ end
76
+
77
+ if bank_prefix.length == 4
78
+ bank_prefix << '0001'
79
+ end
80
+
81
+ if (data_type.eql? 'positive_set')
82
+ account_no = sprintf('%016d', rand(10**16))
83
+ num = bank_prefix + account_no + "252100"
84
+ control_digit = sprintf('%02d', 98 - (num.to_i % 97))
85
+ number = control_digit + bank_prefix + account_no
86
+ else
87
+ number = '00111122223333444455556666'
88
+ end
89
+
90
+ if polish_format
91
+ pl_iban_formatter(number)
92
+ else
93
+ number
94
+ end
95
+ end
96
+ end
97
+ World(GenerateData)
@@ -0,0 +1,59 @@
1
+ module Utils
2
+ def click(element)
3
+ if @app.config['capybara']['browser']=='phantomjs'
4
+ element.trigger('click')
5
+ else
6
+ element.click
7
+ end
8
+ end
9
+
10
+ def set_app(app)
11
+ Capybara.app_host = @app.config['project']['default_host'][app]
12
+ end
13
+
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
+ end
17
+
18
+ def wait_for_expected_result(timespan = @app.config['capybara']['default_wait_time'], exception_type = RSpec::Expectations::ExpectationNotMetError)
19
+ # Default setting: get default wait time from config.yml
20
+ _then = Time.now
21
+ while true
22
+ begin
23
+ yield
24
+ break
25
+ rescue exception_type => e
26
+ # 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."
29
+ raise e
30
+ end
31
+ sleep 0.01
32
+ end
33
+ end
34
+ #for debug purpose
35
+ #puts "Waiting for expected result took #{Time.now - _then}s."
36
+ end
37
+
38
+ 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
45
+ end
46
+
47
+ def wait_for_ajax
48
+ sleep 1
49
+ Timeout.timeout(Capybara.default_wait_time, Timeout::Error) do
50
+ loop until finished_all_ajax_requests?
51
+ end
52
+ end
53
+
54
+ def finished_all_ajax_requests?
55
+ page.evaluate_script('jQuery.active').zero?
56
+ end
57
+ end
58
+
59
+ World(Utils)
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuculungwa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.66
4
+ version: 0.0.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kaftanski
8
- - Jakub Kubiak
9
8
  - Tomasz Tokarski
10
9
  - Jarosław Biniek
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2015-08-21 00:00:00.000000000 Z
13
+ date: 2015-12-29 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: aruba
@@ -240,6 +239,9 @@ extensions: []
240
239
  extra_rdoc_files: []
241
240
  files:
242
241
  - lib/cuculungwa.rb
242
+ - lib/cuculungwa/formatters.rb
243
+ - lib/cuculungwa/generators.rb
244
+ - lib/cuculungwa/utils.rb
243
245
  homepage: http://rubygems.org/gems/cuculungwa
244
246
  licenses:
245
247
  - MIT
@@ -252,7 +254,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
254
  requirements:
253
255
  - - ">="
254
256
  - !ruby/object:Gem::Version
255
- version: 1.9.3
257
+ version: 2.2.2
256
258
  required_rubygems_version: !ruby/object:Gem::Requirement
257
259
  requirements:
258
260
  - - ">="