marty_rspec 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6561535ced695e713a4c2aacb6a9e466019c2185
4
- data.tar.gz: 0c034a62ed8e12a41ab5006d715a625f930ad12f
3
+ metadata.gz: 29a66ed63853c3aaa6307a27d2e8926054d8d1ce
4
+ data.tar.gz: 7bd7daa4ebf6a9a609cd8a03f96adf1a65b63fa3
5
5
  SHA512:
6
- metadata.gz: e9c19c974199c52acf44de92a9abc5f2dc83360d9b0170c0fbb46f9156f0eaf86f4792974fde6a59bfaa5453801b5d93bf8f4a37d687c1665cc5d4d3bbff281e
7
- data.tar.gz: 6f7d07317c44ec96cdbc1e464cbb90a6ec93cf1e4710b703a16375721dcb68ca731ed6369d7192afa2c7528a374b71dd6df4bef80a854ed5fa4b3a6d7901c1d9
6
+ metadata.gz: e6298731dd50d8b1db4e5bee9b6f364932f66bb2cf748657ea7590885baaccc30689220f65e00045d805e7e806cf191f4dd110b185e656a9baf8fca376586462
7
+ data.tar.gz: 2a96e0b2aefa3368621a28f00e0e403c151d37ca4212730308b41052bc7456c6b3e28704d31a897b9fda67410b5b9cff57585431cf4bd9dcddcec5020611abb1
@@ -1,26 +1,10 @@
1
- Capybara.add_selector(:gridpanel) do
2
- xpath { |name| ".//div[contains(@id, '#{name}')] | " +
3
- ".//div[contains(@id, '#{name.camelize(:lower)}')]" }
1
+ RSpec::Matchers.define :netzke_include do |expected|
2
+ match do |actual|
3
+ parsed_values = actual.each_with_object({}) do | (k, v), h |
4
+ h[k] = v == "False" ? false : v
5
+ end
6
+ expect(parsed_values).to include(expected.stringify_keys)
7
+ end
8
+
9
+ diffable
4
10
  end
5
- Capybara.add_selector(:msg) do
6
- xpath { "//div[@id='msg-div']" }
7
- end
8
- Capybara.add_selector(:body) do
9
- xpath { ".//div[@data-ref='body']" }
10
- end
11
- Capybara.add_selector(:input) do
12
- xpath { |name| "//input[@name='#{name}']" }
13
- end
14
- Capybara.add_selector(:status) do
15
- xpath { |name| "//div[contains(@id, 'statusbar')]//div[text()='#{name}']" }
16
- end
17
- Capybara.add_selector(:btn) do
18
- xpath { |name| ".//span[text()='#{name}']" }
19
- end
20
- Capybara.add_selector(:refresh) do
21
- xpath { "//img[contains(@class, 'x-tool-refresh')]" }
22
- end
23
- Capybara.add_selector(:gridcolumn) do
24
- xpath { |name| ".//span[contains(@class, 'x-column-header')]" +
25
- "//span[text()='#{name}']" }
26
- end
@@ -0,0 +1,26 @@
1
+ Capybara.add_selector(:gridpanel) do
2
+ xpath { |name| ".//div[contains(@id, '#{name}')] | " +
3
+ ".//div[contains(@id, '#{name.camelize(:lower)}')]" }
4
+ end
5
+ Capybara.add_selector(:msg) do
6
+ xpath { "//div[@id='msg-div']" }
7
+ end
8
+ Capybara.add_selector(:body) do
9
+ xpath { ".//div[@data-ref='body']" }
10
+ end
11
+ Capybara.add_selector(:input) do
12
+ xpath { |name| "//input[@name='#{name}']" }
13
+ end
14
+ Capybara.add_selector(:status) do
15
+ xpath { |name| "//div[contains(@id, 'statusbar')]//div[text()='#{name}']" }
16
+ end
17
+ Capybara.add_selector(:btn) do
18
+ xpath { |name| ".//span[text()='#{name}']" }
19
+ end
20
+ Capybara.add_selector(:refresh) do
21
+ xpath { "//img[contains(@class, 'x-tool-refresh')]" }
22
+ end
23
+ Capybara.add_selector(:gridcolumn) do
24
+ xpath { |name| ".//span[contains(@class, 'x-column-header')]" +
25
+ "//span[text()='#{name}']" }
26
+ end
@@ -1,4 +1,5 @@
1
1
  require 'capybara/dsl'
2
+ require 'rspec/matchers'
2
3
 
3
4
  module MartyRSpec
4
5
  module NetzkeGrid
@@ -109,34 +110,20 @@ module MartyRSpec
109
110
  JS
110
111
  end
111
112
 
112
- def validate_row_values row, fields
113
- js_get_fields = fields.each_key.map do |k|
114
- <<-JS
115
- var col = Ext.ComponentQuery.query('gridcolumn[name=\"#{k}\"]', grid)[0];
116
- var value = col.assoc ? r.get('association_values')['#{k}'] :
117
- r.get('#{k}');
118
- if (value instanceof Date) {
119
- obj['#{k}'] = value.toISOString().substring(0,
120
- value.toISOString().indexOf('T'));
121
- } else {
122
- obj['#{k}'] = value;
123
- };
124
- JS
125
- end.join
126
-
113
+ def get_row_vals row
127
114
  res = run_js <<-JS
128
115
  #{ext_var(grid, 'grid')}
129
- #{ext_var(ext_row(row.to_i - 1, 'grid'), 'r')}
130
- var obj = {};
131
- #{js_get_fields}
132
- return obj;
116
+ return #{ext_row(row.to_i - 1, 'grid')}.data;
133
117
  JS
118
+ end
134
119
 
120
+ def validate_row_values row, fields
121
+ res = get_row_vals(row)
135
122
  # in netzke 1.0, "False" becomes false
136
- expected_value = fields.each_with_object({}) do | (k, v), h |
137
- h[k.to_s] = v == "False" ? false : v
138
- end
139
- wait_for_element { expect(res).to eq(expected_value) }
123
+ # DEPRECATED: use custom matcher :have_netzke_fields, as below
124
+ warn "[DEPRECATED] use expect(<<GRID OBJECT>>.get_row_vals(#{row}))." +
125
+ "to netzke_include(#{fields})"
126
+ wait_for_element { expect(res).to netzke_include(fields) }
140
127
  end
141
128
 
142
129
  def sorted_by? col, direction = 'asc'
@@ -146,7 +133,7 @@ module MartyRSpec
146
133
  var colValues = [];
147
134
 
148
135
  grid.getStore().each(function(r){
149
- var val = col.assoc ? r.get('association_values)['#{col}'] :
136
+ var val = col.assoc ? r.get('association_values')['#{col}'] :
150
137
  r.get('#{col}');
151
138
  if (val) colValues.#{direction == 'asc' ? 'push' : 'unshift'}(val);
152
139
  });
@@ -1,3 +1,3 @@
1
1
  module MartyRSpec
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/marty_rspec.rb CHANGED
@@ -2,3 +2,4 @@ require 'marty_rspec/version'
2
2
  require 'marty_rspec/util'
3
3
  require 'marty_rspec/netzke_grid'
4
4
  require 'marty_rspec/custom_matchers'
5
+ require 'marty_rspec/custom_selectors'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marty_rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Matsuo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -37,6 +37,7 @@ files:
37
37
  - Rakefile
38
38
  - lib/marty_rspec.rb
39
39
  - lib/marty_rspec/custom_matchers.rb
40
+ - lib/marty_rspec/custom_selectors.rb
40
41
  - lib/marty_rspec/netzke_grid.rb
41
42
  - lib/marty_rspec/util.rb
42
43
  - lib/marty_rspec/version.rb