mechanical-cuke 0.1.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/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +22 -0
- data/README.textile +119 -0
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/features/step_definitions/mechanical-cuke_steps.rb +0 -0
- data/features/support/env.rb +24 -0
- data/features/support/mocha.rb +17 -0
- data/features/support/paths.rb +19 -0
- data/features/web_steps.feature +54 -0
- data/lib/mechanical-cuke/save_and_open.rb +22 -0
- data/lib/mechanical-cuke/web_steps.rb +95 -0
- data/lib/mechanical-cuke.rb +66 -0
- data/test/fixtures/server/server.rb +20 -0
- data/test/fixtures/server/views/form.erb +51 -0
- data/test/fixtures/server/views/form_output.erb +36 -0
- data/test/fixtures/server/views/index.erb +14 -0
- metadata +102 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010 Joseph A. Ilacqua, Jr
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
h1. mechanical-cuke
|
2
|
+
|
3
|
+
mechanical-cuke re-implements the Cucumber step definitions provided
|
4
|
+
by cucumber-rails in web_steps.rb in Mechanize. This allows Cucumber
|
5
|
+
features to be written for any site by running the tests over HTTP.
|
6
|
+
|
7
|
+
h2. Rational
|
8
|
+
|
9
|
+
Webrat and Capybara both can drive tests over HTML. However, Webrat's
|
10
|
+
Mechanize support is limited (doesn't work with multipart forms, can't
|
11
|
+
submit empty form fields, no support for basis auth). Capybara drives
|
12
|
+
tests over HTTP using browsers, excellent for testing Javascript, but
|
13
|
+
slow for test that only involve HTML.
|
14
|
+
|
15
|
+
h2. Usage
|
16
|
+
|
17
|
+
Add:
|
18
|
+
|
19
|
+
require 'mechanical-cuke'
|
20
|
+
|
21
|
+
to features/support/env.rb
|
22
|
+
|
23
|
+
In features/support/paths.rb you will need to make sure you are
|
24
|
+
returning the full URL. The simplest way to do this is to add 'URL' +
|
25
|
+
before the case statement in the path_to function e.g.:
|
26
|
+
|
27
|
+
bc. def path_to(page_name)
|
28
|
+
case page_name
|
29
|
+
|
30
|
+
becomes
|
31
|
+
|
32
|
+
bc. def path_to(page_name)
|
33
|
+
'http://localhost:3000' +
|
34
|
+
case page_name
|
35
|
+
|
36
|
+
h2. Steps Provided
|
37
|
+
|
38
|
+
bc. Given am on path
|
39
|
+
When I go to path
|
40
|
+
|
41
|
+
GET the page at _path_ and sets it to the current page for follow steps.
|
42
|
+
|
43
|
+
bc. When I press "button"
|
44
|
+
|
45
|
+
Press button with label "_button_". If the button is in a form
|
46
|
+
|
47
|
+
bc. When I follow "link"
|
48
|
+
|
49
|
+
Click the link with text "_link_".
|
50
|
+
|
51
|
+
bc. When I fill in "field" with "value"
|
52
|
+
When I fill in "value" for "field"
|
53
|
+
|
54
|
+
Fill in the text field, password field, or text area _field_ with
|
55
|
+
_value_. _field_ can be the id or name of the field, or the text
|
56
|
+
within the label for the field.
|
57
|
+
|
58
|
+
bc. When I fill in the following:
|
59
|
+
|
60
|
+
Takes a table of fields and values of the form:
|
61
|
+
|
62
|
+
bc. When I fill in the following:
|
63
|
+
| Account Number | 5002 |
|
64
|
+
| Expiry date | 2009-11-01 |
|
65
|
+
| Note | Nice guy |
|
66
|
+
|
67
|
+
|
68
|
+
bc. When I select "value" from "field"
|
69
|
+
|
70
|
+
Selects the option with _value_ from select list _field_. _field_ can
|
71
|
+
be the id or name of the field, or the text within the label for the
|
72
|
+
field.
|
73
|
+
|
74
|
+
bc. When I check "field"
|
75
|
+
When I uncheck "field"
|
76
|
+
|
77
|
+
Check or uncheck "_field_". PENDING
|
78
|
+
|
79
|
+
bc. When I choose "field"
|
80
|
+
|
81
|
+
Checks radio button _field_. _field_ can be the id or the text within
|
82
|
+
the label for the field; the field name would be ambiguous.
|
83
|
+
|
84
|
+
When I attach the file "path" to "field"
|
85
|
+
|
86
|
+
Attach the file in _path_ to the file field _field_. PENDING
|
87
|
+
|
88
|
+
bc. Then I should see "text"
|
89
|
+
Then I should see /regexp/
|
90
|
+
|
91
|
+
The body of the page should contain _text_ or _regexp_.
|
92
|
+
|
93
|
+
bc. Then I should not see "text"
|
94
|
+
Then I should not see /regexp/
|
95
|
+
|
96
|
+
The body of the page should *not* contain _text_ or _regexp_.
|
97
|
+
|
98
|
+
bc. Then the "field" field should contain "value"
|
99
|
+
Then the "field" field should not contain "value"
|
100
|
+
|
101
|
+
The value _field_ should be (or not be) _value_. PENDING
|
102
|
+
|
103
|
+
bc. Then the "_field_" checkbox should be checked
|
104
|
+
Then the "_field_" checkbox not should be checked
|
105
|
+
|
106
|
+
The checkbox _field_ should be (or not be) checked. PENDING
|
107
|
+
|
108
|
+
bc. Then I should be on _path_
|
109
|
+
|
110
|
+
The path/uri of the current page should be _path_.
|
111
|
+
|
112
|
+
bc. Then show me the page
|
113
|
+
|
114
|
+
Save the current page and open in the default browser.
|
115
|
+
|
116
|
+
h2. Authors
|
117
|
+
|
118
|
+
Spike Ilacqua
|
119
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "mechanical-cuke"
|
8
|
+
gem.summary = %Q{A Mechanize driver for Cucumber}
|
9
|
+
gem.description = %Q{A Mechanize driver for Cucumber. Provides step definitions for driving web applications using Mechanize.}
|
10
|
+
gem.email = "spike@indra.com"
|
11
|
+
gem.homepage = "http://github.com/spikex/mechanical-cuke"
|
12
|
+
gem.authors = ["Spike Ilacqua"]
|
13
|
+
gem.add_runtime_dependency 'mechanize', '>= 1.0.0'
|
14
|
+
gem.add_runtime_dependency "cucumber", ">= 0.8.5"
|
15
|
+
gem.add_development_dependency "open4", ">= 0.9.6"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
begin
|
45
|
+
require 'cucumber/rake/task'
|
46
|
+
Cucumber::Rake::Task.new(:cucumber)
|
47
|
+
|
48
|
+
task :cucumber => :check_dependencies
|
49
|
+
rescue LoadError
|
50
|
+
task :cucumber do
|
51
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
task :default => :cucumber
|
56
|
+
|
57
|
+
require 'rake/rdoctask'
|
58
|
+
Rake::RDocTask.new do |rdoc|
|
59
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
60
|
+
|
61
|
+
rdoc.rdoc_dir = 'rdoc'
|
62
|
+
rdoc.title = "mechanical-cuke #{version}"
|
63
|
+
rdoc.rdoc_files.include('README*')
|
64
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
65
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
+
|
3
|
+
require 'mechanical-cuke'
|
4
|
+
|
5
|
+
require 'test/unit/assertions'
|
6
|
+
|
7
|
+
require 'open4'
|
8
|
+
|
9
|
+
World(Test::Unit::Assertions)
|
10
|
+
|
11
|
+
Before do
|
12
|
+
@server ||= {}
|
13
|
+
server_app = File.dirname(__FILE__) + '/../../test/fixtures/server/server.rb'
|
14
|
+
@server[:pid], @server[:stdin], @server[:stdout], @server[:stderr] =
|
15
|
+
Open4::popen4 server_app
|
16
|
+
status = @server[:stdout].readline
|
17
|
+
raise "Server startup failed" if status !~ /Sinatra.* has taken the stage on/
|
18
|
+
end
|
19
|
+
|
20
|
+
After do
|
21
|
+
if @server[:pid]
|
22
|
+
Process.kill('HUP', @server[:pid])
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mocha'
|
2
|
+
require 'launchy'
|
3
|
+
|
4
|
+
World(Mocha::API)
|
5
|
+
|
6
|
+
Before('@mock_launchy') do
|
7
|
+
Launchy::Browser.expects(:run).returns(true)
|
8
|
+
# TODO: Mock saving file...
|
9
|
+
end
|
10
|
+
|
11
|
+
After('@mock_launchy') do
|
12
|
+
begin
|
13
|
+
mocha_verify
|
14
|
+
ensure
|
15
|
+
mocha_teardown
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
def path_to(page_name)
|
3
|
+
|
4
|
+
'http://localhost:4567' +
|
5
|
+
|
6
|
+
case page_name
|
7
|
+
|
8
|
+
when /the index page/
|
9
|
+
'/'
|
10
|
+
when /the form page/
|
11
|
+
'/form'
|
12
|
+
else
|
13
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
14
|
+
"Now, go and add a mapping in #{__FILE__}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Feature: Using Mechanize
|
2
|
+
In order to test web sites over HTTP
|
3
|
+
I want to be able to interacted with sites using Mechanize
|
4
|
+
|
5
|
+
Scenario: Navigation Steps
|
6
|
+
Given I am on the index page
|
7
|
+
Then I should be on the index page
|
8
|
+
When I go to the index page
|
9
|
+
Then I should be on the index page
|
10
|
+
When I follow "Form Link"
|
11
|
+
Then I should be on the form page
|
12
|
+
|
13
|
+
Scenario: Should See Steps
|
14
|
+
Given I am on the index page
|
15
|
+
Then I should see "Hello World!"
|
16
|
+
And I should see /Hel+o.World./
|
17
|
+
But I should not see "Oogy Boogy!"
|
18
|
+
And I should not see /[Oo]+gy Bo+gy/
|
19
|
+
|
20
|
+
Scenario: Form Steps
|
21
|
+
Given I am on the form page
|
22
|
+
When I fill in "Field by Label" with "Label Field"
|
23
|
+
And I fill in "Name Field" for "field_by_name"
|
24
|
+
And I fill in "field_by_id_id" with "ID Field"
|
25
|
+
And I fill in "Text Area by Label" with "Text Area Text"
|
26
|
+
And I fill in "Password by Label" with "Password Text"
|
27
|
+
And I select "Option Two" from "Select by Name"
|
28
|
+
And I choose "Radio Button One"
|
29
|
+
And I press "Submit"
|
30
|
+
Then I should see "Label Field"
|
31
|
+
And I should see "Name Field"
|
32
|
+
And I should see "Option Two"
|
33
|
+
And I should see "Text Area Text"
|
34
|
+
And I should see "Password Text"
|
35
|
+
And I should see "Radio Button One Chosen"
|
36
|
+
But I should not see "Option One"
|
37
|
+
And I should not see "Radio Button Two Chosen"
|
38
|
+
|
39
|
+
Scenario: Form Table Steps
|
40
|
+
Given I am on the form page
|
41
|
+
When I fill in the following:
|
42
|
+
| Field by Label | Labeled |
|
43
|
+
| field_by_name | Named |
|
44
|
+
| field_by_id_id | ID-ed |
|
45
|
+
And I press "Submit"
|
46
|
+
Then I should see "Labeled"
|
47
|
+
And I should see "Named"
|
48
|
+
And I should see "ID-ed"
|
49
|
+
|
50
|
+
@mock_launchy
|
51
|
+
Scenario: Navigation Steps
|
52
|
+
Given I am on the index page
|
53
|
+
Then show me the page
|
54
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
def save_page(page)
|
4
|
+
return nil unless File.directory?(directory = save_pages_dir)
|
5
|
+
filename = "#{directory}/mechanize-#{Time.now.to_i}.html"
|
6
|
+
page.save_as(filename)
|
7
|
+
filename
|
8
|
+
end
|
9
|
+
|
10
|
+
def open_in_browser(path) # :nodoc
|
11
|
+
require "launchy"
|
12
|
+
Launchy::Browser.run(path)
|
13
|
+
rescue LoadError
|
14
|
+
warn "Sorry, you need to install launchy to open pages: `gem install launchy`"
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def save_pages_dir
|
20
|
+
tmp_dir = Pathname.new(Dir.pwd).join("tmp")
|
21
|
+
tmp_dir.exist? ? tmp_dir : Dir.pwd
|
22
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
2
|
+
get path_to(page_name)
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
6
|
+
get path_to(page_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^(?:|I )press "([^\"]*)"$/ do |name|
|
10
|
+
button = form.submits.find{|f| f.name == name}
|
11
|
+
form.click_button(button)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^(?:|I )follow "([^\"]*)"$/ do |link|
|
15
|
+
current_page.link_with(:text => link).click
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
19
|
+
f = find_field(field)
|
20
|
+
raise "Can't find field \"#{field}\"" if f.nil?
|
21
|
+
f.value = value
|
22
|
+
end
|
23
|
+
|
24
|
+
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
|
25
|
+
f = find_field(field)
|
26
|
+
raise "Can't find field \"#{field}\"" if f.nil?
|
27
|
+
f.value = value
|
28
|
+
end
|
29
|
+
|
30
|
+
When /^(?:|I )fill in the following:$/ do | fields|
|
31
|
+
fields.rows_hash.each do |name, value|
|
32
|
+
When %{I fill in "#{name}" with "#{value}"}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
37
|
+
f = find_field(field)
|
38
|
+
raise "Can't find field \"#{field}\"" if f.nil?
|
39
|
+
f.option_with(:value => value).select
|
40
|
+
end
|
41
|
+
|
42
|
+
When /^(?:|I )choose "([^\"]*)"$/ do |field|
|
43
|
+
r = find_radiobutton(field)
|
44
|
+
raise "Can't find radio button \"#{field}\"" if r.nil?
|
45
|
+
r.check
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^(?:|I )should see "([^\"]*)"$/ do |text|
|
49
|
+
if defined?(Spec::Rails::Matchers)
|
50
|
+
response.should contain(text)
|
51
|
+
else
|
52
|
+
assert current_page.body.include?(text)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
58
|
+
regexp = Regexp.new(regexp)
|
59
|
+
if defined?(Spec::Rails::Matchers)
|
60
|
+
page.should have_xpath('//*', :text => regexp)
|
61
|
+
else
|
62
|
+
assert_match regexp, current_page.body
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
67
|
+
regexp = Regexp.new(regexp)
|
68
|
+
if defined?(Spec::Rails::Matchers)
|
69
|
+
page.should have_not_xpath('//*', :text => regexp)
|
70
|
+
else
|
71
|
+
assert_no_match regexp, current_page.body
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
But /^(?:|I )should not see "([^\"]*)"$/ do |text|
|
76
|
+
if defined?(Spec::Rails::Matchers)
|
77
|
+
response.should_not contain(text)
|
78
|
+
else
|
79
|
+
assert !current_page.body.include?(text)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
84
|
+
current_path = current_page.uri.to_s
|
85
|
+
if defined?(Spec::Rails::Matchers)
|
86
|
+
current_path.should == path_to(page_name)
|
87
|
+
else
|
88
|
+
assert_equal path_to(page_name), current_path
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
Then /^show me the page$/ do
|
93
|
+
filename = save_page(current_page)
|
94
|
+
open_in_browser(filename) unless filename.nil?
|
95
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'mechanical-cuke/web_steps'
|
3
|
+
require 'mechanical-cuke/save_and_open'
|
4
|
+
|
5
|
+
module MechanicalCuke
|
6
|
+
class << self
|
7
|
+
attr_accessor :save_and_open_page_path
|
8
|
+
def configure
|
9
|
+
yield self
|
10
|
+
end
|
11
|
+
# TODO: try def get blah blah
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
World do
|
16
|
+
session = Mechanize.new
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def form
|
22
|
+
current_page.forms.first
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_by_id(id)
|
26
|
+
node = current_page.search("##{id}")
|
27
|
+
node.first
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_by_label(field)
|
31
|
+
label = current_page.labels.find { |l| l.text == field }
|
32
|
+
!label.nil? ? label.for.first : nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_field(field)
|
36
|
+
# Search by id
|
37
|
+
if (node = find_by_id(field))
|
38
|
+
return form.field_with(:node => node)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Then by name
|
42
|
+
if (f = form.field_with(:name => field))
|
43
|
+
return f
|
44
|
+
end
|
45
|
+
|
46
|
+
# And finally by label
|
47
|
+
if (node = find_by_label(field))
|
48
|
+
return form.field_with(:node => node)
|
49
|
+
end
|
50
|
+
|
51
|
+
return nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_radiobutton(field)
|
55
|
+
# Search by id
|
56
|
+
if (node = find_by_id(field))
|
57
|
+
return form.radiobutton_with(:node => node.first)
|
58
|
+
end
|
59
|
+
|
60
|
+
# And by label
|
61
|
+
if (node = find_by_label(field))
|
62
|
+
return form.radiobutton_with(:node => node)
|
63
|
+
end
|
64
|
+
|
65
|
+
return nil
|
66
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'sinatra'
|
5
|
+
require 'erb'
|
6
|
+
|
7
|
+
disable :logging
|
8
|
+
STDOUT.sync = true
|
9
|
+
|
10
|
+
get '/' do
|
11
|
+
erb :index
|
12
|
+
end
|
13
|
+
|
14
|
+
get '/form' do
|
15
|
+
erb :form
|
16
|
+
end
|
17
|
+
|
18
|
+
post '/form' do
|
19
|
+
erb :form_output
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Form</title>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<form id="form_id" name="form_name" action="" method="POST">
|
8
|
+
<p>
|
9
|
+
<label for="field_by_label_id">Field by Label</label>
|
10
|
+
<input type="text" id="field_by_label_id" name="field_by_label">
|
11
|
+
</p>
|
12
|
+
<p>
|
13
|
+
<label for="field_by_name_id">Field by Name</label>
|
14
|
+
<input type="text" id="field_by_name_id" name="field_by_name">
|
15
|
+
</p>
|
16
|
+
<p>
|
17
|
+
<label for="field_by_id_id">Field by ID</label>
|
18
|
+
<input type="text" id="field_by_id_id" name="field_by_id">
|
19
|
+
</p>
|
20
|
+
<p>
|
21
|
+
<label for="password_by_label_id">Password by Label</label>
|
22
|
+
<input type="password" id="password_by_label_id" name="password_by_label">
|
23
|
+
</p>
|
24
|
+
<p>
|
25
|
+
<label for="text_area_by_label_id">Text Area by Label</label>
|
26
|
+
<input type="text" id="text_area_by_label_id" name="text_area_by_label">
|
27
|
+
</p>
|
28
|
+
<p>
|
29
|
+
<label for="select_by_name_id">Select by Name</label>
|
30
|
+
<select id="select_by_name_id" name="select_by_name">
|
31
|
+
<option></option>
|
32
|
+
<option>Option One</option>
|
33
|
+
<option>Option Two</option>
|
34
|
+
<option>Option Three</option>
|
35
|
+
</select>
|
36
|
+
</p>
|
37
|
+
<p>
|
38
|
+
<label>Radio Button by Name</label>
|
39
|
+
<label for="radio_button_one_id">Radio Button One</label>
|
40
|
+
<input type="radio" id="radio_button_one_id"
|
41
|
+
name="radio_button" value="Radio Button One Chosen">
|
42
|
+
<label for="radio_button_two_id">Radio Button Two</label>
|
43
|
+
<input type="radio" id="radio_button_two_id" name="radio_button" value="Radio Button Two Chosen" checked>
|
44
|
+
</p>
|
45
|
+
|
46
|
+
<p>
|
47
|
+
<input type="submit" value="Submit">
|
48
|
+
</p>
|
49
|
+
</form>
|
50
|
+
</body>
|
51
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Form Output</title>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<p>
|
8
|
+
<label>Field by Label</label>
|
9
|
+
<%= params[:field_by_label] %>
|
10
|
+
</p>
|
11
|
+
<p>
|
12
|
+
<label>Field by Name</label>
|
13
|
+
<%= params[:field_by_name] %>
|
14
|
+
</p>
|
15
|
+
<p>
|
16
|
+
<label>Field by ID</label>
|
17
|
+
<%= params[:field_by_id] %>
|
18
|
+
</p>
|
19
|
+
<p>
|
20
|
+
<label>Password by Label</label>
|
21
|
+
<%= params[:password_by_label] %>
|
22
|
+
</p>
|
23
|
+
<p>
|
24
|
+
<label>Text Area by Label</label>
|
25
|
+
<%= params[:text_area_by_label] %>
|
26
|
+
</p>
|
27
|
+
<p>
|
28
|
+
<label>Select by Name</label>
|
29
|
+
<%= params[:select_by_name] %>
|
30
|
+
</p>
|
31
|
+
<p>
|
32
|
+
<label>Radio Button by Name</label>
|
33
|
+
<%= params[:radio_button] %>
|
34
|
+
</p>
|
35
|
+
</body>
|
36
|
+
</html>
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mechanical-cuke
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Spike Ilacqua
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-08-18 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mechanize
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cucumber
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.5
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: open4
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.9.6
|
44
|
+
version:
|
45
|
+
description: A Mechanize driver for Cucumber. Provides step definitions for driving web applications using Mechanize.
|
46
|
+
email: spike@indra.com
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.textile
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE
|
58
|
+
- README.textile
|
59
|
+
- Rakefile
|
60
|
+
- VERSION
|
61
|
+
- features/step_definitions/mechanical-cuke_steps.rb
|
62
|
+
- features/support/env.rb
|
63
|
+
- features/support/mocha.rb
|
64
|
+
- features/support/paths.rb
|
65
|
+
- features/web_steps.feature
|
66
|
+
- lib/mechanical-cuke.rb
|
67
|
+
- lib/mechanical-cuke/save_and_open.rb
|
68
|
+
- lib/mechanical-cuke/web_steps.rb
|
69
|
+
- test/fixtures/server/server.rb
|
70
|
+
- test/fixtures/server/views/form.erb
|
71
|
+
- test/fixtures/server/views/form_output.erb
|
72
|
+
- test/fixtures/server/views/index.erb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/spikex/mechanical-cuke
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --charset=UTF-8
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
87
|
+
version:
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
93
|
+
version:
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.3.5
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: A Mechanize driver for Cucumber
|
101
|
+
test_files:
|
102
|
+
- test/fixtures/server/server.rb
|