bdd-helper 0.0.2 → 0.0.3

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: cc20facec2072884fe70c461269b8a51a3cee345
4
- data.tar.gz: '082cbf177aa48e9c5c762880c4301dd9a01687fd'
3
+ metadata.gz: ec404f4420287d0524c4314f335bdddf8be7429d
4
+ data.tar.gz: '076422281aa39d50d366fe027632ffb8b43f709b'
5
5
  SHA512:
6
- metadata.gz: 0e3ba15af219bcffcc2a420e1d636ee6d11e8d720ec9153124f385e0325e520a1271f289872db7a01d02b78eb4e8fa50a388a11968170f77c648b85582cc194f
7
- data.tar.gz: 83620f7e9956fe447efc6cdf7c176a9385da62471ce83a1b772ee83ce746708aa83367272a1ad716ffef531e128efe8f6b69307adf13c442762065a5a3c064d5
6
+ metadata.gz: a658fd11c472f840dd84f5117e47a4ea4356bfe9efe314cd64c6c89c1566fb858107148c6e7afe62bfaa5a903a40d834985244e1fcfc13a2cc93ced3369288ab
7
+ data.tar.gz: 44fca287f15e51631bb9dbe35559642b5744bd3596e783ac45f69558d77e609b3c8ef44d2b2107afc5325847459738498d52b2329ec52150da7bbb386fe23b44
data/lib/bdd-helper.rb CHANGED
@@ -5,7 +5,6 @@ require 'capybara/rspec'
5
5
  require 'rspec'
6
6
  require 'rspec/expectations'
7
7
  require 'rspec/matchers'
8
- require 'selenium-cucumber'
9
8
  require 'selenium/webdriver'
10
9
  require 'selenium/webdriver/common/wait'
11
10
 
@@ -1,15 +1,17 @@
1
- @timeout = 20
1
+ require_relative 'config'
2
+
3
+ include BaseConstants
2
4
 
3
5
  Then(/^page (should|should_not) contain "([^"]*)" content$/) do |condition, content|
4
6
  # E.g. : page should contain "Test" content
5
7
  # E.g. : page should_not contain "Test" content
6
- # page.should have_content(content, count: count, wait: @timeout)
8
+ # page.should have_content(content, count: count, wait: $timeout)
7
9
  sleep 1
8
10
  if condition == 'should'
9
- page.should have_content(content, wait: @timeout)
11
+ page.should have_content(content, wait: $timeout)
10
12
 
11
13
  elsif condition == 'should_not'
12
- page.should_not have_content(content, wait: @timeout)
14
+ page.should_not have_content(content, wait: $timeout)
13
15
  end
14
16
  end
15
17
 
@@ -18,9 +20,9 @@ Then(/^page (should|should_not) contain the following contents:$/) do |condition
18
20
  values = table.raw
19
21
  values.each {|raw|
20
22
  if condition == 'should'
21
- page.should have_content(raw[0], wait: @timeout)
23
+ page.should have_content(raw[0], wait: $timeout)
22
24
  elsif condition == 'should_not'
23
- page.should_not have_content(raw[0], wait: @timeout)
25
+ page.should_not have_content(raw[0], wait: $timeout)
24
26
  end
25
27
  }
26
28
  end
@@ -29,23 +31,23 @@ Then(/^page (should|should_not) contain "([^"]*)" "([^"]*)" web element/) do |co
29
31
  # E.g. : page should contain "css" "#test .form" web element
30
32
  sleep 1
31
33
  if condition == 'should'
32
- page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
34
+ page.should have_selector(:"#{web_element_type}", web_element, wait: $timeout)
33
35
 
34
36
  elsif condition == 'should_not'
35
- page.should_not have_selector(:"#{web_element_type}", web_element, wait: @timeout)
37
+ page.should_not have_selector(:"#{web_element_type}", web_element, wait: $timeout)
36
38
  end
37
39
  end
38
40
 
39
41
  Then(/^page (should|should_not) contain "([^"]*)" button$/) do |condition, button|
40
42
  # E.g. : page should contain "Save" button
41
43
  # E.g. : page should_not contain "Save" button
42
- # page.should have_content(content, count: count, wait: @timeout)
44
+ # page.should have_content(content, count: count, wait: $timeout)
43
45
  sleep 1
44
46
  if condition == 'should'
45
- page.should have_button(button, wait: @timeout)
47
+ page.should have_button(button, wait: $timeout)
46
48
 
47
49
  elsif condition == 'should_not'
48
- page.should_not have_button(button, wait: @timeout)
50
+ page.should_not have_button(button, wait: $timeout)
49
51
  end
50
52
  end
51
53
 
@@ -60,7 +62,7 @@ Then(/^"([^"]*)" button (should|should_not) be disabled$/) do |button, condition
60
62
  end
61
63
 
62
64
  When(/^"([^"]*)" checkbox should be (checked|unchecked)$/) do |checkbox, condition|
63
- # E.g. : .. "Agree" checkbox should be checked
65
+ # E.g. : "Agree" checkbox should be checked
64
66
  # checkbox can be label, value or id
65
67
  if condition == 'checked'
66
68
  expect(page).to have_field(checkbox, checked: true, visible: true)
@@ -70,7 +72,7 @@ When(/^"([^"]*)" checkbox should be (checked|unchecked)$/) do |checkbox, conditi
70
72
  end
71
73
 
72
74
  When(/^"([^"]*)" radio button should be (selected|unselected)$/) do |radio_button, condition|
73
- # E.g. : .. "Yes" radio button should be selected
75
+ # E.g. : "Yes" radio button should be selected
74
76
  # radio_button can be name, id or label
75
77
  if condition == 'checked'
76
78
  expect(page).to have_field(radio_button, checked: true, visible: true)
data/lib/steps/browser.rb CHANGED
@@ -1,22 +1,16 @@
1
+ require_relative 'config'
2
+
3
+ include BaseConstants
4
+
1
5
  And(/^refresh the page$/) do
2
6
  page.evaluate_script('window.location.reload()')
3
7
  sleep 1
4
- # location = current_url
5
- # page.driver.browser.navigate.refresh
6
- # sleep 1
7
- # current_url.should == location
8
8
  end
9
9
 
10
10
  When(/^navigate browser to "([^"]*)" url$/) do |url|
11
11
  visit url
12
- #current_url.should == url
13
12
  end
14
13
 
15
- # When(/^navigate browser to "([^"]*)" path$/) do |path|
16
- # visit $URL + path
17
- # current_url.should == $URL + path
18
- # end
19
-
20
14
  And(/^switch window to (first|last) opened$/) do |condition|
21
15
  if condition == 'first'
22
16
  page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
@@ -26,14 +20,10 @@ And(/^switch window to (first|last) opened$/) do |condition|
26
20
  end
27
21
 
28
22
  Then(/^user should redirected to "([^"]*)" path$/) do |path|
29
- page.should have_current_path(path, wait: $TIMEOUT)
23
+ page.should have_current_path(path, wait: $timeout)
30
24
  end
31
25
 
32
- # Given(/^user on main page$/) do
33
- # current_url.should == @url + '/'
34
- # end
35
-
36
- Then(/^alert message (should|should_not) be "([^"]*)" seçiniz."$/) do |condition, message|
26
+ Then(/^alert message (should|should_not) be "([^"]*)"$/) do |condition, message|
37
27
  if condition == 'should'
38
28
  resp = page.driver.browser.switch_to.alert.text
39
29
  resp.should == message
data/lib/steps/check.rb CHANGED
@@ -1,5 +1,9 @@
1
+ require_relative 'config'
2
+
3
+ include BaseConstants
4
+
1
5
  When(/^(check|uncheck) "([^"]*)" checkbox$/) do |condition, checkbox|
2
- # E.g. : .. check "Agree" checkbox
6
+ # E.g. : check "Agree" checkbox
3
7
  # checkbox can be name, id or label
4
8
  if condition == 'check'
5
9
  check(checkbox)
@@ -9,12 +13,12 @@ When(/^(check|uncheck) "([^"]*)" checkbox$/) do |condition, checkbox|
9
13
  end
10
14
 
11
15
  When(/^choose "([^"]*)" radio button$/) do |radio_button|
12
- # E.g. : .. choose "Yes" radio button
16
+ # E.g. : choose "Yes" radio button
13
17
  # radio_button can be name, id or label
14
18
  choose(radio_button)
15
19
  end
16
20
 
17
21
  And(/^check type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
18
- page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
22
+ page.should have_selector(:"#{web_element_type}", web_element, wait: $timeout)
19
23
  find(:"#{web_element_type}", web_element).set(true)
20
24
  end
data/lib/steps/click.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  When(/^click "([^"]*)" (link|button) by (id|title|text)$/) do |identifier, identifier_type, condition|
2
- # E.g: .. click "Save" button by text
2
+ # E.g: click "Save" button by text
3
3
  Capybara.ignore_hidden_elements = false
4
+
4
5
  if condition == 'title' || condition == 'text'
5
6
  page.should have_content(identifier)
6
7
 
@@ -10,18 +11,16 @@ When(/^click "([^"]*)" (link|button) by (id|title|text)$/) do |identifier, ident
10
11
 
11
12
  if identifier_type == 'link'
12
13
  # link can be id, title or text
13
- Capybara.ignore_hidden_elements = false
14
14
  click_link(identifier)
15
15
 
16
16
  elsif identifier_type == 'button'
17
- # button can be id, title, value or text
18
- Capybara.ignore_hidden_elements = false
17
+ # button can be id, title or text
19
18
  click_button(identifier)
20
19
  end
21
20
  end
22
21
 
23
22
  Then(/^click type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
24
- # E.g: .. click type "id" value "save" web element
23
+ # E.g: click type "id" value "save" web element
25
24
  page.should have_selector(:"#{web_element_type}", web_element)
26
25
  find(:"#{web_element_type}", web_element).click
27
26
  end
data/lib/steps/config.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module BaseConstants
2
2
 
3
- @timeout = 20
3
+ $timeout = 20
4
4
 
5
5
  end
data/lib/steps/fill.rb CHANGED
@@ -1,5 +1,9 @@
1
+ require_relative 'config'
2
+
3
+ include BaseConstants
4
+
1
5
  And(/^fill "([^"]*)" with "([^"]*)"$/) do |field, value|
2
- # E.g : ..fill "Phone Number" with "5555555555"
6
+ # E.g : fill "Phone Number" with "5555555555"
3
7
  # field can be name, id or label
4
8
  fill_in(field, with: value)
5
9
  end
@@ -10,25 +14,11 @@ And(/^fill input boxes with these values:$/) do |table|
10
14
  end
11
15
 
12
16
  Then(/^fill type "([^"]*)" value "([^"]*)" web element with "([^"]*)"$/) do |web_element_type, web_element, value|
13
- # E.g: .. click type "id" value "save" web element
14
- page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
17
+ # E.g: fill type "id" value "mobilePhone" web element with "5555555555"
18
+ page.should have_selector(:"#{web_element_type}", web_element, wait: $timeout)
15
19
  find(:"#{web_element_type}", web_element).set(value)
16
20
  end
17
21
 
18
- # =scoping=
19
- # within("//li[@id='employee']") do
20
- # fill_in 'Name', :with => 'Jimmy'
21
- # end
22
- # within(:css, "li#employee") do
23
- # fill_in 'Name', :with => 'Jimmy'
24
- # end
25
- # within_fieldset('Employee') do
26
- # fill_in 'Name', :with => 'Jimmy'
27
- # end
28
- # within_table('Employee') do
29
- # fill_in 'Name', :with => 'Jimmy'
30
- # end
31
-
32
22
  And(/^fill "([^"]*)" with random (email|password|name|gsm)$/) do |field, condition|
33
23
  def generate_code(number, condition)
34
24
  if condition == 'email'
data/lib/steps/select.rb CHANGED
@@ -16,7 +16,7 @@ Then /^"([^"]*)" (should|should_not) be selected for "([^"]*)" dropdown$/ do |se
16
16
  end
17
17
 
18
18
  Then /^"([^"]*)" dropdown (should|should_not) contain "([^"]*)" option$/ do |dropdown, condition, option_text|
19
- # E.g : .. "Country" dropdown should contain "United States" option
19
+ # E.g : "Country" dropdown should contain "United States" option
20
20
  if condition == 'should'
21
21
  page.should have_select(dropdown, with_options: [option_text])
22
22
 
@@ -1,4 +1,5 @@
1
1
  When(/^hover to "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
2
+ # E.g: hover to "css" value ".map" web element
2
3
  find(:"#{web_element_type}", web_element).trigger(:mouseover)
3
4
  end
4
5
 
@@ -6,9 +7,10 @@ When(/^wait "([^"]*)" seconds$/) do |sec_value|
6
7
  sleep sec_value.to_i
7
8
  end
8
9
 
9
- And(/^generate random string and type into "([^"]*)"$/) do |field|
10
- charset = (0...8).map {(65 + rand(26)).chr}.join
11
- fill_in(field, with: charset)
10
+ And(/^generate "([^"]*)" char random string and type into type "([^"]*)" value "([^"]*)"$/) do |count, web_element_type, web_element|
11
+ # E.g: generate "10" char random string and type into type "id" value "mobile"
12
+ charset = (0...count).map {(65 + rand(26)).chr}.join
13
+ find(:"#{web_element_type}", web_element).set(charset)
12
14
  end
13
15
 
14
16
  And(/^execute javascript code "([^"]*)"/) do |code|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bdd-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Ali Aydin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-22 00:00:00.000000000 Z
11
+ date: 2017-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -70,47 +70,21 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 3.5.0
73
- - !ruby/object:Gem::Dependency
74
- name: selenium-cucumber
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '3.1'
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 3.1.5
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '3.1'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 3.1.5
93
73
  - !ruby/object:Gem::Dependency
94
74
  name: selenium-webdriver
95
75
  requirement: !ruby/object:Gem::Requirement
96
76
  requirements:
97
- - - "~>"
77
+ - - '='
98
78
  - !ruby/object:Gem::Version
99
- version: '3.0'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 3.0.5
79
+ version: 3.4.0
103
80
  type: :runtime
104
81
  prerelease: false
105
82
  version_requirements: !ruby/object:Gem::Requirement
106
83
  requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '3.0'
110
- - - ">="
84
+ - - '='
111
85
  - !ruby/object:Gem::Version
112
- version: 3.0.5
113
- description: Package of helper step defitions for BDD testing with Gherkin and Cucumber
86
+ version: 3.4.0
87
+ description: Package of helper step definitions for BDD testing with Gherkin and Cucumber
114
88
  email: maaydin@gmail.com
115
89
  executables: []
116
90
  extensions: []