gem0 0.1.0 → 0.1.1

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: 8973d5b84a41f902e254156818a2f65456fd5888
4
- data.tar.gz: 73c9fecd19f966216fa83be592a8e2b373484b7f
3
+ metadata.gz: '000575388d600916a4fef54501e056eb4cd7636c'
4
+ data.tar.gz: 4ce97dba617bef920a6cf6778371b7157a33945f
5
5
  SHA512:
6
- metadata.gz: 20507e263b4a324a5bcbfefa18409db138c56fc7cac7134bef1ea8d517509196ba87a9fd6c9365f655b165baf5cdae77eae31ff7dfdbed1c0514ccb1eb377a1f
7
- data.tar.gz: 893d2c1b69465600b64d77de1948d76524154b3ebc4d43bbdd8c08ef697b73e36cce83838b328ed0c13f910bebb58c490eb586d7dfddf0c4272be093ad949021
6
+ metadata.gz: 40624b9083fb6591f359ee979062b8dc7e542bd2fc52de49d419a3476bd1f0137e322a7aa1c385a807c2bcf6c66bed442ad5b41fcae04567443f5d3ce5a6757c
7
+ data.tar.gz: '08d8a9b50ee97d20d30f21803ab5d7cbf415b757525618e62fd5caa712da7f36e04c5872cf05f9c9ce48c1bbefe2d31a5e0ec20fcfb840cd1a1ed0fa993714ba'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gem0 (0.0.0)
4
+ gem0 (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,93 @@
1
+ require_relative '../bin/env'
2
+ #require_relative '../../bdd-helper/support/config'
3
+
4
+ include BaseConstants
5
+
6
+ Then(/^page (should|should_not) contain "([^"]*)" content$/) do |condition, content|
7
+ # E.g. : page should contain "Test" content
8
+ # E.g. : page should_not contain "Test" content
9
+ # page.should have_content(content, count: count, wait: @timeout)
10
+ sleep 1
11
+ if condition == 'should'
12
+ page.should have_content(content, wait: @timeout)
13
+
14
+ elsif condition == 'should_not'
15
+ page.should_not have_content(content, wait: @timeout)
16
+ end
17
+ end
18
+
19
+ Then(/^page (should|should_not) contain the following contents:$/) do |condition, table|
20
+ sleep 1
21
+ values = table.raw
22
+ values.each {|raw|
23
+ if condition == 'should'
24
+ page.should have_content(raw[0], wait: @timeout)
25
+ elsif condition == 'should_not'
26
+ page.should_not have_content(raw[0], wait: @timeout)
27
+ end
28
+ }
29
+ end
30
+
31
+ Then(/^page (should|should_not) contain "([^"]*)" "([^"]*)" web element/) do |condition, web_element_type, web_element|
32
+ # E.g. : page should contain "css" "#test .form" web element
33
+ sleep 1
34
+ if condition == 'should'
35
+ page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
36
+
37
+ elsif condition == 'should_not'
38
+ page.should_not have_selector(:"#{web_element_type}", web_element, wait: @timeout)
39
+ end
40
+ end
41
+
42
+ Then(/^page (should|should_not) contain "([^"]*)" button$/) do |condition, button|
43
+ # E.g. : page should contain "Save" button
44
+ # E.g. : page should_not contain "Save" button
45
+ # page.should have_content(content, count: count, wait: @timeout)
46
+ sleep 1
47
+ if condition == 'should'
48
+ page.should have_button(button, wait: @timeout)
49
+
50
+ elsif condition == 'should_not'
51
+ page.should_not have_button(button, wait: @timeout)
52
+ end
53
+ end
54
+
55
+ Then(/^"([^"]*)" button (should|should_not) be disabled$/) do |button, condition|
56
+ sleep 1
57
+ if condition == 'should'
58
+ find_button button, disabled: true
59
+
60
+ elsif condition == 'should_not'
61
+ find_button button, disabled: false
62
+ end
63
+ end
64
+
65
+ When(/^"([^"]*)" checkbox should be (checked|unchecked)$/) do |checkbox, condition|
66
+ # E.g. : .. "Agree" checkbox should be checked
67
+ # checkbox can be label, value or id
68
+ if condition == 'checked'
69
+ expect(page).to have_field(checkbox, checked: true, visible: true)
70
+ elsif condition == 'unchecked'
71
+ expect(page).to have_field(checkbox, checked: false, visible: true)
72
+ end
73
+ end
74
+
75
+ When(/^"([^"]*)" radio button should be (selected|unselected)$/) do |radio_button, condition|
76
+ # E.g. : .. "Yes" radio button should be selected
77
+ # radio_button can be name, id or label
78
+ if condition == 'checked'
79
+ expect(page).to have_field(radio_button, checked: true, visible: true)
80
+ elsif condition == 'unchecked'
81
+ expect(page).to have_field(radio_button, checked: false, visible: true)
82
+ end
83
+ end
84
+
85
+ Then(/^validation message should be "([^"]*)" about "([^"]*)" field$/) do |expected_message, element_value|
86
+ sleep 1.5
87
+ if page.has_css?(element_value)
88
+ expected_message.should == page.execute_script("return document.querySelector('#{element_value}').innerHTML.trim();")
89
+
90
+ elsif page.has_no_css?(element_value)
91
+ expected_message.should == ''
92
+ end
93
+ end
@@ -0,0 +1,48 @@
1
+ require_relative '../bin/env'
2
+ #require_relative '../../bdd-helper/support/config'
3
+
4
+ And(/^refresh the page$/) do
5
+ page.evaluate_script('window.location.reload()')
6
+ sleep 1
7
+ # location = current_url
8
+ # page.driver.browser.navigate.refresh
9
+ # sleep 1
10
+ # current_url.should == location
11
+ end
12
+
13
+ When(/^navigate browser to "([^"]*)" url$/) do |url|
14
+ visit url
15
+ #current_url.should == url
16
+ end
17
+
18
+ # When(/^navigate browser to "([^"]*)" path$/) do |path|
19
+ # visit $URL + path
20
+ # current_url.should == $URL + path
21
+ # end
22
+
23
+ And(/^switch window to (first|last) opened$/) do |condition|
24
+ if condition == 'first'
25
+ page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
26
+ elsif condition == 'last'
27
+ page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
28
+ end
29
+ end
30
+
31
+ Then(/^user should redirected to "([^"]*)" path$/) do |path|
32
+ page.should have_current_path(path, wait: $TIMEOUT)
33
+ end
34
+
35
+ # Given(/^user on main page$/) do
36
+ # current_url.should == @url + '/'
37
+ # end
38
+
39
+ Then(/^alert message (should|should_not) be "([^"]*)" seçiniz."$/) do |condition, message|
40
+ if condition == 'should'
41
+ resp = page.driver.browser.switch_to.alert.text
42
+ resp.should == message
43
+
44
+ elsif condition == 'should_not'
45
+ resp = page.driver.browser.switch_to.alert.text
46
+ resp.should_not == message
47
+ end
48
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../bin/env'
2
+
3
+ When(/^(check|uncheck) "([^"]*)" checkbox$/) do |condition, checkbox|
4
+ # E.g. : .. check "Agree" checkbox
5
+ # checkbox can be name, id or label
6
+ if condition == 'check'
7
+ check(checkbox)
8
+ elsif condition == 'uncheck'
9
+ uncheck(checkbox)
10
+ end
11
+ end
12
+
13
+ When(/^choose "([^"]*)" radio button$/) do |radio_button|
14
+ # E.g. : .. choose "Yes" radio button
15
+ # radio_button can be name, id or label
16
+ choose(radio_button)
17
+ end
18
+
19
+ And(/^check type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
20
+ page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
21
+ find(:"#{web_element_type}", web_element).set(true)
22
+ end
@@ -0,0 +1,29 @@
1
+ require_relative '../bin/env'
2
+
3
+ When(/^click "([^"]*)" (link|button) by (id|title|text)$/) do |identifier, identifier_type, condition|
4
+ # E.g: .. click "Save" button by text
5
+ Capybara.ignore_hidden_elements = false
6
+ if condition == 'title' || condition == 'text'
7
+ page.should have_content(identifier)
8
+
9
+ elsif condition == 'id'
10
+ page.should have_selector(:id, identifier)
11
+ end
12
+
13
+ if identifier_type == 'link'
14
+ # link can be id, title or text
15
+ Capybara.ignore_hidden_elements = false
16
+ click_link(identifier)
17
+
18
+ elsif identifier_type == 'button'
19
+ # button can be id, title, value or text
20
+ Capybara.ignore_hidden_elements = false
21
+ click_button(identifier)
22
+ end
23
+ end
24
+
25
+ Then(/^click type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
26
+ # E.g: .. click type "id" value "save" web element
27
+ page.should have_selector(:"#{web_element_type}", web_element)
28
+ find(:"#{web_element_type}", web_element).click
29
+ end
@@ -0,0 +1,12 @@
1
+ require 'capybara'
2
+ require 'capybara/cucumber'
3
+ require 'capybara/dsl'
4
+ #require 'capybara/poltergeist'
5
+ require 'capybara/rspec'
6
+ require 'rubygems'
7
+ require 'rspec'
8
+ require 'rspec/expectations'
9
+ require 'rspec/matchers'
10
+ require 'selenium-cucumber'
11
+ require 'selenium/webdriver'
12
+ require 'selenium/webdriver/common/wait'
@@ -0,0 +1,56 @@
1
+ require_relative '../bin/env'
2
+
3
+ And(/^fill "([^"]*)" with "([^"]*)"$/) do |field, value|
4
+ # E.g : ..fill "Phone Number" with "5555555555"
5
+ # field can be name, id or label
6
+ fill_in(field, with: value)
7
+ end
8
+
9
+ And(/^fill input boxes with these values:$/) do |table|
10
+ values = table.raw
11
+ values.each {|raw| fill_in(raw[0], with: raw[1])}
12
+ end
13
+
14
+ Then(/^fill type "([^"]*)" value "([^"]*)" web element with "([^"]*)"$/) do |web_element_type, web_element, value|
15
+ # E.g: .. click type "id" value "save" web element
16
+ page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
17
+ find(:"#{web_element_type}", web_element).set(value)
18
+ end
19
+
20
+ # =scoping=
21
+ # within("//li[@id='employee']") do
22
+ # fill_in 'Name', :with => 'Jimmy'
23
+ # end
24
+ # within(:css, "li#employee") do
25
+ # fill_in 'Name', :with => 'Jimmy'
26
+ # end
27
+ # within_fieldset('Employee') do
28
+ # fill_in 'Name', :with => 'Jimmy'
29
+ # end
30
+ # within_table('Employee') do
31
+ # fill_in 'Name', :with => 'Jimmy'
32
+ # end
33
+
34
+ And(/^fill "([^"]*)" with random (email|password|name|gsm)$/) do |field, condition|
35
+ def generate_code(number, condition)
36
+ if condition == 'email'
37
+ charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
38
+ Array.new(number) {charset.sample}.join + "@gmail.com"
39
+
40
+ elsif condition == 'password'
41
+ charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
42
+ Array.new(number) {charset.sample}.join
43
+
44
+ elsif condition == 'name'
45
+ charset = Array('A'..'Z') + Array('a'..'z')
46
+ Array.new(number) {charset.sample}.join
47
+
48
+ elsif condition == 'gsm'
49
+ charset = Array(0..9)
50
+ Array.new(7) {charset.sample}.join
51
+ end
52
+ end
53
+
54
+ var = generate_code(10, condition)
55
+ fill_in(field, with: var)
56
+ end
@@ -0,0 +1,5 @@
1
+ require "gem0/version"
2
+
3
+ module Gem0
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../bin/env'
2
+
3
+ And(/^select "([^"]*)" as "([^"]*)" from dropdown$/) do |dropdown, option|
4
+ # E.g : select "Country" as "United States" from dropdown
5
+ # E.g : select "United States", from: "Country", :match => :first ===>> to select first matched option
6
+ # dropdown can be id, name, label text
7
+ select(option, from: dropdown) # OR ==>> find('#select_id').select('value')
8
+ end
9
+
10
+ Then /^"([^"]*)" (should|should_not) be selected for "([^"]*)" dropdown$/ do |selected_option, condition, dropdown|
11
+ # E.g : "United States" should be selected for "Country" dropdown
12
+ if condition == 'should'
13
+ page.should have_select(dropdown, selected: selected_option)
14
+
15
+ elsif condition == 'should_not'
16
+ page.should_not have_select(dropdown, selected: selected_option)
17
+ end
18
+ end
19
+
20
+ Then /^"([^"]*)" dropdown (should|should_not) contain "([^"]*)" option$/ do |dropdown, condition, option_text|
21
+ # E.g : .. "Country" dropdown should contain "United States" option
22
+ if condition == 'should'
23
+ page.should have_select(dropdown, with_options: [option_text])
24
+
25
+ elsif condition == 'should_not'
26
+ page.should_not have_select(dropdown, with_options: [option_text])
27
+ end
28
+ end
29
+
30
+ Then /^"([^"]*)" dropdown (should|should_not) contain following options:$/ do |dropdown, condition, table|
31
+ values = table.raw
32
+ sleep 1
33
+ values.each {|raw|
34
+ if condition == 'should'
35
+ page.should have_select(dropdown, with_options: [raw[0]])
36
+
37
+ elsif condition == 'should_not'
38
+ page.should_not have_select(dropdown, with_options: [raw[0]])
39
+ end}
40
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../bin/env'
2
+
3
+ When(/^hover to "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
4
+ find(:"#{web_element_type}", web_element).trigger(:mouseover)
5
+ end
6
+
7
+ When(/^wait "([^"]*)" seconds$/) do |sec_value|
8
+ sleep sec_value.to_i
9
+ end
10
+
11
+ And(/^generate random string and type into "([^"]*)"$/) do |field|
12
+ charset = (0...8).map {(65 + rand(26)).chr}.join
13
+ fill_in(field, with: charset)
14
+ end
15
+
16
+ And(/^execute javascript code "([^"]*)"/) do |code|
17
+ page.execute_script(code)
18
+ sleep 2
19
+ end
Binary file
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gem0'
3
- s.version = '0.1.0'
3
+ s.version = '0.1.1'
4
4
  s.date = '2017-08-14'
5
5
  s.summary = 'gem0!'
6
6
  s.description = 'A simple hello world gem'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Quaranto
@@ -20,9 +20,19 @@ files:
20
20
  - Gemfile.lock
21
21
  - README.md
22
22
  - Rakefile
23
+ - bin/assertion.rb
24
+ - bin/browser.rb
25
+ - bin/check.rb
26
+ - bin/click.rb
23
27
  - bin/console
28
+ - bin/env.rb
29
+ - bin/fill.rb
30
+ - bin/gem0.rb
31
+ - bin/select.rb
24
32
  - bin/setup
33
+ - bin/unclassified.rb
25
34
  - gem0-0.0.0.gem
35
+ - gem0-0.1.0.gem
26
36
  - gem0.gemspec
27
37
  homepage: http://rubygems.org/gems/gem0
28
38
  licenses: