spreewald 0.1.0 → 0.1.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/lib/spreewald/web_steps.rb +50 -9
- data/lib/spreewald_support/version.rb +1 -1
- metadata +7 -6
    
        data/lib/spreewald/web_steps.rb
    CHANGED
    
    | @@ -312,15 +312,56 @@ When /^I reload the page$/ do | |
| 312 312 | 
             
            end
         | 
| 313 313 |  | 
| 314 314 | 
             
            Then /^"([^\"]+)" should( not)? be visible$/ do |text, negate|
         | 
| 315 | 
            -
               | 
| 316 | 
            -
             | 
| 317 | 
            -
                 | 
| 318 | 
            -
             | 
| 319 | 
            -
             | 
| 320 | 
            -
             | 
| 321 | 
            -
             | 
| 322 | 
            -
             | 
| 323 | 
            -
             | 
| 315 | 
            +
              case Capybara::current_driver
         | 
| 316 | 
            +
              when :selenium, :webkit
         | 
| 317 | 
            +
                visibility_detecting_javascript = %[
         | 
| 318 | 
            +
                  (function() {
         | 
| 319 | 
            +
             | 
| 320 | 
            +
                    var containsSelector = ':contains(#{text.to_json})';
         | 
| 321 | 
            +
                    var jqueryLoaded = (typeof jQuery != 'undefined');
         | 
| 322 | 
            +
             | 
| 323 | 
            +
                    function findCandidates() {
         | 
| 324 | 
            +
                      if (jqueryLoaded) {
         | 
| 325 | 
            +
                        return $(containsSelector);
         | 
| 326 | 
            +
                      } else {
         | 
| 327 | 
            +
                        return $$(containsSelector);
         | 
| 328 | 
            +
                      }
         | 
| 329 | 
            +
                    }
         | 
| 330 | 
            +
             | 
| 331 | 
            +
                    function isExactCandidate(candidate) {
         | 
| 332 | 
            +
                      if (jqueryLoaded) {
         | 
| 333 | 
            +
                        return $(candidate).children().find(containsSelector).length == 0;
         | 
| 334 | 
            +
                      } else {
         | 
| 335 | 
            +
                        return candidate.select(containsSelector).length == 0;
         | 
| 336 | 
            +
                      }
         | 
| 337 | 
            +
                    }
         | 
| 338 | 
            +
             | 
| 339 | 
            +
                    function elementVisible(element) {
         | 
| 340 | 
            +
                      if (jqueryLoaded) {
         | 
| 341 | 
            +
                        return $(element).is(':visible');
         | 
| 342 | 
            +
                      } else {
         | 
| 343 | 
            +
                        return element.offsetWidth > 0 && element.offsetHeight > 0;
         | 
| 344 | 
            +
                      }
         | 
| 345 | 
            +
                    }
         | 
| 346 | 
            +
             | 
| 347 | 
            +
                    var candidates = findCandidates();
         | 
| 348 | 
            +
             | 
| 349 | 
            +
                    for (var i = 0; i < candidates.length; i++) {
         | 
| 350 | 
            +
                      var candidate = candidates[i];
         | 
| 351 | 
            +
                      if (isExactCandidate(candidate) && elementVisible(candidate)) {
         | 
| 352 | 
            +
                        return true;
         | 
| 353 | 
            +
                      }
         | 
| 354 | 
            +
                    }
         | 
| 355 | 
            +
                    return false;
         | 
| 356 | 
            +
             | 
| 357 | 
            +
                  })();
         | 
| 358 | 
            +
                ].gsub(/\n/, ' ')
         | 
| 359 | 
            +
                matcher = negate ? be_false : be_true
         | 
| 360 | 
            +
                page.evaluate_script(visibility_detecting_javascript).should matcher
         | 
| 361 | 
            +
              else
         | 
| 362 | 
            +
                invisibility_detecting_matcher = have_css('.hidden, .invisible, [style~="display: none"]', :text => text)
         | 
| 363 | 
            +
                expectation = negate ? :should : :should_not # sic
         | 
| 364 | 
            +
                page.send(expectation, invisibility_detecting_matcher)
         | 
| 324 365 | 
             
              end
         | 
| 325 366 | 
             
            end
         | 
| 326 367 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: spreewald
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 25
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 1
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.1. | 
| 9 | 
            +
              - 1
         | 
| 10 | 
            +
              version: 0.1.1
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Tobias Kraze
         | 
| @@ -15,7 +15,8 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2012- | 
| 18 | 
            +
            date: 2012-10-26 00:00:00 +02:00
         | 
| 19 | 
            +
            default_executable: 
         | 
| 19 20 | 
             
            dependencies: 
         | 
| 20 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 21 22 | 
             
              name: cucumber-rails
         | 
| @@ -91,6 +92,7 @@ files: | |
| 91 92 | 
             
            - lib/spreewald_support/tolerance_for_selenium_sync_issues.rb
         | 
| 92 93 | 
             
            - lib/spreewald_support/version.rb
         | 
| 93 94 | 
             
            - spreewald.gemspec
         | 
| 95 | 
            +
            has_rdoc: true
         | 
| 94 96 | 
             
            homepage: https://github.com/makandra/spreewald
         | 
| 95 97 | 
             
            licenses: []
         | 
| 96 98 |  | 
| @@ -120,10 +122,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 120 122 | 
             
            requirements: []
         | 
| 121 123 |  | 
| 122 124 | 
             
            rubyforge_project: 
         | 
| 123 | 
            -
            rubygems_version: 1. | 
| 125 | 
            +
            rubygems_version: 1.3.9.5
         | 
| 124 126 | 
             
            signing_key: 
         | 
| 125 127 | 
             
            specification_version: 3
         | 
| 126 128 | 
             
            summary: Collection of useful cucumber steps.
         | 
| 127 129 | 
             
            test_files: []
         | 
| 128 130 |  | 
| 129 | 
            -
            has_rdoc: 
         |