jsmestad-watircuke 0.3.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.
- data/.gitignore +2 -0
- data/README.rdoc +66 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/cucumber.yml +2 -0
- data/features/ajax.feature +15 -0
- data/features/sample.feature +11 -0
- data/features/search.feature +6 -0
- data/features/step_definitions/search.rb +11 -0
- data/features/support/env.rb +19 -0
- data/features/support/paths.rb +25 -0
- data/lib/watircuke.rb +147 -0
- data/lib/webratcuke.rb +197 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/watircuke_spec.rb +7 -0
- data/watircuke.gemspec +51 -0
- metadata +70 -0
    
        data/.gitignore
    ADDED
    
    
    
        data/README.rdoc
    ADDED
    
    | @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            = Watircuke
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Webrat & Watir Family common (and some cool) steps as a gem.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
            == Install
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            Cucumber::   http://wiki.github.com/aslakhellesoy/cucumber/install
         | 
| 9 | 
            +
            Watir ~ Firewatir ~ Safariwatir::  http://wtr.rubyforge.org/install.html
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
            == Use
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            * Remove step_definitions/webrat_steps.rb if you have it.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            * In the scenarios you want to run watir, just add the @watir tag before.
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            * Run `cucumber` for webrat and `cucumber -p watir` for some Watir =D
         | 
| 19 | 
            +
             | 
| 20 | 
            +
             | 
| 21 | 
            +
            == Rails Sample
         | 
| 22 | 
            +
             | 
| 23 | 
            +
             | 
| 24 | 
            +
            cucumber.yml
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                default: -r features/support/env.rb -r features/support/webrat.rb -r features/step_definitions
         | 
| 27 | 
            +
                watir:   -r features/support/env.rb -r features/support/watir.rb -r features/step_definitions -t watir
         | 
| 28 | 
            +
             | 
| 29 | 
            +
             | 
| 30 | 
            +
            support/watir.rb
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                require 'watircuke'
         | 
| 33 | 
            +
                Before do
         | 
| 34 | 
            +
                  @environment = "http://localhost:3000/
         | 
| 35 | 
            +
                  sleep 1
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
                # optional
         | 
| 38 | 
            +
                # at_exit do
         | 
| 39 | 
            +
                #   @browser.close
         | 
| 40 | 
            +
                # end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
             | 
| 43 | 
            +
            support/webrat.rb
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                require 'webrat'
         | 
| 46 | 
            +
                Webrat.configure do |config|
         | 
| 47 | 
            +
                  config.mode = :rails
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
                require 'cucumber/rails/rspec'
         | 
| 50 | 
            +
                require 'webrat/core/matchers'
         | 
| 51 | 
            +
                require 'webratcuke'
         | 
| 52 | 
            +
             | 
| 53 | 
            +
             | 
| 54 | 
            +
            support/env.rb
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                ENV["RAILS_ENV"] ||= "cucumber"
         | 
| 57 | 
            +
                require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
         | 
| 58 | 
            +
                require 'cucumber/rails/world'
         | 
| 59 | 
            +
                require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
         | 
| 60 | 
            +
                Cucumber::Rails.use_transactional_fixtures
         | 
| 61 | 
            +
                Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
         | 
| 62 | 
            +
             | 
| 63 | 
            +
             | 
| 64 | 
            +
            == ABOUT
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            **cukewatir maximizes the Gherkin speak and minimizes the Watir code.
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'rake'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            begin
         | 
| 5 | 
            +
              require 'jeweler'
         | 
| 6 | 
            +
              Jeweler::Tasks.new do |gem|
         | 
| 7 | 
            +
                gem.name = "watircuke"
         | 
| 8 | 
            +
                gem.summary = "Watir steps for cucumber"
         | 
| 9 | 
            +
                gem.email = "x@nofxx.com"
         | 
| 10 | 
            +
                gem.homepage = "http://github.com/nofxx/watircuke"
         | 
| 11 | 
            +
                gem.authors = ["Rich Downie", "Marcos Piccinini"]
         | 
| 12 | 
            +
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            rescue LoadError
         | 
| 16 | 
            +
              puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            require 'spec/rake/spectask'
         | 
| 20 | 
            +
            Spec::Rake::SpecTask.new(:spec) do |spec|
         | 
| 21 | 
            +
              spec.libs << 'lib' << 'spec'
         | 
| 22 | 
            +
              spec.spec_files = FileList['spec/**/*_spec.rb']
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            Spec::Rake::SpecTask.new(:rcov) do |spec|
         | 
| 26 | 
            +
              spec.libs << 'lib' << 'spec'
         | 
| 27 | 
            +
              spec.pattern = 'spec/**/*_spec.rb'
         | 
| 28 | 
            +
              spec.rcov = true
         | 
| 29 | 
            +
            end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
             | 
| 32 | 
            +
            task :default => :spec
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            require 'rake/rdoctask'
         | 
| 35 | 
            +
            Rake::RDocTask.new do |rdoc|
         | 
| 36 | 
            +
              if File.exist?('VERSION.yml')
         | 
| 37 | 
            +
                config = YAML.load(File.read('VERSION.yml'))
         | 
| 38 | 
            +
                version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
         | 
| 39 | 
            +
              else
         | 
| 40 | 
            +
                version = ""
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              rdoc.rdoc_dir = 'rdoc'
         | 
| 44 | 
            +
              rdoc.title = "watircuke #{version}"
         | 
| 45 | 
            +
              rdoc.rdoc_files.include('README*')
         | 
| 46 | 
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 47 | 
            +
            end
         | 
| 48 | 
            +
             | 
    
        data/VERSION
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            0.3.1
         | 
    
        data/cucumber.yml
    ADDED
    
    
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            Feature: Ajax
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              @watir
         | 
| 4 | 
            +
              Scenario: ajaxy test
         | 
| 5 | 
            +
                Given I am on the watircuke page
         | 
| 6 | 
            +
                And I click "download_button"
         | 
| 7 | 
            +
                And I wait until "facebox"
         | 
| 8 | 
            +
                And I wait until "archives"
         | 
| 9 | 
            +
                Then I should see "Download richdownie/watircuke at master "
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              @watir
         | 
| 12 | 
            +
              Scenario: ajaxy search
         | 
| 13 | 
            +
                Given I am on bing
         | 
| 14 | 
            +
                And I fill in "q" with "cucu"
         | 
| 15 | 
            +
                Then I should see "cucumber"
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            Feature: Github
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              Scenario: search for cucumber at github
         | 
| 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)"
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require 'spec'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            if ENV['CUC_ENV'] == 'webrat'
         | 
| 4 | 
            +
              require 'webrat/core/matchers'
         | 
| 5 | 
            +
              require File.expand_path(File.dirname(__FILE__) + '/../../lib/webratcuke')
         | 
| 6 | 
            +
            else
         | 
| 7 | 
            +
              require File.expand_path(File.dirname(__FILE__) + '/../../lib/watircuke')
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              Before do
         | 
| 10 | 
            +
                @environment = "http://github.com/"
         | 
| 11 | 
            +
                #  sleep 1
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              # "after all"
         | 
| 15 | 
            +
              at_exit do
         | 
| 16 | 
            +
                @browser.close if @browser
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            module NavigationHelpers
         | 
| 2 | 
            +
              def path_to(page_name)
         | 
| 3 | 
            +
                case page_name
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                when /the guides page/i
         | 
| 6 | 
            +
                  @environment + "guides/home"
         | 
| 7 | 
            +
                when /the watircuke page/i
         | 
| 8 | 
            +
                  @environment + "richdownie/watircuke/tree/master"
         | 
| 9 | 
            +
                when /the cucumber page/i
         | 
| 10 | 
            +
                  @environment + "aslakhellesoy/cucumber/tree/master"
         | 
| 11 | 
            +
                when /the homepage/i
         | 
| 12 | 
            +
                  @environment
         | 
| 13 | 
            +
                when /bing/i
         | 
| 14 | 
            +
                  "http://bing.com"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                # Add more page name => path mappings here
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                else
         | 
| 19 | 
            +
                  raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
         | 
| 20 | 
            +
                    "Now, go and add a mapping in features/support/paths.rb"
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            World(NavigationHelpers)
         | 
    
        data/lib/watircuke.rb
    ADDED
    
    | @@ -0,0 +1,147 @@ | |
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Watircuke
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Commonly used watir steps
         | 
| 5 | 
            +
            #
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
            require 'cucumber'
         | 
| 8 | 
            +
            require 'spec'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # Environment
         | 
| 12 | 
            +
            #
         | 
| 13 | 
            +
            if ENV['FIREWATIR']
         | 
| 14 | 
            +
              require 'firewatir'
         | 
| 15 | 
            +
              Browser = FireWatir::Firefox
         | 
| 16 | 
            +
            else
         | 
| 17 | 
            +
              case RUBY_PLATFORM
         | 
| 18 | 
            +
              when /darwin|i686-linux/
         | 
| 19 | 
            +
                require 'firewatir'
         | 
| 20 | 
            +
                Browser = FireWatir::Firefox
         | 
| 21 | 
            +
                # require 'safariwatir'
         | 
| 22 | 
            +
                # Browser = Watir::Safari
         | 
| 23 | 
            +
              when /win32|mingw/
         | 
| 24 | 
            +
                require 'watir'
         | 
| 25 | 
            +
                Browser = Watir::IE
         | 
| 26 | 
            +
              when /java/
         | 
| 27 | 
            +
                require 'celerity'
         | 
| 28 | 
            +
                Browser = Celerity::Browser
         | 
| 29 | 
            +
              else
         | 
| 30 | 
            +
                raise "This platform is not supported (#{PLATFORM})"
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            #
         | 
| 35 | 
            +
            # Cucumber
         | 
| 36 | 
            +
            #
         | 
| 37 | 
            +
            Before do
         | 
| 38 | 
            +
              @browser = Browser.new
         | 
| 39 | 
            +
            end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            #
         | 
| 42 | 
            +
            # Browsing
         | 
| 43 | 
            +
            #
         | 
| 44 | 
            +
            Given /^I am on (.+)$/ do |page_name|
         | 
| 45 | 
            +
              @browser.goto(path_to(page_name))
         | 
| 46 | 
            +
            end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            When /^I (visit|go to) the (.+)$/ do |_, text|
         | 
| 49 | 
            +
              @browser.goto(@environment + text)
         | 
| 50 | 
            +
            end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            When /^I (click|follow) "([^\"]*)"$/ do |_, id|
         | 
| 53 | 
            +
              link = @browser.link(:text, id).click rescue @browser.link(:id, id).click
         | 
| 54 | 
            +
            end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            Then /^I should be on (.+)$/ do |page_name|
         | 
| 57 | 
            +
              URI.parse(@browser.url).path.should == path_to(page_name)
         | 
| 58 | 
            +
            end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            #
         | 
| 61 | 
            +
            # Should see
         | 
| 62 | 
            +
            #
         | 
| 63 | 
            +
            #
         | 
| 64 | 
            +
            Then /^I should see "([^\"]*)"$/ do |text|
         | 
| 65 | 
            +
              @browser.contains_text(text).should be_true
         | 
| 66 | 
            +
            end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            Then /^I should not see "([^\"]*)"$/ do |text|
         | 
| 69 | 
            +
              @browser.contains_text(text).should be_false
         | 
| 70 | 
            +
            end
         | 
| 71 | 
            +
             | 
| 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
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            Given /I verify the page contains a div class "(.*)"/ do |byclass|
         | 
| 80 | 
            +
              @browser.div(:class, byclass).exists?.should be_true
         | 
| 81 | 
            +
            end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            Given /I verify the page contains a div id "(.*)"/ do |id|
         | 
| 84 | 
            +
              @browser.div(:id, id).exists?.should be_true
         | 
| 85 | 
            +
            end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            Given /I verify the page contains a link class "(.*)"/ do |byclass|
         | 
| 88 | 
            +
              @browser.link(:class, byclass).exists?.should be_true
         | 
| 89 | 
            +
            end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
            Given /I verify the page contains the image "(.*)"/ do |image|
         | 
| 92 | 
            +
              @browser.image(:src, image).exists?.should be_true
         | 
| 93 | 
            +
            end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
         | 
| 96 | 
            +
              @browser.checkbox(label).should be_checked
         | 
| 97 | 
            +
            end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            #
         | 
| 100 | 
            +
            # Forms
         | 
| 101 | 
            +
            #
         | 
| 102 | 
            +
            #
         | 
| 103 | 
            +
            When /^I press "([^\"]*)"$/ do |b|
         | 
| 104 | 
            +
              @browser.button(:value, b).click
         | 
| 105 | 
            +
            end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
         | 
| 108 | 
            +
              @browser.text_field(:name, field).set(value)
         | 
| 109 | 
            +
            end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, id|
         | 
| 112 | 
            +
              @browser.select_list(:id, id).select(value)
         | 
| 113 | 
            +
            end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            When /^I choose "([^\"]*)"$/ do |id|
         | 
| 116 | 
            +
              @browser.radio(:id, id).click
         | 
| 117 | 
            +
            end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            When /^I check "([^\"]*)"$/ do |id|
         | 
| 120 | 
            +
              @browser.checkbox(:id, id).click
         | 
| 121 | 
            +
            end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
            When /^I uncheck "([^\"]*)"$/ do |id|
         | 
| 124 | 
            +
              @browser.checkbox(field).clear
         | 
| 125 | 
            +
            end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            #
         | 
| 128 | 
            +
            # Javascript
         | 
| 129 | 
            +
            #
         | 
| 130 | 
            +
            Given /From the "(.*)" link I fire the "(.*)" event/  do |text, event|
         | 
| 131 | 
            +
              @browser.link(:text , text).fire_event(event)
         | 
| 132 | 
            +
            end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
            Given /I click the "(.*)" span/  do |text|
         | 
| 135 | 
            +
              @browser.span(:text, text).click
         | 
| 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
    ADDED
    
    | @@ -0,0 +1,197 @@ | |
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Watircuke
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Commonly used webrat steps
         | 
| 5 | 
            +
            # http://github.com/brynary/webrat
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            # Browsing
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            Given /^I am on (.+)$/ do |page_name|
         | 
| 13 | 
            +
              visit path_to(page_name)
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            When /^I go to (.+)$/ do |page_name|
         | 
| 17 | 
            +
              visit path_to(page_name)
         | 
| 18 | 
            +
            end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            When /^I follow "([^\"]*)"$/ do |link|
         | 
| 21 | 
            +
              click_link(link)
         | 
| 22 | 
            +
            end
         | 
| 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 | 
            +
             | 
| 96 | 
            +
            When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
         | 
| 97 | 
            +
              fill_in(field, :with => value)
         | 
| 98 | 
            +
            end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
            When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
         | 
| 101 | 
            +
              select(value, :from => field)
         | 
| 102 | 
            +
            end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            # Use this step in conjunction with Rail's datetime_select helper. For example:
         | 
| 105 | 
            +
            # When I select "December 25, 2008 10:00" as the date and time
         | 
| 106 | 
            +
            When /^I select "([^\"]*)" as the date and time$/ do |time|
         | 
| 107 | 
            +
              select_datetime(time)
         | 
| 108 | 
            +
            end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            When /^I (press|follow|check|uncheck|choose) "([^\"]*)" for (.*) whose (.*) is "([^\"]*)"$/ do |action, whatyouclick, class_name, var_name, value|
         | 
| 111 | 
            +
              id = var_name == "id" ? value : eval("\"#{class_name}\".classify.constantize.find_by_#{var_name}(\"#{value}\").id.to_s")
         | 
| 112 | 
            +
              within("tr[id=row_#{class_name}_#{id}]") do
         | 
| 113 | 
            +
                case action
         | 
| 114 | 
            +
                  when "press"   then   click_button(whatyouclick)
         | 
| 115 | 
            +
                  when "follow"  then   click_link(whatyouclick)
         | 
| 116 | 
            +
                  when "check"   then   check(whatyouclick)
         | 
| 117 | 
            +
                  when "uncheck" then   uncheck(whatyouclick)
         | 
| 118 | 
            +
                  when "choose"  then   uncheck(whatyouclick)
         | 
| 119 | 
            +
                end
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
            end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
             | 
| 124 | 
            +
            # Use this step when using multiple datetime_select helpers on a page or
         | 
| 125 | 
            +
            # you want to specify which datetime to select. Given the following view:
         | 
| 126 | 
            +
            #   <%= f.label :preferred %><br />
         | 
| 127 | 
            +
            #   <%= f.datetime_select :preferred %>
         | 
| 128 | 
            +
            #   <%= f.label :alternative %><br />
         | 
| 129 | 
            +
            #   <%= f.datetime_select :alternative %>
         | 
| 130 | 
            +
            # The following steps would fill out the form:
         | 
| 131 | 
            +
            # When I select "November 23, 2004 11:20" as the "Preferred" date and time
         | 
| 132 | 
            +
            # And I select "November 25, 2004 10:30" as the "Alternative" date and time
         | 
| 133 | 
            +
            When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
         | 
| 134 | 
            +
              select_datetime(datetime, :from => datetime_label)
         | 
| 135 | 
            +
            end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
            # Use this step in conjunction with Rail's time_select helper. For example:
         | 
| 138 | 
            +
            # When I select "2:20PM" as the time
         | 
| 139 | 
            +
            # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
         | 
| 140 | 
            +
            # will convert the 2:20PM to 14:20 and then select it.
         | 
| 141 | 
            +
            When /^I select "([^\"]*)" as the time$/ do |time|
         | 
| 142 | 
            +
              select_time(time)
         | 
| 143 | 
            +
            end
         | 
| 144 | 
            +
             | 
| 145 | 
            +
            # Use this step when using multiple time_select helpers on a page or you want to
         | 
| 146 | 
            +
            # specify the name of the time on the form.  For example:
         | 
| 147 | 
            +
            # When I select "7:30AM" as the "Gym" time
         | 
| 148 | 
            +
            When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
         | 
| 149 | 
            +
              select_time(time, :from => time_label)
         | 
| 150 | 
            +
            end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
            # Use this step in conjunction with Rail's date_select helper.  For example:
         | 
| 153 | 
            +
            # When I select "February 20, 1981" as the date
         | 
| 154 | 
            +
            When /^I select "([^\"]*)" as the date$/ do |date|
         | 
| 155 | 
            +
              select_date(date)
         | 
| 156 | 
            +
            end
         | 
| 157 | 
            +
             | 
| 158 | 
            +
            # Use this step when using multiple date_select helpers on one page or
         | 
| 159 | 
            +
            # you want to specify the name of the date on the form. For example:
         | 
| 160 | 
            +
            # When I select "April 26, 1982" as the "Date of Birth" date
         | 
| 161 | 
            +
            When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
         | 
| 162 | 
            +
              select_date(date, :from => date_label)
         | 
| 163 | 
            +
            end
         | 
| 164 | 
            +
             | 
| 165 | 
            +
            When /^I choose "([^\"]*)"$/ do |field|
         | 
| 166 | 
            +
              choose(field)
         | 
| 167 | 
            +
            end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
            When /^I check "([^\"]*)"$/ do |field|
         | 
| 170 | 
            +
              check(field)
         | 
| 171 | 
            +
            end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
            When /^I uncheck "([^\"]*)"$/ do |field|
         | 
| 174 | 
            +
              uncheck(field)
         | 
| 175 | 
            +
            end
         | 
| 176 | 
            +
             | 
| 177 | 
            +
            When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
         | 
| 178 | 
            +
              attach_file(field, path)
         | 
| 179 | 
            +
            end
         | 
| 180 | 
            +
             | 
| 181 | 
            +
             | 
| 182 | 
            +
            # Steps that are generally useful and help encourage use of semantic
         | 
| 183 | 
            +
            # IDs and Class Names in your markup. In the steps below, a match following
         | 
| 184 | 
            +
            # "the" will verify the presences of an element with a given ID while a match following
         | 
| 185 | 
            +
            # "a" or "an" will verify the presence an element of a given class.
         | 
| 186 | 
            +
            Then /^I debug$/ do
         | 
| 187 | 
            +
              debugger
         | 
| 188 | 
            +
            end
         | 
| 189 | 
            +
             | 
| 190 | 
            +
            Then /^save_and_open_page$/ do
         | 
| 191 | 
            +
              save_and_open_page
         | 
| 192 | 
            +
            end
         | 
| 193 | 
            +
             | 
| 194 | 
            +
            Then /^I wait for ([0-9]+) seconds$/ do |delay|
         | 
| 195 | 
            +
              sleep delay.to_i
         | 
| 196 | 
            +
            end
         | 
| 197 | 
            +
             | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        data/watircuke.gemspec
    ADDED
    
    | @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |s|
         | 
| 4 | 
            +
              s.name = %q{watircuke}
         | 
| 5 | 
            +
              s.version = "0.3.1"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 8 | 
            +
              s.authors = ["Rich Downie", "Marcos Piccinini"]
         | 
| 9 | 
            +
              s.date = %q{2009-06-29}
         | 
| 10 | 
            +
              s.email = %q{x@nofxx.com}
         | 
| 11 | 
            +
              s.extra_rdoc_files = [
         | 
| 12 | 
            +
                "README.rdoc"
         | 
| 13 | 
            +
              ]
         | 
| 14 | 
            +
              s.files = [
         | 
| 15 | 
            +
                ".gitignore",
         | 
| 16 | 
            +
                 "README.rdoc",
         | 
| 17 | 
            +
                 "Rakefile",
         | 
| 18 | 
            +
                 "VERSION",
         | 
| 19 | 
            +
                 "cucumber.yml",
         | 
| 20 | 
            +
                 "features/ajax.feature",
         | 
| 21 | 
            +
                 "features/sample.feature",
         | 
| 22 | 
            +
                 "features/search.feature",
         | 
| 23 | 
            +
                 "features/step_definitions/search.rb",
         | 
| 24 | 
            +
                 "features/support/env.rb",
         | 
| 25 | 
            +
                 "features/support/paths.rb",
         | 
| 26 | 
            +
                 "lib/watircuke.rb",
         | 
| 27 | 
            +
                 "lib/webratcuke.rb",
         | 
| 28 | 
            +
                 "spec/spec_helper.rb",
         | 
| 29 | 
            +
                 "spec/watircuke_spec.rb",
         | 
| 30 | 
            +
                 "watircuke.gemspec"
         | 
| 31 | 
            +
              ]
         | 
| 32 | 
            +
              s.homepage = %q{http://github.com/nofxx/watircuke}
         | 
| 33 | 
            +
              s.rdoc_options = ["--charset=UTF-8"]
         | 
| 34 | 
            +
              s.require_paths = ["lib"]
         | 
| 35 | 
            +
              s.rubygems_version = %q{1.3.4}
         | 
| 36 | 
            +
              s.summary = %q{Watir steps for cucumber}
         | 
| 37 | 
            +
              s.test_files = [
         | 
| 38 | 
            +
                "spec/spec_helper.rb",
         | 
| 39 | 
            +
                 "spec/watircuke_spec.rb"
         | 
| 40 | 
            +
              ]
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              if s.respond_to? :specification_version then
         | 
| 43 | 
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 44 | 
            +
                s.specification_version = 3
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         | 
| 47 | 
            +
                else
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              else
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: jsmestad-watircuke
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              version: 0.3.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors: 
         | 
| 7 | 
            +
            - Rich Downie
         | 
| 8 | 
            +
            - Marcos Piccinini
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            date: 2009-06-29 00:00:00 -07:00
         | 
| 14 | 
            +
            default_executable: 
         | 
| 15 | 
            +
            dependencies: []
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            description: 
         | 
| 18 | 
            +
            email: x@nofxx.com
         | 
| 19 | 
            +
            executables: []
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            extensions: []
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            extra_rdoc_files: 
         | 
| 24 | 
            +
            - README.rdoc
         | 
| 25 | 
            +
            files: 
         | 
| 26 | 
            +
            - .gitignore
         | 
| 27 | 
            +
            - README.rdoc
         | 
| 28 | 
            +
            - Rakefile
         | 
| 29 | 
            +
            - VERSION
         | 
| 30 | 
            +
            - cucumber.yml
         | 
| 31 | 
            +
            - features/ajax.feature
         | 
| 32 | 
            +
            - features/sample.feature
         | 
| 33 | 
            +
            - features/search.feature
         | 
| 34 | 
            +
            - features/step_definitions/search.rb
         | 
| 35 | 
            +
            - features/support/env.rb
         | 
| 36 | 
            +
            - features/support/paths.rb
         | 
| 37 | 
            +
            - lib/watircuke.rb
         | 
| 38 | 
            +
            - lib/webratcuke.rb
         | 
| 39 | 
            +
            - spec/spec_helper.rb
         | 
| 40 | 
            +
            - spec/watircuke_spec.rb
         | 
| 41 | 
            +
            - watircuke.gemspec
         | 
| 42 | 
            +
            has_rdoc: false
         | 
| 43 | 
            +
            homepage: http://github.com/nofxx/watircuke
         | 
| 44 | 
            +
            post_install_message: 
         | 
| 45 | 
            +
            rdoc_options: 
         | 
| 46 | 
            +
            - --charset=UTF-8
         | 
| 47 | 
            +
            require_paths: 
         | 
| 48 | 
            +
            - lib
         | 
| 49 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 50 | 
            +
              requirements: 
         | 
| 51 | 
            +
              - - ">="
         | 
| 52 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 53 | 
            +
                  version: "0"
         | 
| 54 | 
            +
              version: 
         | 
| 55 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 56 | 
            +
              requirements: 
         | 
| 57 | 
            +
              - - ">="
         | 
| 58 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 59 | 
            +
                  version: "0"
         | 
| 60 | 
            +
              version: 
         | 
| 61 | 
            +
            requirements: []
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            rubyforge_project: 
         | 
| 64 | 
            +
            rubygems_version: 1.2.0
         | 
| 65 | 
            +
            signing_key: 
         | 
| 66 | 
            +
            specification_version: 3
         | 
| 67 | 
            +
            summary: Watir steps for cucumber
         | 
| 68 | 
            +
            test_files: 
         | 
| 69 | 
            +
            - spec/spec_helper.rb
         | 
| 70 | 
            +
            - spec/watircuke_spec.rb
         |