nofxx-watircuke 0.2.3 → 0.3.0

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.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = Watircuke
1
+ = Watircuke
2
2
 
3
3
 
4
4
  == INSTALL
@@ -14,12 +14,12 @@ Once installed just run "cucumber features" in Safari, Firefox, Watir (see featu
14
14
 
15
15
  == Rails
16
16
 
17
- Supposing your webrat features are on features/plain, Watir on features/watir and
18
- you remove step_definitions/webrat_steps.rb (don't worry, steps will be included),
17
+ Supposing your webrat features are on features/plain, Watir on features/watir and
18
+ you remove step_definitions/webrat_steps.rb (don't worry, steps will be included),
19
19
  you can run `cucumber` for plain webrat and `cucumber -p watir` for some Watir =D
20
20
 
21
21
  cucumber.yml
22
-
22
+
23
23
  default: -r features/support/env.rb -r features/support/webrat.rb -r features/step_definitions features/plain
24
24
  watir: -r features/support/env.rb -r features/support/watir.rb -r features/step_definitions features/watir
25
25
 
@@ -56,9 +56,8 @@ support/env.rb
56
56
  require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
57
57
  Cucumber::Rails.use_transactional_fixtures
58
58
  Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
59
-
60
- == TODO
61
59
 
62
- Rewrite the watir steps to resemble webrat's ones.
63
60
 
64
- **cukewatir maximizes the Gherkin speak and minimizes the Watir code.
61
+ == ABOUT
62
+
63
+ **cukewatir maximizes the Gherkin speak and minimizes the Watir code.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: -r features/support/env.rb -r features/support/paths.rb features
@@ -0,0 +1,8 @@
1
+ Feature: Github
2
+
3
+ Scenario: ajaxy test
4
+ Given I am on the watircuke page
5
+ And I click "download_button"
6
+ And I wait until "facebox"
7
+ And I wait until "archives"
8
+ Then I should see "Download richdownie/watircuke at master "
@@ -1,10 +1,11 @@
1
1
  Feature: Github
2
-
2
+
3
3
  Scenario: search for cucumber at github
4
- Given I am on the watircuke page
5
- Then I verify the page contains the text "richdownie"
6
- And I fill in the text field "q" with "cucumber"
7
- And I click the "Search" button
8
- And I select "Code" from the select list "type_value"
9
- And I click the "aslakhellesoy / cucumber" link
10
- Then I verify the page contains the text "BDD that talks to domain experts first and code second"
4
+ Given I am on the cucumber page
5
+ Then I should see "BDD that talks to domain experts first and code second"
6
+ When I fill in "q" with "watircuke"
7
+ And I press "Search"
8
+ And I select "Code" from "type_value"
9
+ Then I should see "Repositories"
10
+ When I follow "richdownie / watircuke"
11
+ Then I should see "H30 (watir, safariwatir, firewatir)"
@@ -1,39 +1,15 @@
1
- require 'test/unit/assertions'
2
- include Test::Unit::Assertions
3
1
  require 'spec'
2
+ #require 'cucumber/rails/rspec'
3
+ require 'webrat/core/matchers'
4
4
 
5
- if ENV['FIREWATIR']
6
- require 'firewatir'
7
- Browser = FireWatir::Firefox
8
- else
9
- case RUBY_PLATFORM
10
- when /darwin|i686-linux/
11
- require 'firewatir'
12
- Browser = FireWatir::Firefox
13
- # require 'safariwatir'
14
- # Browser = Watir::Safari
15
- when /win32|mingw/
16
- require 'watir'
17
- Browser = Watir::IE
18
- when /java/
19
- require 'celerity'
20
- Browser = Celerity::Browser
21
- else
22
- raise "This platform is not supported (#{PLATFORM})"
23
- end
24
- end
25
-
26
-
27
- # "before all"
28
- browser = Browser.new
5
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/watircuke')
29
6
 
30
- Before do
31
- @browser = browser
32
- @environment = "http://github.com/"
33
- sleep 3
34
- end
7
+ Before do
8
+ @environment = "http://github.com/"
9
+ # sleep 1
10
+ end
35
11
 
36
- # "after all"
37
- at_exit do
38
- # @browser.close
39
- end
12
+ # "after all"
13
+ at_exit do
14
+ # @browser.close
15
+ end
@@ -1,15 +1,18 @@
1
1
  module NavigationHelpers
2
2
  def path_to(page_name)
3
3
  case page_name
4
-
4
+
5
5
  when /the guides page/i
6
6
  @environment + "guides/home"
7
-
8
7
  when /the watircuke page/i
9
8
  @environment + "richdownie/watircuke/tree/master"
10
-
9
+ when /the cucumber page/i
10
+ @environment + "aslakhellesoy/cucumber/tree/master"
11
+ when /the homepage/i
12
+ @environment
13
+
11
14
  # Add more page name => path mappings here
12
-
15
+
13
16
  else
14
17
  raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
15
18
  "Now, go and add a mapping in features/support/paths.rb"
@@ -17,6 +20,4 @@ module NavigationHelpers
17
20
  end
18
21
  end
19
22
 
20
- World do
21
- extend NavigationHelpers
22
- end
23
+ World(NavigationHelpers)
data/lib/watircuke.rb CHANGED
@@ -1,7 +1,11 @@
1
- require "cucumber"
1
+ #
2
+ # Watircuke
3
+ #
4
+ # Commonly used watir steps
5
+ #
6
+ #
7
+ require 'cucumber'
2
8
  require 'spec'
3
- #require File.join(File.dirname(__FILE__), '..', 'features', 'support', 'env')
4
- # Dir[File.join(File.dirname(__FILE__), '..', 'features', 'step_definitions', '*rb')].each { |file| require file }
5
9
 
6
10
  #
7
11
  # Environment
@@ -37,39 +41,40 @@ end
37
41
  #
38
42
  # Browsing
39
43
  #
40
- When /^I follow "([^\"]*)"$/ do |l|
41
- @browser.link(:text, l).click
44
+ Given /^I am on (.+)$/ do |page_name|
45
+ @browser.goto(path_to(page_name))
42
46
  end
43
47
 
44
48
  When /^I (visit|go to) the (.+)$/ do |_, text|
45
49
  @browser.goto(@environment + text)
46
50
  end
47
51
 
48
- Given /^I am on (.+)$/ do |page_name|
49
- @browser.goto(path_to(page_name))
52
+ When /^I (click|follow) "([^\"]*)"$/ do |_, id|
53
+ link = @browser.link(:text, id).click rescue @browser.link(:id, id).click
50
54
  end
51
55
 
52
- # Then /^I should be on (.+)$/ do |page_name|
53
- # URI.parse(current_url).path.should == path_to(page_name)
54
- # end
56
+ Then /^I should be on (.+)$/ do |page_name|
57
+ URI.parse(@browser.url).path.should == path_to(page_name)
58
+ end
55
59
 
56
60
  #
57
61
  # Should see
58
62
  #
63
+ #
59
64
  Then /^I should see "([^\"]*)"$/ do |text|
60
- @browser.should contains_text(text)
65
+ @browser.contains_text(text).should be_true
61
66
  end
62
67
 
63
68
  Then /^I should not see "([^\"]*)"$/ do |text|
64
- @browser.should_not contains_text(text)
69
+ @browser.contains_text(text).should be_false
65
70
  end
66
71
 
67
- Then /^I should see "([^\"]*)" (\d+) times*$/ do |text, count|
68
- res = @browser.body
69
- (count.to_i - 1).times { res.sub!(/#{text}/, "")}
70
- res.should contain(text)
71
- res.sub(/#{text}/, "").should_not contain(text)
72
- end
72
+ # Then /^I should see "([^\"]*)" (\d+) times*$/ do |text, count|
73
+ # res = @browser.body
74
+ # (count.to_i - 1).times { res.sub!(/#{text}/, "")}
75
+ # res.should contain(text)
76
+ # res.sub(/#{text}/, "").should_not contain(text)
77
+ # end
73
78
 
74
79
  Given /I verify the page contains a div class "(.*)"/ do |byclass|
75
80
  @browser.div(:class, byclass).exists?.should be_true
@@ -87,9 +92,14 @@ Given /I verify the page contains the image "(.*)"/ do |image|
87
92
  @browser.image(:src, image).exists?.should be_true
88
93
  end
89
94
 
95
+ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
96
+ @browser.checkbox(label).should be_checked
97
+ end
98
+
90
99
  #
91
100
  # Forms
92
101
  #
102
+ #
93
103
  When /^I press "([^\"]*)"$/ do |b|
94
104
  @browser.button(:value, b).click
95
105
  end
@@ -110,14 +120,8 @@ When /^I check "([^\"]*)"$/ do |id|
110
120
  @browser.checkbox(:id, id).click
111
121
  end
112
122
 
113
- # When /^I uncheck "([^\"]*)"$/ do |field|
114
- # uncheck(field)
115
- # end
116
- # Given /I click the "(.*)" checkbox/ do |id|
117
- # end
118
-
119
- Given /I wait "(.*)" seconds/ do |time|
120
- sleep time.to_i
123
+ When /^I uncheck "([^\"]*)"$/ do |id|
124
+ @browser.checkbox(field).clear
121
125
  end
122
126
 
123
127
  #
@@ -130,3 +134,14 @@ end
130
134
  Given /I click the "(.*)" span/ do |text|
131
135
  @browser.span(:text, text).click
132
136
  end
137
+
138
+ Given /I wait (\d+) seconds*/ do |time|
139
+ sleep time.to_i
140
+ end
141
+
142
+ Given /^I wait until "([^\"]*)"$/ do |div|
143
+ 7.times do |i|
144
+ break if @browser.div(:id, div).exists?
145
+ i == 7 ? raise(Watir::Exception::UnknownObjectException) : sleep(1)
146
+ end
147
+ end
data/lib/webratcuke.rb CHANGED
@@ -1,8 +1,14 @@
1
- # require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
2
-
1
+ #
2
+ # Watircuke
3
+ #
3
4
  # Commonly used webrat steps
4
5
  # http://github.com/brynary/webrat
6
+ #
5
7
 
8
+ #
9
+ # Browsing
10
+ #
11
+ #
6
12
  Given /^I am on (.+)$/ do |page_name|
7
13
  visit path_to(page_name)
8
14
  end
@@ -11,14 +17,82 @@ When /^I go to (.+)$/ do |page_name|
11
17
  visit path_to(page_name)
12
18
  end
13
19
 
14
- When /^I press "([^\"]*)"$/ do |button|
15
- click_button(button)
16
- end
17
-
18
20
  When /^I follow "([^\"]*)"$/ do |link|
19
21
  click_link(link)
20
22
  end
21
23
 
24
+ Then /^I should be on (.+)$/ do |page_name|
25
+ URI.parse(current_url).path.should == path_to(page_name)
26
+ end
27
+
28
+ #
29
+ # Should see
30
+ #
31
+ #
32
+ Then /^I should see "([^\"]*)"$/ do |text|
33
+ response.should contain(text)
34
+ end
35
+
36
+ Then /^I should not see "([^\"]*)"$/ do |text|
37
+ response.should_not contain(text)
38
+ end
39
+
40
+ Then /^I should see "([^\"]*)" (\d+) times*$/ do |text, count|
41
+ res = response.body
42
+ (count.to_i - 1).times { res.sub!(/#{text}/, "")}
43
+ res.should contain(text)
44
+ res.sub(/#{text}/, "").should_not contain(text)
45
+ end
46
+
47
+ Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
48
+ field_labeled(field).value.should =~ /#{value}/
49
+ end
50
+
51
+ Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
52
+ field_labeled(field).value.should_not =~ /#{value}/
53
+ end
54
+
55
+ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
56
+ field_labeled(label).should be_checked
57
+ end
58
+
59
+ Then /^I should see a (\S+) in the (\S+)$/ do |element, containing_element|
60
+ response.should have_tag("##{containing_element} .#{element}")
61
+ end
62
+
63
+ Then /^I should see the (\S+) in the (\S+)$/ do |element, containing_element|
64
+ response.should have_tag("##{containing_element} ##{element}")
65
+ end
66
+
67
+ Then /^I should see (\d+) (\S+) in the (\S+)$/ do |count, element, containing_element|
68
+ response.should have_tag("##{containing_element} .#{element.singularize}",:count => count.to_i)
69
+ end
70
+
71
+ Then /^I should see (\d+) to (\d+) (\S+) in the (\S+)$/ do |min, max, element, containing_element|
72
+ response.should have_tag("##{containing_element} .#{element.singularize}",min.to_i..max.to_i)
73
+ end
74
+
75
+ Then /^the (\S+) in the (\S+) should contain (a|an|the) (\S+)$/ do |middle_element, outer_element, a, inner_element|
76
+ response.should have_tag("##{outer_element} .#{middle_element} .#{inner_element}")
77
+ end
78
+
79
+ Then /^I should see the (\S+)$/ do |element_id|
80
+ response.should have_tag("##{element_id}")
81
+ end
82
+
83
+ Then /^I should see (a|an) (\S+)$/ do |a, element_class|
84
+ response.should have_tag(".#{element_class}")
85
+ end
86
+
87
+
88
+ #
89
+ # Forms
90
+ #
91
+ #
92
+ When /^I press "([^\"]*)"$/ do |button|
93
+ click_button(button)
94
+ end
95
+
22
96
  When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
23
97
  fill_in(field, :with => value)
24
98
  end
@@ -88,6 +162,10 @@ When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
88
162
  select_date(date, :from => date_label)
89
163
  end
90
164
 
165
+ When /^I choose "([^\"]*)"$/ do |field|
166
+ choose(field)
167
+ end
168
+
91
169
  When /^I check "([^\"]*)"$/ do |field|
92
170
  check(field)
93
171
  end
@@ -96,45 +174,10 @@ When /^I uncheck "([^\"]*)"$/ do |field|
96
174
  uncheck(field)
97
175
  end
98
176
 
99
- When /^I choose "([^\"]*)"$/ do |field|
100
- choose(field)
101
- end
102
-
103
177
  When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
104
178
  attach_file(field, path)
105
179
  end
106
180
 
107
- Then /^I should see "([^\"]*)"$/ do |text|
108
- response.should contain(text)
109
- end
110
-
111
- Then /^I should see "([^\"]*)" (\d+) times*$/ do |text, count|
112
- res = response.body
113
- (count.to_i - 1).times { res.sub!(/#{text}/, "")}
114
- res.should contain(text)
115
- res.sub(/#{text}/, "").should_not contain(text)
116
- end
117
-
118
-
119
- Then /^I should not see "([^\"]*)"$/ do |text|
120
- response.should_not contain(text)
121
- end
122
-
123
- Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
124
- field_labeled(field).value.should =~ /#{value}/
125
- end
126
-
127
- Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
128
- field_labeled(field).value.should_not =~ /#{value}/
129
- end
130
-
131
- Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
132
- field_labeled(label).should be_checked
133
- end
134
-
135
- Then /^I should be on (.+)$/ do |page_name|
136
- URI.parse(current_url).path.should == path_to(page_name)
137
- end
138
181
 
139
182
  # Steps that are generally useful and help encourage use of semantic
140
183
  # IDs and Class Names in your markup. In the steps below, a match following
@@ -152,30 +195,3 @@ Then /^I wait for ([0-9]+) seconds$/ do |delay|
152
195
  sleep delay.to_i
153
196
  end
154
197
 
155
- Then /^I should see a (\S+) in the (\S+)$/ do |element, containing_element|
156
- response.should have_tag("##{containing_element} .#{element}")
157
- end
158
-
159
- Then /^I should see the (\S+) in the (\S+)$/ do |element, containing_element|
160
- response.should have_tag("##{containing_element} ##{element}")
161
- end
162
-
163
- Then /^I should see (\d+) (\S+) in the (\S+)$/ do |count, element, containing_element|
164
- response.should have_tag("##{containing_element} .#{element.singularize}",:count => count.to_i)
165
- end
166
-
167
- Then /^I should see (\d+) to (\d+) (\S+) in the (\S+)$/ do |min, max, element, containing_element|
168
- response.should have_tag("##{containing_element} .#{element.singularize}",min.to_i..max.to_i)
169
- end
170
-
171
- Then /^the (\S+) in the (\S+) should contain (a|an|the) (\S+)$/ do |middle_element, outer_element, a, inner_element|
172
- response.should have_tag("##{outer_element} .#{middle_element} .#{inner_element}")
173
- end
174
-
175
- Then /^I should see the (\S+)$/ do |element_id|
176
- response.should have_tag("##{element_id}")
177
- end
178
-
179
- Then /^I should see (a|an) (\S+)$/ do |a, element_class|
180
- response.should have_tag(".#{element_class}")
181
- end
data/watircuke.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{watircuke}
5
- s.version = "0.2.3"
5
+ s.version = "0.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rich Downie", "Marcos Piccinini"]
9
- s.date = %q{2009-06-16}
9
+ s.date = %q{2009-06-17}
10
10
  s.email = %q{x@nofxx.com}
11
11
  s.extra_rdoc_files = [
12
12
  "README"
@@ -16,19 +16,9 @@ Gem::Specification.new do |s|
16
16
  "README",
17
17
  "Rakefile",
18
18
  "VERSION",
19
+ "cucumber.yml",
20
+ "features/ajax.feature",
19
21
  "features/sample.feature",
20
- "features/step_definitions/assertions.rb",
21
- "features/step_definitions/buttons.rb",
22
- "features/step_definitions/checkboxes.rb",
23
- "features/step_definitions/javascript.rb",
24
- "features/step_definitions/links.rb",
25
- "features/step_definitions/pages.rb",
26
- "features/step_definitions/radio_buttons.rb",
27
- "features/step_definitions/select_lists.rb",
28
- "features/step_definitions/sleep.rb",
29
- "features/step_definitions/spans.rb",
30
- "features/step_definitions/text_fields.rb",
31
- "features/step_definitions/urls.rb",
32
22
  "features/support/env.rb",
33
23
  "features/support/paths.rb",
34
24
  "lib/watircuke.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nofxx-watircuke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich Downie
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-06-16 00:00:00 -07:00
13
+ date: 2009-06-17 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -27,19 +27,9 @@ files:
27
27
  - README
28
28
  - Rakefile
29
29
  - VERSION
30
+ - cucumber.yml
31
+ - features/ajax.feature
30
32
  - features/sample.feature
31
- - features/step_definitions/assertions.rb
32
- - features/step_definitions/buttons.rb
33
- - features/step_definitions/checkboxes.rb
34
- - features/step_definitions/javascript.rb
35
- - features/step_definitions/links.rb
36
- - features/step_definitions/pages.rb
37
- - features/step_definitions/radio_buttons.rb
38
- - features/step_definitions/select_lists.rb
39
- - features/step_definitions/sleep.rb
40
- - features/step_definitions/spans.rb
41
- - features/step_definitions/text_fields.rb
42
- - features/step_definitions/urls.rb
43
33
  - features/support/env.rb
44
34
  - features/support/paths.rb
45
35
  - lib/watircuke.rb
@@ -1,23 +0,0 @@
1
- Given /I verify the page contains the text "(.*)"/ do |text|
2
- assert(@browser.contains_text(text))
3
- end
4
-
5
- Given /I verify the page does not contain the text "(.*)"/ do |text|
6
- assert_false(@browser.contains_text(text))
7
- end
8
-
9
- Given /I verify the page contains a div class "(.*)"/ do |byclass|
10
- assert(@browser.div(:class, byclass).exists?)
11
- end
12
-
13
- Given /I verify the page contains a div id "(.*)"/ do |id|
14
- assert(@browser.div(:id, id).exists?)
15
- end
16
-
17
- Given /I verify the page contains a link class "(.*)"/ do |byclass|
18
- assert(@browser.link(:class, byclass).exists?)
19
- end
20
-
21
- Given /I verify the page contains the image "(.*)"/ do |image|
22
- assert(@browser.image(:src, image).exists?)
23
- end
@@ -1,3 +0,0 @@
1
- Given /I click the "(.*)" button/ do |value|
2
- @browser.button(:value, value).click
3
- end
@@ -1,3 +0,0 @@
1
- Given /I click the "(.*)" checkbox/ do |id|
2
- @browser.checkbox(:id, id).click
3
- end
@@ -1,3 +0,0 @@
1
- Given /From the "(.*)" link I fire the "(.*)" event/ do |text, event|
2
- @browser.link(:text , text).fire_event(event)
3
- end
@@ -1,3 +0,0 @@
1
- Given /I click the "(.*)" link/ do |text|
2
- @browser.link(:text, text).click
3
- end
@@ -1,3 +0,0 @@
1
- Given /^I am on (.+)$/ do |page_name|
2
- @browser.goto(path_to(page_name))
3
- end
@@ -1,3 +0,0 @@
1
- Given /I click the "(.*)" radio button/ do |id|
2
- @browser.radio(:id, id).click
3
- end
@@ -1,3 +0,0 @@
1
- Given /I select "(.*)" from the select list "(.*)"/ do |value, id|
2
- @browser.select_list(:id, id).select(value)
3
- end
@@ -1,3 +0,0 @@
1
- Given /I wait "(.*)" seconds/ do |time|
2
- sleep time.to_i
3
- end
@@ -1,3 +0,0 @@
1
- Given /I click the "(.*)" span/ do |text|
2
- @browser.span(:text, text).click
3
- end
@@ -1,4 +0,0 @@
1
- Given /I fill in the text field "(.*)" with "(.*)"/ do |name, text|
2
- @browser.text_field(:name, name).set(text)
3
- end
4
-
@@ -1,3 +0,0 @@
1
- Given /I visit "(.*)"/ do |text|
2
- @browser.goto(@environment + text)
3
- end