chop 0.24.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af7f4ec5f90dbc90ca3dd23f091388583a1f5685a8d2701f56a2779134e07702
4
- data.tar.gz: 019b73dd3bd79756bc5b83acb65b73994cd61875fa1c940bbc6cc9e1ef497ea3
3
+ metadata.gz: ef8e55d7073955552b6c9a2c84fa3557b155932868f819e383bfbe8e324005f7
4
+ data.tar.gz: ffc599c2e17422d296c41e1becc4376624d0ed6942107a39f6b37ac74f092c7c
5
5
  SHA512:
6
- metadata.gz: 308830226d83493873bf32aa8b071b1c006306d875ea146df4b8c7fc1c7b09f105b020cab17fa847b6461ba7dd74a5decd2a1e0fa3788b173311f869e49471c1
7
- data.tar.gz: f7b9d15d9550dc2a3bfc1b0001413a3a735d15296edcf6b89b4b0da95fcb9cacb24dbb6ac2d2ac5a92e43acfa3105570f32a4bb9c59623c8170ca47435518a2d
6
+ metadata.gz: 8bae49072827f854b8d3f82609e91d39cb374d123f12cca8db1b8b2f632076eb355886c00ccb8a8d61eff4d7048501499c45bfed74172879fccef46ca3d78017
7
+ data.tar.gz: 5741000e0fc3764eadbc01d42ded2118648e380af61651421f73f640e6dd11264d6d895b3e73030d7d5b5400b2696e53124eb821bd9eed09ae6f9e43c349ab5a
data/README.md CHANGED
@@ -18,7 +18,7 @@ end
18
18
  Chop monkeypatches Cucumber tables with three new methods:
19
19
 
20
20
  * `#create!`: Creates entities. Built-in support for ActiveRecord (default) and FactoryGirl, at present.
21
- * `#diff!`: Enhances existing method to also accept a CSS selector. Currently supports diffing `<table>`, `<dl>`, `<ul>`, and even `<form>`!.
21
+ * `#diff!`: Enhances existing method to also accept a capybara element, or a CSS selector pointing to one. Currently supports diffing `<table>`, `<dl>`, `<ul>`, and even `<form>`!.
22
22
  * `#fill_in!`: Fills in a form on the current page.
23
23
 
24
24
  All these methods accept blocks for customization.
@@ -157,7 +157,11 @@ module Chop
157
157
 
158
158
  def root
159
159
  @root ||= begin
160
- session.find(selector)
160
+ if selector.is_a?(Capybara::Node::Element)
161
+ selector
162
+ else
163
+ session.find(selector)
164
+ end
161
165
  rescue Capybara::ElementNotFound
162
166
  raise unless @allow_not_found
163
167
  Node("")
@@ -7,7 +7,13 @@ module Chop
7
7
  end
8
8
 
9
9
  def diff! selector, table, session: Capybara.current_session, as: nil, &block
10
- class_name = as ? as.to_s.camelize : session.find(selector).tag_name.camelize
10
+ class_name = if as
11
+ as.to_s
12
+ elsif selector.respond_to?(:tag_name)
13
+ selector.tag_name
14
+ else
15
+ session.find(selector).tag_name
16
+ end.camelize
11
17
  klass = const_get("Chop::#{class_name}")
12
18
  klass.diff! selector, table, session: session, &block
13
19
  end
@@ -25,7 +31,7 @@ if defined?(Cucumber::MultilineArgument::DataTable)
25
31
  end
26
32
 
27
33
  def diff! other_table="table", options={}, &block
28
- if other_table.is_a?(String) && !other_table.include?("|")
34
+ if other_table.respond_to?(:tag_name) || (other_table.is_a?(String) && !other_table.include?("|"))
29
35
  Chop.diff! other_table, self, options, &block
30
36
  else
31
37
  super
@@ -1,3 +1,3 @@
1
1
  module Chop
2
- VERSION = "0.24.0"
2
+ VERSION = "0.25.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2020-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubygems_version: 3.0.4
144
+ rubygems_version: 3.0.3
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Slice and dice your cucumber tables with ease!