elabs_matchers 0.0.7 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -6
- data/{development.txt → development.md} +2 -2
- data/doc/ElabsMatchers/Helpers/Fixtures.html +46 -46
- data/doc/ElabsMatchers/Helpers/NormalizeKeys.html +45 -45
- data/doc/ElabsMatchers/Helpers/ReloadRecord.html +45 -45
- data/doc/ElabsMatchers/Helpers/SelectYearAndMonth.html +48 -48
- data/doc/ElabsMatchers/Helpers.html +40 -40
- data/doc/ElabsMatchers/Matchers/{Allow/AllowMatcher.html → BeValidWith/BeValidWithMatcher.html} +150 -85
- data/doc/ElabsMatchers/Matchers/BeValidWith.html +229 -0
- data/doc/ElabsMatchers/Matchers/ContainHash/ContainHashMatcher.html +80 -67
- data/doc/ElabsMatchers/Matchers/ContainHash.html +51 -51
- data/doc/ElabsMatchers/Matchers/HaveAttribute/HaveAttributeMatcher.html +108 -95
- data/doc/ElabsMatchers/Matchers/HaveAttribute.html +49 -49
- data/doc/ElabsMatchers/Matchers/HaveFields/HaveFieldsMatcher.html +103 -90
- data/doc/ElabsMatchers/Matchers/HaveFields.html +50 -50
- data/doc/ElabsMatchers/Matchers/HaveFlash/HaveFlashMatcher.html +108 -95
- data/doc/ElabsMatchers/Matchers/HaveFlash.html +57 -57
- data/doc/ElabsMatchers/Matchers/HaveFormErrorsOn/HaveFormErrorsOnMatcher.html +110 -97
- data/doc/ElabsMatchers/Matchers/HaveFormErrorsOn.html +49 -49
- data/doc/ElabsMatchers/Matchers/HaveHeader/HaveHeaderMatcher.html +103 -90
- data/doc/ElabsMatchers/Matchers/HaveHeader.html +49 -49
- data/doc/ElabsMatchers/Matchers/HaveImage/HaveImageMatcher.html +104 -91
- data/doc/ElabsMatchers/Matchers/HaveImage.html +49 -49
- data/doc/ElabsMatchers/Matchers/OnlyInclude/OnlyIncludeMatcher.html +79 -66
- data/doc/ElabsMatchers/Matchers/OnlyInclude.html +50 -50
- data/doc/ElabsMatchers/Matchers/Persist/PersistMatcher.html +134 -69
- data/doc/ElabsMatchers/Matchers/Persist.html +49 -49
- data/doc/ElabsMatchers/Matchers.html +42 -42
- data/doc/ElabsMatchers.html +143 -144
- data/doc/_index.html +35 -52
- data/doc/class_list.html +25 -27
- data/doc/css/full_list.css +32 -31
- data/doc/css/style.css +262 -91
- data/doc/file.README.html +91 -87
- data/doc/file_list.html +27 -26
- data/doc/frames.html +10 -21
- data/doc/index.html +91 -87
- data/doc/js/app.js +106 -72
- data/doc/js/full_list.js +170 -127
- data/doc/method_list.html +456 -505
- data/doc/top-level-namespace.html +36 -38
- data/elabs_matchers.gemspec +2 -2
- data/history.txt +11 -0
- data/lib/elabs_matchers/helpers/normalize_keys.rb +1 -1
- data/lib/elabs_matchers/helpers/select_year_and_month.rb +1 -0
- data/lib/elabs_matchers/matchers/be_valid_with.rb +5 -10
- data/lib/elabs_matchers/matchers/contain_hash.rb +4 -2
- data/lib/elabs_matchers/matchers/have_attribute.rb +5 -2
- data/lib/elabs_matchers/matchers/have_fields.rb +5 -2
- data/lib/elabs_matchers/matchers/have_flash.rb +5 -2
- data/lib/elabs_matchers/matchers/have_form_errors_on.rb +5 -2
- data/lib/elabs_matchers/matchers/have_header.rb +5 -2
- data/lib/elabs_matchers/matchers/have_image.rb +5 -2
- data/lib/elabs_matchers/matchers/only_include.rb +14 -2
- data/lib/elabs_matchers/matchers/persist.rb +8 -2
- data/lib/elabs_matchers/version.rb +1 -1
- data/lib/elabs_matchers.rb +0 -1
- data/spec/elabs_matchers/matchers/only_include_spec.rb +13 -0
- data/spec/elabs_matchers/matchers/persist_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -0
- metadata +8 -29
- data/doc/Cucumber.html +0 -116
- data/doc/ElabsMatchers/Cucumber/Common.html +0 -145
- data/doc/ElabsMatchers/Cucumber.html +0 -108
- data/doc/ElabsMatchers/Helpers/Capybara.html +0 -241
- data/doc/ElabsMatchers/Helpers/Common.html +0 -213
- data/doc/ElabsMatchers/Helpers/Orm.html +0 -289
- data/doc/ElabsMatchers/Helpers/Session.html +0 -497
- data/doc/ElabsMatchers/Matchers/Allow.html +0 -229
- data/doc/ElabsMatchers/Matchers/Capybara/Common.html +0 -1159
- data/doc/ElabsMatchers/Matchers/Capybara.html +0 -108
- data/doc/ElabsMatchers/Matchers/HaveTableRow/HaveTableRowMatcher.html +0 -654
- data/doc/ElabsMatchers/Matchers/HaveTableRow.html +0 -236
- data/doc/ElabsMatchers/Matchers/Rspec/Allow.html +0 -98
- data/doc/ElabsMatchers/Matchers/Rspec/Common.html +0 -332
- data/doc/ElabsMatchers/Matchers/Rspec/Orm.html +0 -231
- data/doc/ElabsMatchers/Matchers/Rspec.html +0 -110
- data/doc/ElabsMatchers/Orm/Post.html +0 -1041
- data/doc/ElabsMatchers/Orm.html +0 -108
- data/lib/elabs_matchers/matchers/have_table_row.rb +0 -124
- data/spec/elabs_matchers/matchers/have_table_row_spec.rb +0 -119
data/doc/ElabsMatchers/Orm.html
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
-
<title>
|
7
|
-
Module: ElabsMatchers::Orm
|
8
|
-
|
9
|
-
— Documentation by YARD 0.7.5
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
relpath = '..';
|
19
|
-
if (relpath != '') relpath += '/';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
23
|
-
|
24
|
-
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
25
|
-
|
26
|
-
|
27
|
-
</head>
|
28
|
-
<body>
|
29
|
-
<script type="text/javascript" charset="utf-8">
|
30
|
-
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
-
</script>
|
32
|
-
|
33
|
-
<div id="header">
|
34
|
-
<div id="menu">
|
35
|
-
|
36
|
-
<a href="../_index.html">Index (O)</a> »
|
37
|
-
<span class='title'><span class='object_link'><a href="../ElabsMatchers.html" title="ElabsMatchers (module)">ElabsMatchers</a></span></span>
|
38
|
-
»
|
39
|
-
<span class="title">Orm</span>
|
40
|
-
|
41
|
-
|
42
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
-
</div>
|
44
|
-
|
45
|
-
<div id="search">
|
46
|
-
|
47
|
-
<a id="class_list_link" href="#">Class List</a>
|
48
|
-
|
49
|
-
<a id="method_list_link" href="#">Method List</a>
|
50
|
-
|
51
|
-
<a id="file_list_link" href="#">File List</a>
|
52
|
-
|
53
|
-
</div>
|
54
|
-
<div class="clear"></div>
|
55
|
-
</div>
|
56
|
-
|
57
|
-
<iframe id="search_frame"></iframe>
|
58
|
-
|
59
|
-
<div id="content"><h1>Module: ElabsMatchers::Orm
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
</h1>
|
64
|
-
|
65
|
-
<dl class="box">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
<dt class="r1 last">Defined in:</dt>
|
75
|
-
<dd class="r1 last">lib/elabs_matchers/orm/post.rb</dd>
|
76
|
-
|
77
|
-
</dl>
|
78
|
-
<div class="clear"></div>
|
79
|
-
|
80
|
-
<h2>Defined Under Namespace</h2>
|
81
|
-
<p class="children">
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Orm/Post.html" title="ElabsMatchers::Orm::Post (class)">Post</a></span>
|
87
|
-
|
88
|
-
|
89
|
-
</p>
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
</div>
|
100
|
-
|
101
|
-
<div id="footer">
|
102
|
-
Generated on Fri Feb 17 16:29:16 2012 by
|
103
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
104
|
-
0.7.5 (ruby-1.9.3).
|
105
|
-
</div>
|
106
|
-
|
107
|
-
</body>
|
108
|
-
</html>
|
@@ -1,124 +0,0 @@
|
|
1
|
-
module ElabsMatchers
|
2
|
-
module Matchers
|
3
|
-
module HaveTableRow
|
4
|
-
rspec :type => :request
|
5
|
-
rspec :type => :feature
|
6
|
-
|
7
|
-
class HaveTableRowMatcher < Struct.new(:table_name, :row)
|
8
|
-
attr_reader :page
|
9
|
-
|
10
|
-
def matches?(page)
|
11
|
-
@page = page
|
12
|
-
table and table.has_selector?(selector_type, selector)
|
13
|
-
end
|
14
|
-
|
15
|
-
def does_not_match?(page)
|
16
|
-
@page = page
|
17
|
-
!table or table.has_no_selector?(selector_type, selector)
|
18
|
-
end
|
19
|
-
|
20
|
-
def failure_message_for_should
|
21
|
-
"Expected #{row.inspect} to be included in the table #{table_name}, but it wasn't:\n\n#{ascii_table}"
|
22
|
-
end
|
23
|
-
|
24
|
-
def failure_message_for_should_not
|
25
|
-
"Expected there to be no table #{table_name} with row #{row.inspect}, but there was.\n\n#{ascii_table}"
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def selector_type
|
31
|
-
:xpath
|
32
|
-
end
|
33
|
-
|
34
|
-
def selector
|
35
|
-
if ElabsMatchers.table_row_selector
|
36
|
-
ElabsMatchers.table_row_selector[row, table]
|
37
|
-
else
|
38
|
-
exps = row.map do |header, value|
|
39
|
-
col_index = table.all("th").to_a.index { |th| th.text.include?(header.to_s) }
|
40
|
-
col_index = if col_index then col_index + 1 else 0 end
|
41
|
-
|
42
|
-
XPath.generate do |x|
|
43
|
-
cell = x.child(:td, :th)[col_index.to_s.to_sym]
|
44
|
-
|
45
|
-
if value.blank?
|
46
|
-
cell["not(node())".to_sym].or(cell.descendant(:input)["string-length(normalize-space(@value))=0".to_sym])
|
47
|
-
else
|
48
|
-
cell[x.contains(value).or(x.descendant(:input)[x.attr(:value).contains(value)])]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
XPath.descendant(:tr)[exps.reduce(:&)]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def table
|
58
|
-
table_xpath = XPath::HTML.table(table_name)
|
59
|
-
|
60
|
-
if page.has_xpath?(table_xpath)
|
61
|
-
page.find(:xpath, table_xpath)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def ascii_table
|
66
|
-
synchronize do
|
67
|
-
if table
|
68
|
-
column_lengths = []
|
69
|
-
table.all("tr").map do |tr|
|
70
|
-
tr.all("td,th").each_with_index do |td, i|
|
71
|
-
size = td_content(td).strip.size
|
72
|
-
if (column_lengths[i] || 0) < size
|
73
|
-
column_lengths[i] = size
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
table.all("tr").map do |tr|
|
79
|
-
middle = []
|
80
|
-
space = if tr.all("td,th").first.tag_name == "th" then "_" else " " end
|
81
|
-
wall = "|"
|
82
|
-
|
83
|
-
tr.all("td,th").each_with_index do |td, i|
|
84
|
-
middle << td_content(td).strip.ljust(column_lengths[i], space)
|
85
|
-
end
|
86
|
-
|
87
|
-
[wall, space, middle.join(space + wall + space), space, wall].join
|
88
|
-
end.join("\n")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def td_content(td)
|
94
|
-
text = td.text.presence
|
95
|
-
text ||= td.find("input, textarea")[:value] if td.has_css?("input")
|
96
|
-
text || ""
|
97
|
-
end
|
98
|
-
|
99
|
-
def synchronize
|
100
|
-
if page.respond_to?(:document)
|
101
|
-
page.document.synchronize { yield }
|
102
|
-
else
|
103
|
-
yield
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
##
|
110
|
-
#
|
111
|
-
# Asserts if the supplied table row exists in the table
|
112
|
-
#
|
113
|
-
# @param [String] table_name The tables's caption text.
|
114
|
-
# @param [Hash] row A hash representing the column name and value in key-value form.
|
115
|
-
#
|
116
|
-
# Example:
|
117
|
-
# table.should have_table_row("Posts", "Title" => "First", :year => "2012")
|
118
|
-
|
119
|
-
def have_table_row(table_name, row)
|
120
|
-
HaveTableRowMatcher.new(table_name, row)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe ElabsMatchers::Matchers::HaveTableRow, :type => :feature do
|
4
|
-
describe "#have_table_row" do
|
5
|
-
let(:header) { %Q{
|
6
|
-
<caption>Posts</caption>
|
7
|
-
<thead>
|
8
|
-
<tr><th>Title</th><th>Author</th></tr>
|
9
|
-
</thead>} }
|
10
|
-
subject { Capybara.string("<table>" + header + "<tbody>" + html + "</tbody></table>") }
|
11
|
-
|
12
|
-
shared_examples "a table row matcher" do
|
13
|
-
it "returns true when the one of the pairs in the row exists" do
|
14
|
-
should have_table_row("Posts", "Title" => "First")
|
15
|
-
expect { should have_table_row("Posts", "Foo" => "First") }.to fail_assertion
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns true when the all of the pairs in the row exists" do
|
19
|
-
should have_table_row("Posts", "Title" => "First", "Author" => "Adam")
|
20
|
-
expect { should have_table_row("Posts", "Title" => "First", "Author" => "Second") }.to fail_assertion
|
21
|
-
end
|
22
|
-
|
23
|
-
it "returns false when the header is wrong and the value is correct" do
|
24
|
-
should_not have_table_row("Posts", "Label" => "First")
|
25
|
-
expect { should_not have_table_row("Posts", "Title" => "First") }.to fail_assertion
|
26
|
-
end
|
27
|
-
|
28
|
-
it "returns false when the header is correct and the value is wrong" do
|
29
|
-
should_not have_table_row("Posts", "Title" => "Forth")
|
30
|
-
expect { should have_table_row("Posts", "Author" => "First") }.to fail_assertion
|
31
|
-
end
|
32
|
-
|
33
|
-
it "returns false when on of the pairs is wrong" do
|
34
|
-
should_not have_table_row("Posts", "Title" => "First", "Author" => "David")
|
35
|
-
expect { should have_table_row("Posts", "Title" => "First", "Author" => "David") }.to fail_assertion
|
36
|
-
end
|
37
|
-
|
38
|
-
it "returns false when given the value of another column" do
|
39
|
-
should_not have_table_row("Posts", "Title" => "Adam")
|
40
|
-
expect { should have_table_row("Posts", "Title" => "Adam") }.to fail_assertion
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns true when asking for existing blank value" do
|
44
|
-
should have_table_row("Posts", "Author" => "")
|
45
|
-
expect { should have_table_row("Posts", "Third" => "not empty") }.to fail_assertion
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns false when asking for non-existing blank value" do
|
49
|
-
should_not have_table_row("Posts", "Title" => "")
|
50
|
-
expect { should have_table_row("Posts", "Title" => "") }.to fail_assertion
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns false if there is no matching table" do
|
54
|
-
should_not have_table_row("Other", "Title" => "First")
|
55
|
-
expect { should_not have_table_row("Posts", "Title" => "First") }.to fail_assertion
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "with text node values" do
|
60
|
-
it_behaves_like "a table row matcher" do
|
61
|
-
let(:html) { %Q{
|
62
|
-
<tr><td>First</td><td>Adam</td></tr>
|
63
|
-
<tr><td>Second</td><td>David</td></tr>
|
64
|
-
<tr><td>Third</td><td></td></tr>}
|
65
|
-
}
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with input field values" do
|
70
|
-
it_behaves_like "a table row matcher" do
|
71
|
-
let(:html) { %Q{
|
72
|
-
<tr>
|
73
|
-
<td><input type="text" value="First" /></td>
|
74
|
-
<td><input type="text" value="Adam" /></td>
|
75
|
-
</tr>
|
76
|
-
<tr>
|
77
|
-
<td><input type="text" value="Second" /></td>
|
78
|
-
<td><input type="text" value="David" /></td>
|
79
|
-
</tr>
|
80
|
-
<tr>
|
81
|
-
<td><input type="text" value="Third" /></td>
|
82
|
-
<td><input type="text" value="" /></td>
|
83
|
-
</tr>}
|
84
|
-
}
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context "configured with xpath selecto" do
|
89
|
-
before do
|
90
|
-
ElabsMatchers.table_row_selector = lambda do |row, table|
|
91
|
-
exps = row.map do |header, value|
|
92
|
-
col_index = table.all("th").to_a.index { |th| th.text.include?(header.to_s) }
|
93
|
-
col_index = if col_index then col_index + 1 else 0 end
|
94
|
-
|
95
|
-
XPath.generate do |x|
|
96
|
-
cell = x.child(:td, :th)[col_index.to_s.to_sym]
|
97
|
-
|
98
|
-
if value.blank?
|
99
|
-
cell.child(:span)["not(node())".to_sym]
|
100
|
-
else
|
101
|
-
cell.child(:span)[x.contains(value)]
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
XPath.descendant["tr"][exps.reduce(:&)]
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
it_behaves_like "a table row matcher" do
|
111
|
-
let(:html) { %Q{
|
112
|
-
<tr><td><span>First<span></td><td><span>Adam<span></td></tr>
|
113
|
-
<tr><td><span>Second<span></td><td><span>David<span></td></tr>
|
114
|
-
<tr><td><span>Third<span></td><td><span></span></td></tr>}
|
115
|
-
}
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|