watirsplash 2.0.0.rc2 → 2.0.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/Gemfile.lock +13 -13
- data/History.rdoc +14 -9
- data/README.rdoc +1 -1
- data/lib/watirsplash/browser.rb +23 -5
- data/lib/watirsplash/frameworks/watir-webdriver/chrome.rb +1 -3
- data/lib/watirsplash/frameworks/watir-webdriver/firefox.rb +1 -3
- data/lib/watirsplash/frameworks/watir-webdriver/ie.rb +1 -3
- data/lib/watirsplash/generators/templates/new_project/config.rb.tt +10 -0
- data/lib/watirsplash/html_formatter.rb +3 -7
- data/lib/watirsplash/page/base.rb +4 -4
- data/lib/watirsplash/rspec_patches.rb +31 -17
- data/lib/watirsplash/spec_helper.rb +4 -4
- data/lib/watirsplash/version.rb +2 -2
- data/spec/browser_spec.rb +23 -0
- data/spec/environment.rb +4 -0
- data/spec/page_spec.rb +81 -0
- data/spec/rspec_patches_spec.rb +63 -4
- data/spec/spec_helper_spec.rb +0 -5
- metadata +13 -13
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                watirsplash (2.0.0 | 
| 4 | 
            +
                watirsplash (2.0.0)
         | 
| 5 5 | 
             
                  bundler (~> 1.0)
         | 
| 6 6 | 
             
                  rake (= 0.8.7)
         | 
| 7 7 | 
             
                  require_all
         | 
| @@ -14,18 +14,18 @@ GEM | |
| 14 14 | 
             
                builder (3.0.0)
         | 
| 15 15 | 
             
                childprocess (0.1.9)
         | 
| 16 16 | 
             
                  ffi (~> 1.0.6)
         | 
| 17 | 
            -
                commonwatir (1.9. | 
| 17 | 
            +
                commonwatir (1.9.1)
         | 
| 18 18 | 
             
                  user-choices
         | 
| 19 19 | 
             
                diff-lcs (1.1.2)
         | 
| 20 20 | 
             
                ffi (1.0.9-x86-mingw32)
         | 
| 21 | 
            -
                firewatir (1.9. | 
| 22 | 
            -
                  commonwatir (= 1.9. | 
| 23 | 
            -
                hoe (2. | 
| 24 | 
            -
                  rake ( | 
| 21 | 
            +
                firewatir (1.9.1)
         | 
| 22 | 
            +
                  commonwatir (= 1.9.1)
         | 
| 23 | 
            +
                hoe (2.10.0)
         | 
| 24 | 
            +
                  rake (~> 0.8)
         | 
| 25 25 | 
             
                json_pure (1.5.3)
         | 
| 26 26 | 
             
                mini_magick (3.2.1)
         | 
| 27 27 | 
             
                  subexec (~> 0.0.4)
         | 
| 28 | 
            -
                nokogiri (1. | 
| 28 | 
            +
                nokogiri (1.5.0-x86-mingw32)
         | 
| 29 29 | 
             
                rake (0.8.7)
         | 
| 30 30 | 
             
                rautomation (0.5.1)
         | 
| 31 31 | 
             
                require_all (1.2.0)
         | 
| @@ -52,10 +52,10 @@ GEM | |
| 52 52 | 
             
                  builder (>= 2.1.2)
         | 
| 53 53 | 
             
                  s4t-utils (>= 1.0.3)
         | 
| 54 54 | 
             
                  xml-simple (>= 1.0.11)
         | 
| 55 | 
            -
                watir (1.9. | 
| 56 | 
            -
                  commonwatir (= 1.9. | 
| 55 | 
            +
                watir (1.9.1)
         | 
| 56 | 
            +
                  commonwatir (= 1.9.1)
         | 
| 57 57 | 
             
                  ffi (~> 1.0)
         | 
| 58 | 
            -
                  firewatir (= 1.9. | 
| 58 | 
            +
                  firewatir (= 1.9.1)
         | 
| 59 59 | 
             
                  nokogiri
         | 
| 60 60 | 
             
                  rautomation (~> 0.5)
         | 
| 61 61 | 
             
                  win32-process (>= 0.5.5)
         | 
| @@ -74,15 +74,15 @@ GEM | |
| 74 74 | 
             
                windows-pr (1.2.0)
         | 
| 75 75 | 
             
                  win32-api (>= 1.4.5)
         | 
| 76 76 | 
             
                  windows-api (>= 0.3.0)
         | 
| 77 | 
            -
                xml-simple (1.0 | 
| 77 | 
            +
                xml-simple (1.1.0)
         | 
| 78 78 |  | 
| 79 79 | 
             
            PLATFORMS
         | 
| 80 80 | 
             
              x86-mingw32
         | 
| 81 81 |  | 
| 82 82 | 
             
            DEPENDENCIES
         | 
| 83 | 
            -
              firewatir (= 1.9. | 
| 83 | 
            +
              firewatir (= 1.9.1)
         | 
| 84 84 | 
             
              rspec (~> 2.6.0)
         | 
| 85 | 
            -
              watir (= 1.9. | 
| 85 | 
            +
              watir (= 1.9.1)
         | 
| 86 86 | 
             
              watir-webdriver (~> 0.2.5)
         | 
| 87 87 | 
             
              watirsplash!
         | 
| 88 88 | 
             
              win32screenshot (~> 1.0.4)
         | 
    
        data/History.rdoc
    CHANGED
    
    | @@ -1,15 +1,20 @@ | |
| 1 | 
            -
            === Version 2.0.0 / 2011-07- | 
| 2 | 
            -
             | 
| 3 | 
            -
             *  | 
| 4 | 
            -
             *  | 
| 1 | 
            +
            === Version 2.0.0 / 2011-07-06
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             * added Page Objects support - generate them with `watirsplash page` generator 
         | 
| 4 | 
            +
             * added #during RSpec matcher
         | 
| 5 | 
            +
             * added :default option for frameworks 
         | 
| 6 | 
            +
             * using Bundler for specifying runtime dependencies 
         | 
| 7 | 
            +
             * loading environment.rb directly from .rspec file
         | 
| 8 | 
            +
             * use WatirSplash::Browser.new to open up a browser and set it up with RSpec's formatter
         | 
| 9 | 
            +
             * use WatirSplash::Browser.current method to access current browser object globally
         | 
| 10 | 
            +
             * use @browser variable in WatirSplash::Page objects to access browser object 
         | 
| 11 | 
            +
             * moved File.path and File.native_path methods to WatirSplash::Util.file_path and .file_native_path since File.path method conflicts with Ruby 1.9
         | 
| 5 12 | 
             
             * removed ui-test-common functionality - just load it's environment.rb if you really need to use it
         | 
| 13 | 
            +
             * removed deprecated #in RSpec matcher
         | 
| 6 14 | 
             
             * do not load framework automatically anymore when requiring watirsplash - use WatirSplash::Util.load_framework method in environment.rb or config.rb instead
         | 
| 7 | 
            -
             * do not  | 
| 8 | 
            -
             *  | 
| 9 | 
            -
             * added :default option for frameworks
         | 
| 15 | 
            +
             * do not open browser window automatically anymore - use RSpec.configure block in config.rb if needed
         | 
| 16 | 
            +
             * do not maximize browser window anymore automatically - use RSpec configure block in config.rb if needed
         | 
| 10 17 | 
             
             * bumped dependencies for win32screenshot, watir, firewatir and watir-webdriver
         | 
| 11 | 
            -
             * use Bundler for specifying dependencies from now on
         | 
| 12 | 
            -
             * moved File.path and File.native_path methods to WatirSplash::Util.file_path and .file_native_path since File.path method conflicts with Ruby 1.9
         | 
| 13 18 |  | 
| 14 19 | 
             
              PS! This version is not fully backwards compatible due to some core changes, but it is possible to make your old project working with it.
         | 
| 15 20 |  | 
    
        data/README.rdoc
    CHANGED
    
    
    
        data/lib/watirsplash/browser.rb
    CHANGED
    
    | @@ -1,10 +1,28 @@ | |
| 1 1 | 
             
            module WatirSplash
         | 
| 2 2 | 
             
              class Browser
         | 
| 3 | 
            -
                 | 
| 4 | 
            -
                   | 
| 5 | 
            -
             | 
| 6 | 
            -
                   | 
| 7 | 
            -
             | 
| 3 | 
            +
                class << self
         | 
| 4 | 
            +
                  def new
         | 
| 5 | 
            +
                    prepare Watir::Browser.new
         | 
| 6 | 
            +
                  end    
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  @@current = nil
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def current
         | 
| 11 | 
            +
                    @@current
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def current= browser
         | 
| 15 | 
            +
                    @@current = browser
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  private
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def prepare browser
         | 
| 21 | 
            +
                    self.current = browser
         | 
| 22 | 
            +
                    browser
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                end
         | 
| 8 26 | 
             
              end
         | 
| 9 27 | 
             
            end
         | 
| 10 28 |  | 
| @@ -5,3 +5,13 @@ module <%= formatted_name %> | |
| 5 5 | 
             
                URL = <%= formatted_url %>
         | 
| 6 6 | 
             
              end
         | 
| 7 7 | 
             
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            RSpec.configure do |config|
         | 
| 10 | 
            +
              config.before :all do
         | 
| 11 | 
            +
                # WatirSplash::Browser.new 
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              config.after(:all) do
         | 
| 15 | 
            +
                WatirSplash::Browser.current.close if WatirSplash::Browser.current
         | 
| 16 | 
            +
              end  
         | 
| 17 | 
            +
            end
         | 
| @@ -10,10 +10,6 @@ module WatirSplash | |
| 10 10 | 
             
              # * saves all files generated/downloaded during the test and shows them in the report
         | 
| 11 11 | 
             
              class HtmlFormatter < ::RSpec::Core::Formatters::HtmlFormatter
         | 
| 12 12 |  | 
| 13 | 
            -
                # currently used browser object
         | 
| 14 | 
            -
                # needed for saving of screenshots and html
         | 
| 15 | 
            -
                attr_accessor :browser
         | 
| 16 | 
            -
             | 
| 17 13 | 
             
                def initialize(output) # :nodoc:
         | 
| 18 14 | 
             
                  @output_dir = File.expand_path(File.dirname(output))
         | 
| 19 15 | 
             
                  archive_results
         | 
| @@ -38,7 +34,7 @@ module WatirSplash | |
| 38 34 | 
             
                end
         | 
| 39 35 |  | 
| 40 36 | 
             
                def extra_failure_content(exception) # :nodoc:
         | 
| 41 | 
            -
                  if  | 
| 37 | 
            +
                  if WatirSplash::Browser.current && WatirSplash::Browser.current.exists?
         | 
| 42 38 | 
             
                    save_screenshot
         | 
| 43 39 | 
             
                    save_html
         | 
| 44 40 | 
             
                  end
         | 
| @@ -61,7 +57,7 @@ module WatirSplash | |
| 61 57 | 
             
                def save_html # :nodoc:
         | 
| 62 58 | 
             
                  file_name = file_path("browser.html")
         | 
| 63 59 | 
             
                  begin
         | 
| 64 | 
            -
                    html =  | 
| 60 | 
            +
                    html = WatirSplash::Browser.current.html
         | 
| 65 61 | 
             
                    File.open(file_name, 'w') {|f| f.puts html}
         | 
| 66 62 | 
             
                  rescue => e
         | 
| 67 63 | 
             
                    $stderr.puts "saving of html failed: #{e.message}"
         | 
| @@ -71,7 +67,7 @@ module WatirSplash | |
| 71 67 |  | 
| 72 68 | 
             
                def save_screenshot(description="Screenshot", hwnd=nil) # :nodoc:
         | 
| 73 69 | 
             
                  file_name = file_path("screenshot.png", description)
         | 
| 74 | 
            -
                   | 
| 70 | 
            +
                  WatirSplash::Browser.current.save_screenshot(:file_name => file_name, :hwnd => hwnd)
         | 
| 75 71 | 
             
                  file_name
         | 
| 76 72 | 
             
                end
         | 
| 77 73 |  | 
| @@ -13,23 +13,23 @@ module WatirSplash | |
| 13 13 |  | 
| 14 14 | 
             
                  def initialize(browser=nil)
         | 
| 15 15 | 
             
                    if browser
         | 
| 16 | 
            -
                      @browser = WatirSplash:: | 
| 16 | 
            +
                      @browser = WatirSplash::Browser.current = browser 
         | 
| 17 17 | 
             
                    else
         | 
| 18 18 | 
             
                      @browser = WatirSplash::Browser.new
         | 
| 19 19 | 
             
                      @browser.goto @@url
         | 
| 20 20 | 
             
                    end
         | 
| 21 21 | 
             
                  end
         | 
| 22 22 |  | 
| 23 | 
            -
                  def  | 
| 23 | 
            +
                  def modify element, methodz
         | 
| 24 24 | 
             
                    methodz.each_pair do |meth, return_value|
         | 
| 25 25 | 
             
                      element.instance_eval do 
         | 
| 26 | 
            -
                        instance_variable_set(" | 
| 26 | 
            +
                        instance_variable_set("@_#{meth}_return_value_proc", return_value)
         | 
| 27 27 | 
             
                        instance_eval %Q[
         | 
| 28 28 | 
             
                          self.class.send(:alias_method, :__#{meth}, :#{meth}) if respond_to? :#{meth}
         | 
| 29 29 |  | 
| 30 30 | 
             
                          def #{meth}(*args)
         | 
| 31 31 | 
             
                            self.send(:__#{meth}, *args) if respond_to? :__#{meth}
         | 
| 32 | 
            -
                            instance_variable_get(" | 
| 32 | 
            +
                            instance_variable_get("@_#{meth}_return_value_proc").call(*args)
         | 
| 33 33 | 
             
                          end
         | 
| 34 34 | 
             
                        ]
         | 
| 35 35 | 
             
                      end
         | 
| @@ -29,10 +29,6 @@ end | |
| 29 29 |  | 
| 30 30 | 
             
            RSpec.configure do |config| #:nodoc:
         | 
| 31 31 | 
             
              config.include(WatirSplash::SpecHelper)
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              config.after(:all) do
         | 
| 34 | 
            -
                WatirSplash::Util.formatter.browser.close if WatirSplash::Util.formatter.browser
         | 
| 35 | 
            -
              end
         | 
| 36 32 | 
             
            end
         | 
| 37 33 |  | 
| 38 34 | 
             
            module RSpec #:nodoc:all
         | 
| @@ -74,14 +70,14 @@ module RSpec::Matchers | |
| 74 70 | 
             
              class Change
         | 
| 75 71 | 
             
                def matches?(event_proc)
         | 
| 76 72 | 
             
                  raise_block_syntax_error if block_given?
         | 
| 77 | 
            -
             | 
| 73 | 
            +
             | 
| 78 74 | 
             
                  # to make #change work with #in(timeout) method
         | 
| 79 75 | 
             
                  unless defined? @actual_before
         | 
| 80 76 | 
             
                    @actual_before = evaluate_value_proc
         | 
| 81 77 | 
             
                    event_proc.call
         | 
| 82 78 | 
             
                  end
         | 
| 83 79 | 
             
                  @actual_after = evaluate_value_proc
         | 
| 84 | 
            -
             | 
| 80 | 
            +
             | 
| 85 81 | 
             
                  (!change_expected? || changed?) && matches_before? && matches_after? && matches_expected_delta? && matches_min? && matches_max?
         | 
| 86 82 | 
             
                end
         | 
| 87 83 | 
             
              end
         | 
| @@ -114,15 +110,15 @@ RSpec::Matchers.constants.each do |const| | |
| 114 110 | 
             
                inst_methods = instance_methods.map {|m| m.to_sym}
         | 
| 115 111 |  | 
| 116 112 | 
             
                if !(inst_methods.include?(:__matches?) || inst_methods.include?(:__does_not_match?)) && 
         | 
| 117 | 
            -
             | 
| 113 | 
            +
                  (inst_methods.include?(:matches?) || inst_methods.include?(:does_not_match?))
         | 
| 118 114 |  | 
| 119 | 
            -
                  def  | 
| 120 | 
            -
                     | 
| 121 | 
            -
                     | 
| 115 | 
            +
                  def within(timeout)
         | 
| 116 | 
            +
                    @within_timeout = timeout
         | 
| 117 | 
            +
                    self
         | 
| 122 118 | 
             
                  end
         | 
| 123 119 |  | 
| 124 | 
            -
                  def  | 
| 125 | 
            -
                    @ | 
| 120 | 
            +
                  def during(timeout)
         | 
| 121 | 
            +
                    @during_timeout = timeout
         | 
| 126 122 | 
             
                    self
         | 
| 127 123 | 
             
                  end
         | 
| 128 124 |  | 
| @@ -138,8 +134,8 @@ RSpec::Matchers.constants.each do |const| | |
| 138 134 | 
             
                  alias_method :second, :seconds
         | 
| 139 135 |  | 
| 140 136 | 
             
                  def minutes
         | 
| 141 | 
            -
                     | 
| 142 | 
            -
                    @ | 
| 137 | 
            +
                    @within_timeout *= 60 if @within_timeout
         | 
| 138 | 
            +
                    @during_timeout *= 60 if @during_timeout
         | 
| 143 139 | 
             
                    self
         | 
| 144 140 | 
             
                  end
         | 
| 145 141 |  | 
| @@ -150,7 +146,13 @@ RSpec::Matchers.constants.each do |const| | |
| 150 146 | 
             
                  alias_method :__matches?, :matches? 
         | 
| 151 147 |  | 
| 152 148 | 
             
                  def matches?(actual)
         | 
| 153 | 
            -
                     | 
| 149 | 
            +
                    if @within_timeout
         | 
| 150 | 
            +
                      Watir::Wait.until(@within_timeout) {__matches?(actual)} rescue false
         | 
| 151 | 
            +
                    elsif @during_timeout
         | 
| 152 | 
            +
                      Watir::Wait.while(@during_timeout) {__matches?(actual)} rescue true
         | 
| 153 | 
            +
                    else
         | 
| 154 | 
            +
                      __matches?(actual)
         | 
| 155 | 
            +
                    end
         | 
| 154 156 | 
             
                  end
         | 
| 155 157 | 
             
                end
         | 
| 156 158 |  | 
| @@ -158,11 +160,23 @@ RSpec::Matchers.constants.each do |const| | |
| 158 160 | 
             
                  alias_method :__does_not_match?, :does_not_match?
         | 
| 159 161 |  | 
| 160 162 | 
             
                  def does_not_match?(actual)
         | 
| 161 | 
            -
                     | 
| 163 | 
            +
                    if @within_timeout
         | 
| 164 | 
            +
                      Watir::Wait.until(@within_timeout) {__does_not_match?(actual)} rescue false
         | 
| 165 | 
            +
                    elsif @during_timeout
         | 
| 166 | 
            +
                      Watir::Wait.while(@during_timeout) {__does_not_match?(actual)} rescue true
         | 
| 167 | 
            +
                    else
         | 
| 168 | 
            +
                      __does_not_match?(actual)
         | 
| 169 | 
            +
                    end
         | 
| 162 170 | 
             
                  end
         | 
| 163 171 | 
             
                elsif inst_methods.include? :matches?
         | 
| 164 172 | 
             
                  def does_not_match?(actual)
         | 
| 165 | 
            -
                     | 
| 173 | 
            +
                    if @within_timeout
         | 
| 174 | 
            +
                      Watir::Wait.until(@within_timeout) {!__matches?(actual)} rescue false
         | 
| 175 | 
            +
                    elsif @during_timeout
         | 
| 176 | 
            +
                      Watir::Wait.while(@during_timeout) {!__matches?(actual)} rescue true
         | 
| 177 | 
            +
                    else
         | 
| 178 | 
            +
                      !__matches?(actual)
         | 
| 179 | 
            +
                    end
         | 
| 166 180 | 
             
                  end
         | 
| 167 181 | 
             
                end
         | 
| 168 182 | 
             
              end
         | 
| @@ -5,13 +5,13 @@ module WatirSplash | |
| 5 5 | 
             
              module SpecHelper
         | 
| 6 6 |  | 
| 7 7 | 
             
                def method_missing name, *args #:nodoc:
         | 
| 8 | 
            -
                  if WatirSplash:: | 
| 8 | 
            +
                  if WatirSplash::Browser.current.respond_to?(name)
         | 
| 9 9 | 
             
                    SpecHelper.module_eval %Q[
         | 
| 10 10 | 
             
                      def #{name}(*args)
         | 
| 11 | 
            -
                        WatirSplash:: | 
| 11 | 
            +
                        WatirSplash::Browser.current.send(:#{name}, *args) {yield}
         | 
| 12 12 | 
             
                      end
         | 
| 13 13 | 
             
                    ]
         | 
| 14 | 
            -
                     | 
| 14 | 
            +
                    self.send(name, *args) {yield}
         | 
| 15 15 | 
             
                  else
         | 
| 16 16 | 
             
                    super
         | 
| 17 17 | 
             
                  end
         | 
| @@ -21,7 +21,7 @@ module WatirSplash | |
| 21 21 | 
             
                # and not Kernel
         | 
| 22 22 | 
             
                # use Kernel.p if you need to dump some variable 
         | 
| 23 23 | 
             
                def p *args #:nodoc:
         | 
| 24 | 
            -
                  WatirSplash:: | 
| 24 | 
            +
                  WatirSplash::Browser.current.p *args
         | 
| 25 25 | 
             
                end
         | 
| 26 26 |  | 
| 27 27 | 
             
              end
         | 
    
        data/lib/watirsplash/version.rb
    CHANGED
    
    
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            describe WatirSplash::Browser do
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              before :all do
         | 
| 4 | 
            +
                # close the browser opened in environment.rb
         | 
| 5 | 
            +
                WatirSplash::Browser.current.close
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              it "opens up the browser" do
         | 
| 9 | 
            +
                browser = WatirSplash::Browser.new
         | 
| 10 | 
            +
                browser.should exist
         | 
| 11 | 
            +
                browser.should respond_to(:title)
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              it "stores the current browser" do
         | 
| 15 | 
            +
                browser = WatirSplash::Browser.new
         | 
| 16 | 
            +
                browser.should == WatirSplash::Browser.current
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              after :each do
         | 
| 20 | 
            +
                WatirSplash::Browser.current.close
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
    
        data/spec/environment.rb
    CHANGED
    
    
    
        data/spec/page_spec.rb
    ADDED
    
    | @@ -0,0 +1,81 @@ | |
| 1 | 
            +
            class DummyPage < WatirSplash::Page::Base
         | 
| 2 | 
            +
              url "http://bing.com"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def something
         | 
| 5 | 
            +
                modify Hash.new,
         | 
| 6 | 
            +
                  :store => lambda {|a,b| a + b},
         | 
| 7 | 
            +
                  :new_method => lambda {[]}
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            describe WatirSplash::Page::Base do
         | 
| 12 | 
            +
              before :all do
         | 
| 13 | 
            +
                # close the browser opened in environment.rb    
         | 
| 14 | 
            +
                WatirSplash::Browser.current.close
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              context ".new" do
         | 
| 18 | 
            +
                it "opens up a new browser if no browser specified" do
         | 
| 19 | 
            +
                  page = DummyPage.new
         | 
| 20 | 
            +
                  browser = page.instance_variable_get(:@browser)
         | 
| 21 | 
            +
                  browser.should respond_to(:title)
         | 
| 22 | 
            +
                  browser.url.should =~ /bing\.com/
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                it "allows to reuse existing browser" do
         | 
| 26 | 
            +
                  browser = WatirSplash::Browser.new
         | 
| 27 | 
            +
                  browser.goto "http://google.com/ncr"
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  page = DummyPage.new(browser)
         | 
| 30 | 
            +
                  page_browser = page.instance_variable_get(:@browser)
         | 
| 31 | 
            +
                  page_browser.should == browser
         | 
| 32 | 
            +
                  page_browser.url.should =~ /google\.com/
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              context "#modify" do
         | 
| 37 | 
            +
                it "returns the instance of the object" do
         | 
| 38 | 
            +
                  page = DummyPage.new
         | 
| 39 | 
            +
                  page.something.should == {}
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                it "allows to modify default behavior of the instance's methods" do
         | 
| 43 | 
            +
                  page = DummyPage.new
         | 
| 44 | 
            +
                  page.something.store(1, 2).should == 3
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                it "executes the original method too" do
         | 
| 48 | 
            +
                  page = DummyPage.new
         | 
| 49 | 
            +
                  res = page.something
         | 
| 50 | 
            +
                  res.store(1, 2)
         | 
| 51 | 
            +
                  res.should == {1 => 2}
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                it "doesn't modify instance methods of the class itself" do
         | 
| 55 | 
            +
                  h = Hash.new
         | 
| 56 | 
            +
                  h.store(1, 2).should == 2
         | 
| 57 | 
            +
                  h.should == {1 => 2}
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                it "allows to add new methods too" do
         | 
| 61 | 
            +
                  page = DummyPage.new
         | 
| 62 | 
            +
                  page.something.new_method.should == []
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              context "#method_missing" do
         | 
| 67 | 
            +
                it "gets SpecHelper module included into class" do
         | 
| 68 | 
            +
                  DummyPage.included_modules.should include(WatirSplash::SpecHelper)
         | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                it "redirects all missing methods to browser object" do
         | 
| 72 | 
            +
                  page = DummyPage.new
         | 
| 73 | 
            +
                  page.should_not respond_to(:text_field)
         | 
| 74 | 
            +
                  page.text_field(:id => /somethin/).should be_kind_of(Watir::TextField)
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
              end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
              after :each do
         | 
| 79 | 
            +
                WatirSplash::Browser.current.close
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
            end
         | 
    
        data/spec/rspec_patches_spec.rb
    CHANGED
    
    | @@ -79,6 +79,61 @@ describe "RSpec patches" do | |
| 79 79 | 
             
                  end
         | 
| 80 80 | 
             
                end
         | 
| 81 81 |  | 
| 82 | 
            +
                context "#during" do
         | 
| 83 | 
            +
                  it "will pass upon timeout" do
         | 
| 84 | 
            +
                    require "ruby-debug"; debugger;
         | 
| 85 | 
            +
                    t = Time.now
         | 
| 86 | 
            +
                    true.should be_true.during(0.5)
         | 
| 87 | 
            +
                    (Time.now - t).should be >= 0.5
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  it "handles #should_not via matcher's #matches?" do
         | 
| 91 | 
            +
                    t = Time.now
         | 
| 92 | 
            +
                    h = {}
         | 
| 93 | 
            +
                    h.should_not have_key(:special).during(1)
         | 
| 94 | 
            +
                    (Time.now - t).should be >= 1
         | 
| 95 | 
            +
                  end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                  it "fails when #should_not is not satisfied during timeout via matcher's #matches?" do
         | 
| 98 | 
            +
                    t = Time.now
         | 
| 99 | 
            +
                    h = {}
         | 
| 100 | 
            +
                    Thread.new {sleep 0.5; h[:special] = true}
         | 
| 101 | 
            +
                    expect {
         | 
| 102 | 
            +
                      h.should_not have_key(:special).during(1)
         | 
| 103 | 
            +
                    }.to raise_error
         | 
| 104 | 
            +
                    (Time.now - t).should be_between(0.5, 1)
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                  it "handles #should_not via matcher's #does_not_match?" do
         | 
| 108 | 
            +
                    RSpec::Matchers.define :have_my_key do |expected|
         | 
| 109 | 
            +
                      match_for_should_not do |actual|
         | 
| 110 | 
            +
                        !actual.has_key?(expected)
         | 
| 111 | 
            +
                      end
         | 
| 112 | 
            +
                    end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                    t = Time.now
         | 
| 115 | 
            +
                    h = {}
         | 
| 116 | 
            +
                    h.should_not have_my_key(:special).during(1)
         | 
| 117 | 
            +
                    (Time.now - t).should be >= 1
         | 
| 118 | 
            +
                  end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                  it "fails when #should_not is not satisfied within timeout via matcher's #does_not_match?" do
         | 
| 121 | 
            +
                    RSpec::Matchers.define :have_my_key do |expected|
         | 
| 122 | 
            +
                      match_for_should_not do |actual|
         | 
| 123 | 
            +
                        !actual.has_key?(expected)
         | 
| 124 | 
            +
                      end
         | 
| 125 | 
            +
                    end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    t = Time.now
         | 
| 128 | 
            +
                    h = {}
         | 
| 129 | 
            +
                    Thread.new {sleep 0.5; h[:special] = true}
         | 
| 130 | 
            +
                    expect {
         | 
| 131 | 
            +
                      h.should_not have_my_key(:special).during(1)
         | 
| 132 | 
            +
                    }.to raise_error
         | 
| 133 | 
            +
                    (Time.now - t).should be_between(0.5, 1)
         | 
| 134 | 
            +
                  end
         | 
| 135 | 
            +
                end
         | 
| 136 | 
            +
             | 
| 82 137 | 
             
                context "#soon" do
         | 
| 83 138 | 
             
                  it "is an alias for #in(30)" do
         | 
| 84 139 | 
             
                    t = Time.now
         | 
| @@ -99,21 +154,25 @@ describe "RSpec patches" do | |
| 99 154 |  | 
| 100 155 | 
             
                context "#seconds" do
         | 
| 101 156 | 
             
                  it "is for syntactic sugar" do
         | 
| 102 | 
            -
                    RSpec::Matchers::Matcher.new(nil) {}.within(2).seconds.instance_variable_get(:@ | 
| 157 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.within(2).seconds.instance_variable_get(:@within_timeout).should == 2
         | 
| 158 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.during(3).seconds.instance_variable_get(:@during_timeout).should == 3
         | 
| 103 159 | 
             
                  end
         | 
| 104 160 |  | 
| 105 161 | 
             
                  it "has #second as an alias" do
         | 
| 106 | 
            -
                    RSpec::Matchers::Matcher.new(nil) {}.within(1).second.instance_variable_get(:@ | 
| 162 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.within(1).second.instance_variable_get(:@within_timeout).should == 1
         | 
| 163 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.during(2).second.instance_variable_get(:@during_timeout).should == 2
         | 
| 107 164 | 
             
                  end
         | 
| 108 165 | 
             
                end
         | 
| 109 166 |  | 
| 110 167 | 
             
                context "#minutes" do
         | 
| 111 168 | 
             
                  it "converts timeout into minutes" do
         | 
| 112 | 
            -
                    RSpec::Matchers::Matcher.new(nil) {}.within(2).minutes.instance_variable_get(:@ | 
| 169 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.within(2).minutes.instance_variable_get(:@within_timeout).should == 2*60
         | 
| 170 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.during(3).minutes.instance_variable_get(:@during_timeout).should == 3*60
         | 
| 113 171 | 
             
                  end
         | 
| 114 172 |  | 
| 115 173 | 
             
                  it "has #minute as an alias" do
         | 
| 116 | 
            -
                    RSpec::Matchers::Matcher.new(nil) {}.within(1).minute.instance_variable_get(:@ | 
| 174 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.within(1).minute.instance_variable_get(:@within_timeout).should == 1*60
         | 
| 175 | 
            +
                    RSpec::Matchers::Matcher.new(nil) {}.during(2).minute.instance_variable_get(:@during_timeout).should == 2*60
         | 
| 117 176 | 
             
                  end
         | 
| 118 177 | 
             
                end
         | 
| 119 178 |  | 
    
        data/spec/spec_helper_spec.rb
    CHANGED
    
    | @@ -1,10 +1,5 @@ | |
| 1 1 | 
             
            describe WatirSplash::SpecHelper do
         | 
| 2 2 |  | 
| 3 | 
            -
              it "opens browser automatically" do
         | 
| 4 | 
            -
                WatirSplash::Util.formatter.browser.should exist
         | 
| 5 | 
            -
                WatirSplash::Util.formatter.browser.url.should == "about:blank"
         | 
| 6 | 
            -
              end
         | 
| 7 | 
            -
             | 
| 8 3 | 
             
              it "redirects method calls to Watir::Browser" do
         | 
| 9 4 | 
             
                goto "http://dl.dropbox.com/u/2731643/WatirSplash/test.html"
         | 
| 10 5 | 
             
                url.should =~ /test/
         | 
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: watirsplash
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 5 | 
            -
              prerelease:  | 
| 4 | 
            +
              hash: 15
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 2
         | 
| 8 8 | 
             
              - 0
         | 
| 9 9 | 
             
              - 0
         | 
| 10 | 
            -
               | 
| 11 | 
            -
              - 2
         | 
| 12 | 
            -
              version: 2.0.0.rc2
         | 
| 10 | 
            +
              version: 2.0.0
         | 
| 13 11 | 
             
            platform: ruby
         | 
| 14 12 | 
             
            authors: 
         | 
| 15 13 | 
             
            - Jarmo Pertman
         | 
| @@ -17,7 +15,7 @@ autorequire: | |
| 17 15 | 
             
            bindir: bin
         | 
| 18 16 | 
             
            cert_chain: []
         | 
| 19 17 |  | 
| 20 | 
            -
            date: 2011-07- | 
| 18 | 
            +
            date: 2011-07-06 00:00:00 Z
         | 
| 21 19 | 
             
            dependencies: 
         | 
| 22 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 23 21 | 
             
              name: rake
         | 
| @@ -135,7 +133,9 @@ files: | |
| 135 133 | 
             
            - lib/watirsplash/spec_helper.rb
         | 
| 136 134 | 
             
            - lib/watirsplash/util.rb
         | 
| 137 135 | 
             
            - lib/watirsplash/version.rb
         | 
| 136 | 
            +
            - spec/browser_spec.rb
         | 
| 138 137 | 
             
            - spec/environment.rb
         | 
| 138 | 
            +
            - spec/page_spec.rb
         | 
| 139 139 | 
             
            - spec/rspec_patches_spec.rb
         | 
| 140 140 | 
             
            - spec/spec_helper_spec.rb
         | 
| 141 141 | 
             
            - spec/spec_match_array_spec.rb
         | 
| @@ -162,23 +162,23 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 162 162 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 163 163 | 
             
              none: false
         | 
| 164 164 | 
             
              requirements: 
         | 
| 165 | 
            -
              - - " | 
| 165 | 
            +
              - - ">="
         | 
| 166 166 | 
             
                - !ruby/object:Gem::Version 
         | 
| 167 | 
            -
                  hash:  | 
| 167 | 
            +
                  hash: 3
         | 
| 168 168 | 
             
                  segments: 
         | 
| 169 | 
            -
                  -  | 
| 170 | 
            -
                   | 
| 171 | 
            -
                  - 1
         | 
| 172 | 
            -
                  version: 1.3.1
         | 
| 169 | 
            +
                  - 0
         | 
| 170 | 
            +
                  version: "0"
         | 
| 173 171 | 
             
            requirements: []
         | 
| 174 172 |  | 
| 175 173 | 
             
            rubyforge_project: 
         | 
| 176 174 | 
             
            rubygems_version: 1.8.4
         | 
| 177 175 | 
             
            signing_key: 
         | 
| 178 176 | 
             
            specification_version: 3
         | 
| 179 | 
            -
            summary: watirsplash 2.0.0 | 
| 177 | 
            +
            summary: watirsplash 2.0.0
         | 
| 180 178 | 
             
            test_files: 
         | 
| 179 | 
            +
            - spec/browser_spec.rb
         | 
| 181 180 | 
             
            - spec/environment.rb
         | 
| 181 | 
            +
            - spec/page_spec.rb
         | 
| 182 182 | 
             
            - spec/rspec_patches_spec.rb
         | 
| 183 183 | 
             
            - spec/spec_helper_spec.rb
         | 
| 184 184 | 
             
            - spec/spec_match_array_spec.rb
         |