watircuke 0.0.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.
@@ -0,0 +1 @@
1
+ features/test.feature
data/README ADDED
@@ -0,0 +1,18 @@
1
+ INSTALL
2
+
3
+ Cucumber:
4
+ http://wiki.github.com/aslakhellesoy/cucumber/install
5
+
6
+ Watir ~ Firewatir ~ Safariwatir:
7
+ http://wtr.rubyforge.org/install.html
8
+
9
+ Once installed just run "cucumber features" in Safari, Firefox, Watir (see features/support/env.rb)
10
+
11
+
12
+ **cukewatir maximizes the Gherkin speak and minimizes the Watir code.
13
+
14
+ License:
15
+
16
+ MIT
17
+
18
+ Copyright (c) 2009 richdownie
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+
3
+ $LOAD_PATH.unshift('lib')
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "watircuke"
9
+ gem.summary = "Cross-Browser automated testing with Cucumber and Watir"
10
+ gem.email = "rich@richdownie.com"
11
+ gem.homepage = "http://github.com/richdownie/watircuke"
12
+ gem.description = "Test Multiple Browsers with English"
13
+ gem.authors = ["Rich Downie"]
14
+
15
+ gem.add_dependency "commonwatir", ">= 1.6.5"
16
+ gem.add_dependency "firewatir", ">= 1.6.5"
17
+ gem.add_dependency "safariwatir", ">= 0.3.7"
18
+ gem.add_dependency "cucumber"
19
+ end
20
+ rescue LoadError
21
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
22
+ end
23
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
Binary file
@@ -0,0 +1,12 @@
1
+ Feature: Try it out
2
+
3
+ Scenario: Click a Button
4
+ Given I am on the watircuke page
5
+ And I click the "Rubyist" button
6
+ Then I should see the sentence "Who am I?"
7
+
8
+ Scenario: Select a Value
9
+ Given I am on the watircuke page
10
+ And I select "Ruby" from "class_select" # @browser.select_list(:class, /(^|\s)#{what}(\s|$)/).set(option)
11
+ And I select "Cucumber" from "post_category" # @browser.select_list(:id, what).select(option)
12
+ Then I should NOT see the text "FOOBAR"
@@ -0,0 +1,56 @@
1
+ Given /I click the "(.*)" button/ do |what|
2
+ find_button(what)
3
+ end
4
+
5
+ Given /I click the "(.*)" checkbox/ do |what|
6
+ find_checkbox(what)
7
+ end
8
+
9
+ Given /I click the "(.*)" image/ do |what|
10
+ find_image(what)
11
+ end
12
+
13
+ Given /I click the "(.*)" link/ do |what|
14
+ find_link(what)
15
+ end
16
+
17
+ Given /I click the "(.*)" radio button/ do |what|
18
+ find_radio_button(what)
19
+ end
20
+
21
+ Given /I click row "(.*)" in the "(.*)" table/ do |row, column, what|
22
+ find_table(row, column, what)
23
+ end
24
+
25
+ Given /I select "(.*)" from "(.*)"/ do |option, what|
26
+ find_select_list(option, what)
27
+ end
28
+
29
+ Given /I fill in the text field "(.*)" with "(.*)"/ do |what, with|
30
+ find_text_field(what, with)
31
+ end
32
+
33
+ Then /^I should (NOT )?see the sentence "([^\"]*)"$/ do |visibility, what|
34
+ expected = (visibility.to_s.strip == 'NOT') ? assert_false(@browser.contains_text(what)) : assert(@browser.contains_text(what))
35
+ end
36
+
37
+ Then /^I should (NOT )?see the text "([^\"]*)"$/ do |visibility, what|
38
+ expected = (visibility.to_s.strip == 'NOT') ? assert_not_equal(@browser.contains_text(what), what) : assert_equal(@browser.contains_text(what))
39
+ end
40
+
41
+ Given /I am redirected to "(.*)"/ do |what|
42
+ url = @browser.url
43
+ assert_equal(@environment + what, url)
44
+ end
45
+
46
+ Given /^I am on (.+)$/ do |page_name|
47
+ @browser.goto(path_to(page_name)) #This step links up with the "path_to" method found in support/paths.rb
48
+ end
49
+
50
+ Given /^I go to "([^\"]*)"$/ do |url|
51
+ @browser.goto(url) #Links to generic urls like "google.com"
52
+ end
53
+
54
+ Given /^I sleep for "([^\"]*)"$/ do |seconds|
55
+ sleep seconds.to_i
56
+ end
@@ -0,0 +1,36 @@
1
+ require 'test/unit/assertions'
2
+ include Test::Unit::Assertions
3
+
4
+ if ENV['SAFARIWATIR']
5
+ require 'safariwatir'
6
+ Browser = Watir::Safari
7
+ else
8
+ case RUBY_PLATFORM
9
+ when /darwin/
10
+ require 'firewatir'
11
+ Browser = FireWatir::Firefox
12
+ when /win32|mingw/
13
+ require 'watir'
14
+ Browser = Watir::IE
15
+ when /java/
16
+ require 'celerity'
17
+ Browser = Celerity::Browser
18
+ else
19
+ raise "This platform is not supported (#{PLATFORM})"
20
+ end
21
+ end
22
+
23
+
24
+ browser = Browser.new
25
+ # "before all"
26
+ Before do
27
+ @browser = browser
28
+ @environment = "http://"
29
+ end
30
+
31
+ # "after all"
32
+ After do
33
+ # @browser.close
34
+ end
35
+
36
+
@@ -0,0 +1,30 @@
1
+ module Paths
2
+ def path_to(page_name)
3
+ case page_name
4
+ # @environment comes from env.rb where it is set to "http://"
5
+ #Test any external site
6
+ when /the google home page/i
7
+ @environment + "google.com"
8
+
9
+ when /the watircuke page/i
10
+ @environment + "richdownie.com/watircuke"
11
+
12
+ #Test any of your local apps
13
+ when /the localhost page/i
14
+ @environment + "localhost:3000"
15
+
16
+ #Test any of your local apps on passenger
17
+ when /the passenger page/i
18
+ @environment + "richdownie1.local/watircuke"
19
+
20
+ when /the youtube page/i
21
+ @environment + "youtube.com"
22
+
23
+ else
24
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
25
+ "Now, go and add a mapping in #{__FILE__}"
26
+ end
27
+ end
28
+ end
29
+
30
+ World(Paths)
@@ -0,0 +1,179 @@
1
+ module WatirCukeHelpers
2
+ def find_button(what)
3
+ case
4
+ when @browser.button(:id, what).exists?
5
+ @browser.button(:id, what).click
6
+
7
+ when @browser.button(:name, what).exists?
8
+ @browser.button(:name, what).click
9
+
10
+ when @browser.button(:value, what).exists?
11
+ @browser.button(:value, what).click
12
+
13
+ when @browser.button(:text, what).exists?
14
+ @browser.button(:text, what).click
15
+
16
+ when @browser.button(:index, what).exists?
17
+ @browser.button(:index, what).click
18
+
19
+ when @browser.button(:class, what).exists?
20
+ @browser.button(:class, what).click
21
+ else
22
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
23
+ end
24
+ end
25
+
26
+ def find_checkbox(what)
27
+ case
28
+ when @browser.checkbox(:id, what).exists?
29
+ @browser.checkbox(:id, what).click
30
+
31
+ when @browser.checkbox(:name, what).exists?
32
+ @browser.checkbox(:name, what).click
33
+
34
+ when @browser.checkbox(:value, what).exists?
35
+ @browser.checkbox(:value, what).click
36
+
37
+ when @browser.checkbox(:text, what).exists?
38
+ @browser.checkbox(:text, what).click
39
+
40
+ when @browser.checkbox(:index, what).exists?
41
+ @browser.checkbox(:index, what).click
42
+
43
+ when @browser.checkbox(:class, what).exists?
44
+ @browser.checkbox(:class, what).click
45
+ else
46
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
47
+ end
48
+ end
49
+
50
+ def find_image(what)
51
+ case
52
+ when @browser.image(:src, what).exists?
53
+ @browser.image(:src, what).click
54
+
55
+ when @browser.image(:id, what).exists?
56
+ @browser.image(:id, what).click
57
+
58
+ when @browser.image(:name, what).exists?
59
+ @browser.image(:name, what).click
60
+
61
+ when @browser.image(:text, what).exists?
62
+ @browser.image(:text, what).click
63
+
64
+ when @browser.image(:index, what).exists?
65
+ @browser.image(:index, what).click
66
+
67
+ when @browser.image(:class, what).exists?
68
+ @browser.image(:class, what).click
69
+ else
70
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
71
+ end
72
+ end
73
+
74
+ def find_link(what)
75
+ case
76
+ when @browser.link(:id, what).exists?
77
+ @browser.link(:id, what).click
78
+
79
+ when @browser.link(:text, what).exists?
80
+ @browser.link(:text, what).click
81
+
82
+ when @browser.link(:class, what).exists?
83
+ @browser.link(:class, what).click
84
+ else
85
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
86
+ end
87
+ end
88
+
89
+ def find_radio_button(what)
90
+ case
91
+ when @browser.radio(:id, what).exists?
92
+ @browser.radio(:id, what).click
93
+
94
+ when @browser.radio(:name, what).exists?
95
+ @browser.radio(:name, what).click
96
+
97
+ when @browser.radio(:value, what).exists?
98
+ @browser.radio(:value, what).click
99
+
100
+ when @browser.radio(:text, what).exists?
101
+ @browser.radio(:text, what).click
102
+
103
+ when @browser.radio(:index, what).exists?
104
+ @browser.radio(:index, what).click
105
+
106
+ when @browser.radio(:class, what).exists?
107
+ @browser.radio(:class, what).click
108
+ else
109
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
110
+ end
111
+ end
112
+
113
+ def find_table(row, column, what)
114
+ row = row.to_i
115
+ column = column.to_i
116
+ case
117
+ when @browser.table(:id, what).exists?
118
+ @browser.table(:id, what)[row][column].click
119
+
120
+ when @browser.table(:name, what).exists?
121
+ @browser.table(:name, what)[row][column].click
122
+
123
+ when @browser.table(:index, what).exists?
124
+ @browser.table(:index, what)[row][column].click
125
+
126
+ when @browser.table(:class, what).exists?
127
+ @browser.table(:class, what)[row][column].click
128
+ else
129
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
130
+ end
131
+ end
132
+
133
+ def find_select_list(option, what)
134
+ case
135
+ when @browser.select_list(:id, what).exists?
136
+ @browser.select_list(:id, what).select(option)
137
+
138
+ when @browser.select_list(:name, what).exists?
139
+ @browser.select_list(:name, what).select(option)
140
+
141
+ when @browser.select_list(:value, what).exists?
142
+ @browser.select_list(:value, what).select(option)
143
+
144
+ when @browser.select_list(:text, what).exists?
145
+ @browser.select_list(:text, what).select(option)
146
+
147
+ when @browser.select_list(:index, what).exists?
148
+ @browser.select_list(:index, what).select(option)
149
+
150
+ when @browser.select_list(:class, /(^|\s)#{what}(\s|$)/).exists?
151
+ @browser.select_list(:class, /(^|\s)#{what}(\s|$)/).set(option)
152
+ else
153
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
154
+ end
155
+ end
156
+
157
+ def find_text_field(what, with)
158
+ case
159
+ when @browser.text_field(:id, what).exists?
160
+ @browser.text_field(:id, what).set(with)
161
+
162
+ when @browser.text_field(:name, what).exists?
163
+ @browser.text_field(:name, what).set(with)
164
+
165
+ when @browser.text_field(:value, what).exists?
166
+ @browser.text_field(:value, what).set(with)
167
+
168
+ when @browser.text_field(:index, what).exists?
169
+ @browser.text_field(:index, what).set(with)
170
+
171
+ when @browser.text_field(:class, /(^|\s)#{what}(\s|$)/).exists?
172
+ @browser.text_field(:class, /(^|\s)#{what}(\s|$)/).set(with)
173
+ else
174
+ fail("Sorry, I wasn't able to find the " + "'#{what}'" + " element ")
175
+ end
176
+ end
177
+ end
178
+
179
+ World(WatirCukeHelpers)
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{watircuke}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Rich Downie"]
12
+ s.date = %q{2010-03-25}
13
+ s.description = %q{Test Multiple Browsers with English}
14
+ s.email = %q{rich@richdownie.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "README",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "features/.DS_Store",
24
+ "features/sample.feature",
25
+ "features/step_definitions/watircuke_steps.rb",
26
+ "features/support/env.rb",
27
+ "features/support/paths.rb",
28
+ "features/support/watircuke.rb",
29
+ "watircuke.gemspec"
30
+ ]
31
+ s.homepage = %q{http://github.com/richdownie/watircuke}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.5}
35
+ s.summary = %q{Cross-Browser automated testing with Cucumber and Watir}
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<commonwatir>, [">= 1.6.5"])
43
+ s.add_runtime_dependency(%q<firewatir>, [">= 1.6.5"])
44
+ s.add_runtime_dependency(%q<safariwatir>, [">= 0.3.7"])
45
+ s.add_runtime_dependency(%q<cucumber>, [">= 0"])
46
+ else
47
+ s.add_dependency(%q<commonwatir>, [">= 1.6.5"])
48
+ s.add_dependency(%q<firewatir>, [">= 1.6.5"])
49
+ s.add_dependency(%q<safariwatir>, [">= 0.3.7"])
50
+ s.add_dependency(%q<cucumber>, [">= 0"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<commonwatir>, [">= 1.6.5"])
54
+ s.add_dependency(%q<firewatir>, [">= 1.6.5"])
55
+ s.add_dependency(%q<safariwatir>, [">= 0.3.7"])
56
+ s.add_dependency(%q<cucumber>, [">= 0"])
57
+ end
58
+ end
59
+
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: watircuke
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rich Downie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-25 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: commonwatir
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.6.5
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: firewatir
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.5
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: safariwatir
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.3.7
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: cucumber
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: Test Multiple Browsers with English
56
+ email: rich@richdownie.com
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - README
63
+ files:
64
+ - .gitignore
65
+ - README
66
+ - Rakefile
67
+ - VERSION
68
+ - features/.DS_Store
69
+ - features/sample.feature
70
+ - features/step_definitions/watircuke_steps.rb
71
+ - features/support/env.rb
72
+ - features/support/paths.rb
73
+ - features/support/watircuke.rb
74
+ - watircuke.gemspec
75
+ has_rdoc: true
76
+ homepage: http://github.com/richdownie/watircuke
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --charset=UTF-8
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project:
99
+ rubygems_version: 1.3.5
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Cross-Browser automated testing with Cucumber and Watir
103
+ test_files: []
104
+