watir_pump 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -0
- data/lib/watir_pump/component.rb +27 -0
- data/lib/watir_pump/component_collection.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46afc438adf0692f8cf253804f031984e6d4d068067168a81c964a3b8291387e
|
4
|
+
data.tar.gz: f965db8f63df648b50c7a731d7a4c3300187f93fe6f84f68625d4801421d2240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e17dc240658a4ac2da38fdbcacbfaba31a5401703d65a14d658c292c28ee09df4765955206c47c234fb3c5743c1415e5e90c7bb80412c2e242cd33bbe15e010
|
7
|
+
data.tar.gz: 6ba704ad7c61a2316e128fb3be63c96c49f0531760a34b201c96c796749cf973e6fe8c70531c59f3c66b69d7c14580a8aaf9190d67f852f23a592252deed0a52
|
data/README.md
CHANGED
@@ -917,6 +917,33 @@ There's a few methods that components forward directly to its root:
|
|
917
917
|
|
918
918
|
Thanks to this one can write just `comp.present?` instead of `comp.root.present?`.
|
919
919
|
|
920
|
+
### Customized `inspect` method
|
921
|
+
|
922
|
+
This features is especially useful when using WatirPump with testing frameworks like `rspec`.
|
923
|
+
|
924
|
+
Consider the following example:
|
925
|
+
|
926
|
+
```ruby
|
927
|
+
class MyComponent < WatirPump::Component
|
928
|
+
span_reader :name, id: 'name'
|
929
|
+
span_reader :surname, id: 'surname'
|
930
|
+
span_reader :age, id: 'age'
|
931
|
+
inspect_properties [:name, :surname, :age]
|
932
|
+
end
|
933
|
+
|
934
|
+
class HomePage < WatirPump::Page
|
935
|
+
component :details, MyComponent
|
936
|
+
end
|
937
|
+
|
938
|
+
MyPage.open do
|
939
|
+
expect(details).to have_attributes(name: 'John', surname: 'Smith')
|
940
|
+
end
|
941
|
+
```
|
942
|
+
|
943
|
+
In case of expectation (here: `have_attributes`) not matched `rspec` will display the `expected` and `got` values.
|
944
|
+
Without the usage of `inspect_properties` the default implementation of `inspect` would be used, and it's not
|
945
|
+
very useful for test debugging since it's too verbose. Use `inspect_properties` to have your `rspec` logs easy to work with.
|
946
|
+
|
920
947
|
## Region aka anonymous component
|
921
948
|
|
922
949
|
If certain HTML section appears only on one page (thus there's no point in creating another `Component` class)
|
data/lib/watir_pump/component.rb
CHANGED
@@ -329,6 +329,24 @@ module WatirPump
|
|
329
329
|
end
|
330
330
|
end
|
331
331
|
end
|
332
|
+
|
333
|
+
# Define the customized `inspect` method
|
334
|
+
# that will return the desired properties
|
335
|
+
# Useful especially when working with testing frameworks that
|
336
|
+
# inspect the object under test in case of expectations not being met
|
337
|
+
#
|
338
|
+
# @param [Symbol] properties (methods) to be included in the result
|
339
|
+
#
|
340
|
+
# @return Hash
|
341
|
+
def inspect_properties(properties)
|
342
|
+
define_method :inspect do
|
343
|
+
ret = {}
|
344
|
+
properties.each do |p|
|
345
|
+
ret[p] = public_send(p)
|
346
|
+
end
|
347
|
+
ret
|
348
|
+
end
|
349
|
+
end
|
332
350
|
end # << self
|
333
351
|
|
334
352
|
# Invoked implicity by WatirPump framework.
|
@@ -412,6 +430,15 @@ module WatirPump
|
|
412
430
|
end
|
413
431
|
end
|
414
432
|
|
433
|
+
# Customized Ruby's object inspection method
|
434
|
+
#
|
435
|
+
# @return String
|
436
|
+
def inspect
|
437
|
+
# rubocop:disable Metrics/LineLength
|
438
|
+
"<#{self.class.name} parent: #{parent.class.name} methods: #{public_methods(false).join(', ')}>"
|
439
|
+
# rubocop:enable Metrics/LineLength
|
440
|
+
end
|
441
|
+
|
415
442
|
private
|
416
443
|
|
417
444
|
def form_field_writers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir_pump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|