forked from nofxx/watircuke
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gemify, just create a profile and require 'watircuke' or 'webratcuke'
This way we can have the same regex syntax from webrat on watir. (or how I failed trying to remove webrat_steps from the load path). But looks good to have the webrat steps as separate lib, not much DRY having it on each project here.
- Loading branch information
Showing
8 changed files
with
309 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.DS_Store | ||
pkg/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'rubygems' | ||
require 'rake' | ||
|
||
begin | ||
require 'jeweler' | ||
Jeweler::Tasks.new do |gem| | ||
gem.name = "watircuke" | ||
gem.summary = "Watir steps for cucumber" | ||
gem.email = "x@nofxx.com" | ||
gem.homepage = "http://github.com/nofxx/watircuke" | ||
gem.authors = ["Marcos Piccinini"] | ||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings | ||
end | ||
|
||
rescue LoadError | ||
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" | ||
end | ||
|
||
require 'spec/rake/spectask' | ||
Spec::Rake::SpecTask.new(:spec) do |spec| | ||
spec.libs << 'lib' << 'spec' | ||
spec.spec_files = FileList['spec/**/*_spec.rb'] | ||
end | ||
|
||
Spec::Rake::SpecTask.new(:rcov) do |spec| | ||
spec.libs << 'lib' << 'spec' | ||
spec.pattern = 'spec/**/*_spec.rb' | ||
spec.rcov = true | ||
end | ||
|
||
|
||
task :default => :spec | ||
|
||
require 'rake/rdoctask' | ||
Rake::RDocTask.new do |rdoc| | ||
if File.exist?('VERSION.yml') | ||
config = YAML.load(File.read('VERSION.yml')) | ||
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}" | ||
else | ||
version = "" | ||
end | ||
|
||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = "watircuke #{version}" | ||
rdoc.rdoc_files.include('README*') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require "cucumber" | ||
require File.join(File.dirname(__FILE__), '..', 'features', 'support', 'env') | ||
Dir[File.join(File.dirname(__FILE__), '..', 'features', 'step_definitions', '*rb')].each { |file| require file } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
# require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) | ||
|
||
# Commonly used webrat steps | ||
# http://github.com/brynary/webrat | ||
|
||
Given /^I am on (.+)$/ do |page_name| | ||
visit path_to(page_name) | ||
end | ||
|
||
When /^I go to (.+)$/ do |page_name| | ||
visit path_to(page_name) | ||
end | ||
|
||
When /^I press "([^\"]*)"$/ do |button| | ||
click_button(button) | ||
end | ||
|
||
When /^I follow "([^\"]*)"$/ do |link| | ||
click_link(link) | ||
end | ||
|
||
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| | ||
fill_in(field, :with => value) | ||
end | ||
|
||
When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field| | ||
select(value, :from => field) | ||
end | ||
|
||
# Use this step in conjunction with Rail's datetime_select helper. For example: | ||
# When I select "December 25, 2008 10:00" as the date and time | ||
When /^I select "([^\"]*)" as the date and time$/ do |time| | ||
select_datetime(time) | ||
end | ||
|
||
When /^I (press|follow|check|uncheck|choose) "([^\"]*)" for (.*) whose (.*) is "([^\"]*)"$/ do |action, whatyouclick, class_name, var_name, value| | ||
id = var_name == "id" ? value : eval("\"#{class_name}\".classify.constantize.find_by_#{var_name}(\"#{value}\").id.to_s") | ||
within("tr[id=row_#{class_name}_#{id}]") do | ||
case action | ||
when "press" then click_button(whatyouclick) | ||
when "follow" then click_link(whatyouclick) | ||
when "check" then check(whatyouclick) | ||
when "uncheck" then uncheck(whatyouclick) | ||
when "choose" then uncheck(whatyouclick) | ||
end | ||
end | ||
end | ||
|
||
|
||
# Use this step when using multiple datetime_select helpers on a page or | ||
# you want to specify which datetime to select. Given the following view: | ||
# <%= f.label :preferred %><br /> | ||
# <%= f.datetime_select :preferred %> | ||
# <%= f.label :alternative %><br /> | ||
# <%= f.datetime_select :alternative %> | ||
# The following steps would fill out the form: | ||
# When I select "November 23, 2004 11:20" as the "Preferred" date and time | ||
# And I select "November 25, 2004 10:30" as the "Alternative" date and time | ||
When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label| | ||
select_datetime(datetime, :from => datetime_label) | ||
end | ||
|
||
# Use this step in conjunction with Rail's time_select helper. For example: | ||
# When I select "2:20PM" as the time | ||
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat | ||
# will convert the 2:20PM to 14:20 and then select it. | ||
When /^I select "([^\"]*)" as the time$/ do |time| | ||
select_time(time) | ||
end | ||
|
||
# Use this step when using multiple time_select helpers on a page or you want to | ||
# specify the name of the time on the form. For example: | ||
# When I select "7:30AM" as the "Gym" time | ||
When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label| | ||
select_time(time, :from => time_label) | ||
end | ||
|
||
# Use this step in conjunction with Rail's date_select helper. For example: | ||
# When I select "February 20, 1981" as the date | ||
When /^I select "([^\"]*)" as the date$/ do |date| | ||
select_date(date) | ||
end | ||
|
||
# Use this step when using multiple date_select helpers on one page or | ||
# you want to specify the name of the date on the form. For example: | ||
# When I select "April 26, 1982" as the "Date of Birth" date | ||
When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label| | ||
select_date(date, :from => date_label) | ||
end | ||
|
||
When /^I check "([^\"]*)"$/ do |field| | ||
check(field) | ||
end | ||
|
||
When /^I uncheck "([^\"]*)"$/ do |field| | ||
uncheck(field) | ||
end | ||
|
||
When /^I choose "([^\"]*)"$/ do |field| | ||
choose(field) | ||
end | ||
|
||
When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field| | ||
attach_file(field, path) | ||
end | ||
|
||
Then /^I should see "([^\"]*)"$/ do |text| | ||
response.should contain(text) | ||
end | ||
|
||
Then /^I should see "([^\"]*)" (\d+) times*$/ do |text, count| | ||
res = response.body | ||
(count.to_i - 1).times { res.sub!(/#{text}/, "")} | ||
res.should contain(text) | ||
res.sub(/#{text}/, "").should_not contain(text) | ||
end | ||
|
||
|
||
Then /^I should not see "([^\"]*)"$/ do |text| | ||
response.should_not contain(text) | ||
end | ||
|
||
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value| | ||
field_labeled(field).value.should =~ /#{value}/ | ||
end | ||
|
||
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value| | ||
field_labeled(field).value.should_not =~ /#{value}/ | ||
end | ||
|
||
Then /^the "([^\"]*)" checkbox should be checked$/ do |label| | ||
field_labeled(label).should be_checked | ||
end | ||
|
||
Then /^I should be on (.+)$/ do |page_name| | ||
URI.parse(current_url).path.should == path_to(page_name) | ||
end | ||
|
||
# Steps that are generally useful and help encourage use of semantic | ||
# IDs and Class Names in your markup. In the steps below, a match following | ||
# "the" will verify the presences of an element with a given ID while a match following | ||
# "a" or "an" will verify the presence an element of a given class. | ||
Then /^I debug$/ do | ||
debugger | ||
end | ||
|
||
Then /^save_and_open_page$/ do | ||
save_and_open_page | ||
end | ||
|
||
Then /^I wait for ([0-9]+) seconds$/ do |delay| | ||
sleep delay.to_i | ||
end | ||
|
||
Then /^I should see a (\S+) in the (\S+)$/ do |element, containing_element| | ||
response.should have_tag("##{containing_element} .#{element}") | ||
end | ||
|
||
Then /^I should see the (\S+) in the (\S+)$/ do |element, containing_element| | ||
response.should have_tag("##{containing_element} ##{element}") | ||
end | ||
|
||
Then /^I should see (\d+) (\S+) in the (\S+)$/ do |count, element, containing_element| | ||
response.should have_tag("##{containing_element} .#{element.singularize}",:count => count.to_i) | ||
end | ||
|
||
Then /^I should see (\d+) to (\d+) (\S+) in the (\S+)$/ do |min, max, element, containing_element| | ||
response.should have_tag("##{containing_element} .#{element.singularize}",min.to_i..max.to_i) | ||
end | ||
|
||
Then /^the (\S+) in the (\S+) should contain (a|an|the) (\S+)$/ do |middle_element, outer_element, a, inner_element| | ||
response.should have_tag("##{outer_element} .#{middle_element} .#{inner_element}") | ||
end | ||
|
||
Then /^I should see the (\S+)$/ do |element_id| | ||
response.should have_tag("##{element_id}") | ||
end | ||
|
||
Then /^I should see (a|an) (\S+)$/ do |a, element_class| | ||
response.should have_tag(".#{element_class}") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'rubygems' | ||
require 'spec' | ||
|
||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require 'watircuke' | ||
|
||
Spec::Runner.configure do |config| | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | ||
|
||
describe "Watircuke" do | ||
it "should open ffox" do | ||
puts "Opening ffox!" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{watircuke} | ||
s.version = "0.2.0" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Marcos Piccinini"] | ||
s.date = %q{2009-06-16} | ||
s.email = %q{x@nofxx.com} | ||
s.extra_rdoc_files = [ | ||
"README" | ||
] | ||
s.files = [ | ||
".gitignore", | ||
"README", | ||
"Rakefile", | ||
"VERSION", | ||
"features/sample.feature", | ||
"features/step_definitions/assertions.rb", | ||
"features/step_definitions/buttons.rb", | ||
"features/step_definitions/checkboxes.rb", | ||
"features/step_definitions/javascript.rb", | ||
"features/step_definitions/links.rb", | ||
"features/step_definitions/pages.rb", | ||
"features/step_definitions/radio_buttons.rb", | ||
"features/step_definitions/select_lists.rb", | ||
"features/step_definitions/sleep.rb", | ||
"features/step_definitions/spans.rb", | ||
"features/step_definitions/text_fields.rb", | ||
"features/step_definitions/urls.rb", | ||
"features/support/env.rb", | ||
"features/support/paths.rb", | ||
"lib/watircuke.rb", | ||
"lib/webratcuke.rb", | ||
"spec/spec_helper.rb", | ||
"spec/watircuke_spec.rb" | ||
] | ||
s.homepage = %q{http://github.com/nofxx/watircuke} | ||
s.rdoc_options = ["--charset=UTF-8"] | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.3.4} | ||
s.summary = %q{Watir steps for cucumber} | ||
s.test_files = [ | ||
"spec/watircuke_spec.rb", | ||
"spec/spec_helper.rb" | ||
] | ||
|
||
if s.respond_to? :specification_version then | ||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then | ||
else | ||
end | ||
else | ||
end | ||
end |