mechanical-cuke 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,6 +13,10 @@ begin
13
13
  gem.add_runtime_dependency 'mechanize', '>= 1.0.0'
14
14
  gem.add_runtime_dependency "cucumber", ">= 0.8.5"
15
15
  gem.add_development_dependency "open4", ">= 0.9.6"
16
+ gem.add_development_dependency "cucumber-rails", ">= 0.2.4"
17
+ gem.add_development_dependency "mocha", ">= 0.9.8"
18
+ gem.add_development_dependency "launchy", ">= 0.3.3"
19
+ gem.add_development_dependency "sinatra", ">= 1.0"
16
20
  end
17
21
  Jeweler::GemcutterTasks.new
18
22
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
@@ -0,0 +1,12 @@
1
+ Feature: Missing Fields
2
+ In order to provide reliable tests
3
+ Steps referering to elements not found on a form should fail
4
+
5
+ Scenario: Failing Steps
6
+ Given I am on the blank form
7
+ When I fill in a nonexistent text field an error should be raised
8
+ When I select a nonexistent select field an error should be raised
9
+ When I choose a nonexistent radio button an error should be raised
10
+ When I check a nonexistent check box an error should be raised
11
+ When I press a nonexistent button an error should be raised
12
+ When I select a missing option from an existing select an error should be raised
@@ -0,0 +1,32 @@
1
+ When /^I (?:fill in|select|choose|check|press) a nonexistent (.+) an error should be raised$/ do |type|
2
+
3
+ case type
4
+ when "text field" then
5
+ assert_raise(RuntimeError) do
6
+ When %{I fill in "nonexistent" with "anything"}
7
+ end
8
+ when "select field" then
9
+ assert_raise(RuntimeError) do
10
+ When %{I select "anything" from "nonexistent"}
11
+ end
12
+ when "radio button" then
13
+ assert_raise(RuntimeError) do
14
+ When %{I choose "nonexistent"}
15
+ end
16
+ when "check box" then
17
+ assert_raise(RuntimeError) do
18
+ When %{I check "nonexistent"}
19
+ end
20
+ when "button" then
21
+ assert_raise(RuntimeError) do
22
+ When %{I press "nonexistent"}
23
+ end
24
+ else assert false
25
+ end
26
+ end
27
+
28
+ When /^I select a missing option from an existing select an error should be raised$/ do
29
+ assert_raise(RuntimeError) do
30
+ When %{I select "nonexistent" from "Exists"}
31
+ end
32
+ end
@@ -1,7 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
 
3
3
  require 'mechanical-cuke'
4
- require 'cucumber/web/tableish'
5
4
 
6
5
  require 'test/unit/assertions'
7
6
 
@@ -15,6 +15,8 @@ module NavigationHelpers
15
15
  '/upload'
16
16
  when /the protected page/
17
17
  '/protected'
18
+ when /the blank form/
19
+ '/blank_form'
18
20
  else
19
21
  raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
20
22
  "Now, go and add a mapping in #{__FILE__}"
@@ -6,8 +6,9 @@ When /^(?:|I )go to (.+)$/ do |page_name|
6
6
  get path_to(page_name)
7
7
  end
8
8
 
9
- When /^(?:|I )press "([^\"]*)"$/ do |name|
10
- button = form.submits.find{|f| f.name == name}
9
+ When /^(?:|I )press "([^\"]*)"$/ do |value|
10
+ button = form.submits.find{|f| f.value == value}
11
+ raise "Can't find button \"#{value}\"" if button.nil?
11
12
  form.click_button(button)
12
13
  end
13
14
 
@@ -36,17 +37,21 @@ end
36
37
  When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
37
38
  f = find_field(field)
38
39
  raise "Can't find field \"#{field}\"" if f.nil?
39
- f.option_with(:value => value).select
40
+ option = f.option_with(:value => value)
41
+ raise "Can't find option #{value} for \"#{field}\"" if option.nil?
42
+ option.select
40
43
  end
41
44
 
42
45
 
43
46
  When /^(?:|I )check "([^\"]*)"$/ do |field|
44
47
  cb = find_checkbox(field)
48
+ raise "Can't find check box \"#{field}\"" if cb.nil?
45
49
  cb.checked = true
46
50
  end
47
51
 
48
52
  When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
49
53
  cb = find_checkbox(field)
54
+ raise "Can't find check box \"#{field}\"" if cb.nil?
50
55
  cb.checked = false
51
56
  end
52
57
 
@@ -48,3 +48,7 @@ get '/protected' do
48
48
  end
49
49
  end
50
50
 
51
+ get '/blank_form' do
52
+ erb :blank_form
53
+ end
54
+
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Blank Form</title>
5
+ </head>
6
+ <body>
7
+ <form id="form_id" name="form_name" action="" method="POST">
8
+ <p>
9
+ <label for="select_id">Exists</label>
10
+ <select id="select_id" name="select">
11
+ <option></option>
12
+ <option>Option Exists</option>
13
+ </select>
14
+ </p>
15
+
16
+ </form>
17
+ </body>
18
+ </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mechanical-cuke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spike Ilacqua
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-08-19 00:00:00 -06:00
12
+ date: 2010-08-21 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,46 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.9.6
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: cucumber-rails
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.2.4
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 0.9.8
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: launchy
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 0.3.3
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: sinatra
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "1.0"
84
+ version:
45
85
  description: A Mechanize driver for Cucumber. Provides step definitions for driving web applications using Mechanize.
46
86
  email: spike@indra.com
47
87
  executables: []
@@ -58,8 +98,10 @@ files:
58
98
  - README.textile
59
99
  - Rakefile
60
100
  - VERSION
101
+ - features/missing_fields.feature
61
102
  - features/step_definitions/basic_auth_steps.rb
62
103
  - features/step_definitions/mechanical-cuke_steps.rb
104
+ - features/step_definitions/missing_field_steps.rb
63
105
  - features/step_definitions/table_steps.rb
64
106
  - features/support/env.rb
65
107
  - features/support/mocha.rb
@@ -71,6 +113,7 @@ files:
71
113
  - lib/mechanical-cuke/web_steps.rb
72
114
  - test/fixtures/hello.txt
73
115
  - test/fixtures/server/server.rb
116
+ - test/fixtures/server/views/blank_form.erb
74
117
  - test/fixtures/server/views/form.erb
75
118
  - test/fixtures/server/views/form_output.erb
76
119
  - test/fixtures/server/views/index.erb