spreewald 0.3.1 → 0.3.2
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 +37 -35
- data/lib/spreewald_support/version.rb +1 -1
- metadata +4 -4
data/lib/spreewald/web_steps.rb
CHANGED
@@ -373,50 +373,52 @@ end
|
|
373
373
|
Then /^"([^\"]+)" should( not)? be visible$/ do |text, negate|
|
374
374
|
case Capybara::current_driver
|
375
375
|
when :selenium, :webkit
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
376
|
+
patiently do
|
377
|
+
visibility_detecting_javascript = %[
|
378
|
+
(function() {
|
379
|
+
|
380
|
+
var containsSelector = ':contains(#{text.to_json})';
|
381
|
+
var jqueryLoaded = (typeof jQuery != 'undefined');
|
382
|
+
|
383
|
+
function findCandidates() {
|
384
|
+
if (jqueryLoaded) {
|
385
|
+
return $(containsSelector);
|
386
|
+
} else {
|
387
|
+
return $$(containsSelector);
|
388
|
+
}
|
387
389
|
}
|
388
|
-
}
|
389
390
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
391
|
+
function isExactCandidate(candidate) {
|
392
|
+
if (jqueryLoaded) {
|
393
|
+
return $(candidate).find(containsSelector).length == 0;
|
394
|
+
} else {
|
395
|
+
return candidate.select(containsSelector).length == 0;
|
396
|
+
}
|
395
397
|
}
|
396
|
-
}
|
397
398
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
399
|
+
function elementVisible(element) {
|
400
|
+
if (jqueryLoaded) {
|
401
|
+
return $(element).is(':visible');
|
402
|
+
} else {
|
403
|
+
return element.offsetWidth > 0 && element.offsetHeight > 0;
|
404
|
+
}
|
403
405
|
}
|
404
|
-
}
|
405
406
|
|
406
|
-
|
407
|
+
var candidates = findCandidates();
|
407
408
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
409
|
+
for (var i = 0; i < candidates.length; i++) {
|
410
|
+
var candidate = candidates[i];
|
411
|
+
if (isExactCandidate(candidate) && elementVisible(candidate)) {
|
412
|
+
return true;
|
413
|
+
}
|
412
414
|
}
|
413
|
-
|
414
|
-
return false;
|
415
|
+
return false;
|
415
416
|
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
417
|
+
})();
|
418
|
+
].gsub(/\n/, ' ')
|
419
|
+
matcher = negate ? be_false : be_true
|
420
|
+
page.evaluate_script(visibility_detecting_javascript).should matcher
|
421
|
+
end
|
420
422
|
else
|
421
423
|
invisibility_detecting_matcher = have_css('.hidden, .invisible, [style~="display: none"]', :text => text)
|
422
424
|
expectation = negate ? :should : :should_not # sic
|
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: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tobias Kraze
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-13 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|