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.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -6
  3. data/{development.txt → development.md} +2 -2
  4. data/doc/ElabsMatchers/Helpers/Fixtures.html +46 -46
  5. data/doc/ElabsMatchers/Helpers/NormalizeKeys.html +45 -45
  6. data/doc/ElabsMatchers/Helpers/ReloadRecord.html +45 -45
  7. data/doc/ElabsMatchers/Helpers/SelectYearAndMonth.html +48 -48
  8. data/doc/ElabsMatchers/Helpers.html +40 -40
  9. data/doc/ElabsMatchers/Matchers/{Allow/AllowMatcher.html → BeValidWith/BeValidWithMatcher.html} +150 -85
  10. data/doc/ElabsMatchers/Matchers/BeValidWith.html +229 -0
  11. data/doc/ElabsMatchers/Matchers/ContainHash/ContainHashMatcher.html +80 -67
  12. data/doc/ElabsMatchers/Matchers/ContainHash.html +51 -51
  13. data/doc/ElabsMatchers/Matchers/HaveAttribute/HaveAttributeMatcher.html +108 -95
  14. data/doc/ElabsMatchers/Matchers/HaveAttribute.html +49 -49
  15. data/doc/ElabsMatchers/Matchers/HaveFields/HaveFieldsMatcher.html +103 -90
  16. data/doc/ElabsMatchers/Matchers/HaveFields.html +50 -50
  17. data/doc/ElabsMatchers/Matchers/HaveFlash/HaveFlashMatcher.html +108 -95
  18. data/doc/ElabsMatchers/Matchers/HaveFlash.html +57 -57
  19. data/doc/ElabsMatchers/Matchers/HaveFormErrorsOn/HaveFormErrorsOnMatcher.html +110 -97
  20. data/doc/ElabsMatchers/Matchers/HaveFormErrorsOn.html +49 -49
  21. data/doc/ElabsMatchers/Matchers/HaveHeader/HaveHeaderMatcher.html +103 -90
  22. data/doc/ElabsMatchers/Matchers/HaveHeader.html +49 -49
  23. data/doc/ElabsMatchers/Matchers/HaveImage/HaveImageMatcher.html +104 -91
  24. data/doc/ElabsMatchers/Matchers/HaveImage.html +49 -49
  25. data/doc/ElabsMatchers/Matchers/OnlyInclude/OnlyIncludeMatcher.html +79 -66
  26. data/doc/ElabsMatchers/Matchers/OnlyInclude.html +50 -50
  27. data/doc/ElabsMatchers/Matchers/Persist/PersistMatcher.html +134 -69
  28. data/doc/ElabsMatchers/Matchers/Persist.html +49 -49
  29. data/doc/ElabsMatchers/Matchers.html +42 -42
  30. data/doc/ElabsMatchers.html +143 -144
  31. data/doc/_index.html +35 -52
  32. data/doc/class_list.html +25 -27
  33. data/doc/css/full_list.css +32 -31
  34. data/doc/css/style.css +262 -91
  35. data/doc/file.README.html +91 -87
  36. data/doc/file_list.html +27 -26
  37. data/doc/frames.html +10 -21
  38. data/doc/index.html +91 -87
  39. data/doc/js/app.js +106 -72
  40. data/doc/js/full_list.js +170 -127
  41. data/doc/method_list.html +456 -505
  42. data/doc/top-level-namespace.html +36 -38
  43. data/elabs_matchers.gemspec +2 -2
  44. data/history.txt +11 -0
  45. data/lib/elabs_matchers/helpers/normalize_keys.rb +1 -1
  46. data/lib/elabs_matchers/helpers/select_year_and_month.rb +1 -0
  47. data/lib/elabs_matchers/matchers/be_valid_with.rb +5 -10
  48. data/lib/elabs_matchers/matchers/contain_hash.rb +4 -2
  49. data/lib/elabs_matchers/matchers/have_attribute.rb +5 -2
  50. data/lib/elabs_matchers/matchers/have_fields.rb +5 -2
  51. data/lib/elabs_matchers/matchers/have_flash.rb +5 -2
  52. data/lib/elabs_matchers/matchers/have_form_errors_on.rb +5 -2
  53. data/lib/elabs_matchers/matchers/have_header.rb +5 -2
  54. data/lib/elabs_matchers/matchers/have_image.rb +5 -2
  55. data/lib/elabs_matchers/matchers/only_include.rb +14 -2
  56. data/lib/elabs_matchers/matchers/persist.rb +8 -2
  57. data/lib/elabs_matchers/version.rb +1 -1
  58. data/lib/elabs_matchers.rb +0 -1
  59. data/spec/elabs_matchers/matchers/only_include_spec.rb +13 -0
  60. data/spec/elabs_matchers/matchers/persist_spec.rb +1 -1
  61. data/spec/spec_helper.rb +7 -0
  62. metadata +8 -29
  63. data/doc/Cucumber.html +0 -116
  64. data/doc/ElabsMatchers/Cucumber/Common.html +0 -145
  65. data/doc/ElabsMatchers/Cucumber.html +0 -108
  66. data/doc/ElabsMatchers/Helpers/Capybara.html +0 -241
  67. data/doc/ElabsMatchers/Helpers/Common.html +0 -213
  68. data/doc/ElabsMatchers/Helpers/Orm.html +0 -289
  69. data/doc/ElabsMatchers/Helpers/Session.html +0 -497
  70. data/doc/ElabsMatchers/Matchers/Allow.html +0 -229
  71. data/doc/ElabsMatchers/Matchers/Capybara/Common.html +0 -1159
  72. data/doc/ElabsMatchers/Matchers/Capybara.html +0 -108
  73. data/doc/ElabsMatchers/Matchers/HaveTableRow/HaveTableRowMatcher.html +0 -654
  74. data/doc/ElabsMatchers/Matchers/HaveTableRow.html +0 -236
  75. data/doc/ElabsMatchers/Matchers/Rspec/Allow.html +0 -98
  76. data/doc/ElabsMatchers/Matchers/Rspec/Common.html +0 -332
  77. data/doc/ElabsMatchers/Matchers/Rspec/Orm.html +0 -231
  78. data/doc/ElabsMatchers/Matchers/Rspec.html +0 -110
  79. data/doc/ElabsMatchers/Orm/Post.html +0 -1041
  80. data/doc/ElabsMatchers/Orm.html +0 -108
  81. data/lib/elabs_matchers/matchers/have_table_row.rb +0 -124
  82. data/spec/elabs_matchers/matchers/have_table_row_spec.rb +0 -119
@@ -1,23 +1,22 @@
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">
1
+ <!DOCTYPE html>
2
+ <html>
4
3
  <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.8.2.1
9
+ &mdash; Documentation by YARD 0.9.12
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
16
 
17
17
  <script type="text/javascript" charset="utf-8">
18
- hasFrames = window.top.frames.main ? true : false;
18
+ pathId = "";
19
19
  relpath = '';
20
- framesUrl = "frames.html#!" + escape(window.location.href);
21
20
  </script>
22
21
 
23
22
 
@@ -28,58 +27,56 @@
28
27
 
29
28
  </head>
30
29
  <body>
31
- <div id="header">
32
- <div id="menu">
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
33
38
 
34
39
  <a href="_index.html">Index</a> &raquo;
35
40
 
36
41
 
37
42
  <span class="title">Top Level Namespace</span>
38
43
 
39
-
40
- <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
44
  </div>
42
45
 
43
- <div id="search">
46
+ <div id="search">
44
47
 
45
48
  <a class="full_list_link" id="class_list_link"
46
49
  href="class_list.html">
47
- Class List
48
- </a>
49
-
50
- <a class="full_list_link" id="method_list_link"
51
- href="method_list.html">
52
- Method List
53
- </a>
54
-
55
- <a class="full_list_link" id="file_list_link"
56
- href="file_list.html">
57
- File List
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
58
56
  </a>
59
57
 
60
58
  </div>
61
- <div class="clear"></div>
62
- </div>
59
+ <div class="clear"></div>
60
+ </div>
63
61
 
64
- <iframe id="search_frame"></iframe>
65
-
66
- <div id="content"><h1>Top Level Namespace
62
+ <div id="content"><h1>Top Level Namespace
67
63
 
68
64
 
69
65
 
70
66
  </h1>
67
+ <div class="box_info">
68
+
71
69
 
72
- <dl class="box">
73
70
 
74
71
 
75
-
76
72
 
77
-
78
73
 
79
74
 
75
+
80
76
 
81
- </dl>
82
- <div class="clear"></div>
77
+
78
+
79
+ </div>
83
80
 
84
81
  <h2>Defined Under Namespace</h2>
85
82
  <p class="children">
@@ -102,11 +99,12 @@
102
99
 
103
100
  </div>
104
101
 
105
- <div id="footer">
106
- Generated on Wed Sep 19 15:04:26 2012 by
102
+ <div id="footer">
103
+ Generated on Wed Mar 14 09:56:36 2018 by
107
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.2.1 (ruby-1.9.3).
105
+ 0.9.12 (ruby-2.4.1).
109
106
  </div>
110
107
 
108
+ </div>
111
109
  </body>
112
110
  </html>
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Everyone at Elabs"]
10
10
  s.email = ["dev@elabs.se"]
11
11
  s.homepage = "http://github.com/elabs/elabs_matchers"
12
- s.summary = %q{Provides a set of usefull rspec matchers}
13
- s.description = %q{Provides a set of usefull rspec matchers to be used with RSpec and/or Capybara}
12
+ s.summary = %q{Provides a set of useful rspec matchers}
13
+ s.description = %q{Provides a set of useful rspec matchers to be used with RSpec and/or Capybara}
14
14
 
15
15
  s.rubyforge_project = "elabs_matchers"
16
16
 
data/history.txt CHANGED
@@ -1,3 +1,14 @@
1
+ # Version 2.0.1
2
+
3
+ - Use `attribute_names` in favor of `keys` due to Rails 6.1 deprecation (#8)
4
+ - Deprecate `only_include` in favor of Rspec's own (#10)
5
+ - Documentation and file-name fixes (#7)
6
+
7
+ # Version 2.0.0
8
+
9
+ ### Changed
10
+ * Compatibility with Rails 5
11
+
1
12
  # Version 0.0.4
2
13
 
3
14
  ### Changed
@@ -19,7 +19,7 @@ module ElabsMatchers
19
19
 
20
20
  def normalize_keys(hash)
21
21
  hash.inject(HashWithIndifferentAccess.new) do |new_hash, (key, value)|
22
- new_hash[key.parameterize("_")] = value
22
+ new_hash[key.parameterize(separator: "_")] = value
23
23
  new_hash
24
24
  end
25
25
  end
@@ -3,6 +3,7 @@ module ElabsMatchers
3
3
  module SelectYearAndMonth
4
4
  rspec :type => :request
5
5
  rspec :type => :feature
6
+ rspec :type => :system
6
7
 
7
8
  ##
8
9
  #
@@ -35,13 +35,15 @@ module ElabsMatchers
35
35
  self
36
36
  end
37
37
 
38
- def failure_message_for_should
38
+ def failure_message
39
39
  common_failure_message(:valid)
40
40
  end
41
+ alias_method :failure_message_for_should, :failure_message
41
42
 
42
- def failure_message_for_should_not
43
+ def failure_message_when_negated
43
44
  common_failure_message(:invalid)
44
45
  end
46
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
45
47
 
46
48
  def description
47
49
  "be valid with #{@values.inspect} as #{@attributes.inspect}"
@@ -81,7 +83,7 @@ module ElabsMatchers
81
83
  record.valid?
82
84
 
83
85
  attributes.map do |attribute|
84
- record.errors.keys.include?(attribute)
86
+ record.errors.attribute_names.include?(attribute)
85
87
  end
86
88
  end
87
89
 
@@ -128,13 +130,6 @@ module ElabsMatchers
128
130
  def be_valid_with(*values)
129
131
  BeValidWithMatcher.new(values)
130
132
  end
131
-
132
- ##
133
- #
134
- # This is a DEPRECATED alias for `be_valid_with`. This no longer works
135
- # with newer versions of RSpec
136
- #
137
- alias_method :allow, :be_valid_with
138
133
  end
139
134
  end
140
135
  end
@@ -9,13 +9,15 @@ module ElabsMatchers
9
9
  contains?(expected, actual)
10
10
  end
11
11
 
12
- def failure_message_for_should
12
+ def failure_message
13
13
  "Expected #{expected.inspect} to exist in #{actual.inspect} but it did not."
14
14
  end
15
+ alias_method :failure_message_for_should, :failure_message
15
16
 
16
- def failure_message_for_should_not
17
+ def failure_message_when_negated
17
18
  "Expected #{expected.inspect} to not exist in #{actual.inspect} but it did."
18
19
  end
20
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
19
21
 
20
22
  private
21
23
 
@@ -3,6 +3,7 @@ module ElabsMatchers
3
3
  module HaveAttribute
4
4
  rspec :type => :request
5
5
  rspec :type => :feature
6
+ rspec :type => :system
6
7
 
7
8
  class HaveAttributeMatcher < Struct.new(:label, :value)
8
9
  attr_reader :page
@@ -17,14 +18,16 @@ module ElabsMatchers
17
18
  page.has_no_selector?(selector_type, selector)
18
19
  end
19
20
 
20
- def failure_message_for_should
21
+ def failure_message
21
22
  attributes = page.all(:css, "li.wrapper").map(&:text).to_sentence
22
23
  "expected there to be an attribute #{label}: #{value}, but the only attributes were: #{attributes}."
23
24
  end
25
+ alias_method :failure_message_for_should, :failure_message
24
26
 
25
- def failure_message_for_should_not
27
+ def failure_message_when_negated
26
28
  "expected there to be no attribute #{label}: #{value}, but there was."
27
29
  end
30
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
28
31
 
29
32
  private
30
33
 
@@ -3,6 +3,7 @@ module ElabsMatchers
3
3
  module HaveFields
4
4
  rspec :type => :request
5
5
  rspec :type => :feature
6
+ rspec :type => :system
6
7
 
7
8
  class HaveFieldsMatcher < Struct.new(:fields)
8
9
  attr_reader :page
@@ -17,16 +18,18 @@ module ElabsMatchers
17
18
  fields.all? { |label, value| page.has_no_field?(label, :with => value) }
18
19
  end
19
20
 
20
- def failure_message_for_should
21
+ def failure_message
21
22
  field_values = page.all("input, textarea").map { |input| input[:value] }
22
23
 
23
24
  "expected page to have the fields #{fields.inspect}, but it didn't.
24
25
  The fields on the page had the following values: #{field_values.to_sentence}."
25
26
  end
27
+ alias_method :failure_message_for_should, :failure_message
26
28
 
27
- def failure_message_for_should_not
29
+ def failure_message_when_negated
28
30
  "expected page not to have the fields #{fields.inspect}, but it did."
29
31
  end
32
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
30
33
  end
31
34
 
32
35
  ##
@@ -3,6 +3,7 @@ module ElabsMatchers
3
3
  module HaveFlash
4
4
  rspec :type => :request
5
5
  rspec :type => :feature
6
+ rspec :type => :system
6
7
 
7
8
  class HaveFlashMatcher < Struct.new(:type, :message)
8
9
  attr_reader :page
@@ -17,13 +18,15 @@ module ElabsMatchers
17
18
  page.has_no_selector?(selector_type, selector, :text => message)
18
19
  end
19
20
 
20
- def failure_message_for_should
21
+ def failure_message
21
22
  "Expected flash #{type} to be '#{message}' but was '#{page.find(selector_type, selector).text}'."
22
23
  end
24
+ alias_method :failure_message_for_should, :failure_message
23
25
 
24
- def failure_message_for_should_not
26
+ def failure_message_when_negated
25
27
  "Expected flash #{type} to not be '#{message}' but it was."
26
28
  end
29
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
27
30
 
28
31
  private
29
32
 
@@ -3,6 +3,7 @@ module ElabsMatchers
3
3
  module HaveFormErrorsOn
4
4
  rspec :type => :request
5
5
  rspec :type => :feature
6
+ rspec :type => :system
6
7
 
7
8
  class HaveFormErrorsOnMatcher < Struct.new(:field, :message)
8
9
  attr_reader :page
@@ -20,7 +21,7 @@ module ElabsMatchers
20
21
  page.has_no_field?(field) || page.find_field(field).has_no_selector?(selector_type, selector, :text => message)
21
22
  end
22
23
 
23
- def failure_message_for_should
24
+ def failure_message
24
25
  if page.has_field?(field)
25
26
  error = page.find_field(field).all(selector_type, selector).first
26
27
  if not error
@@ -32,10 +33,12 @@ module ElabsMatchers
32
33
  "No such field #{field}."
33
34
  end
34
35
  end
36
+ alias_method :failure_message_for_should, :failure_message
35
37
 
36
- def failure_message_for_should_not
38
+ def failure_message_when_negated
37
39
  "Expected error message on '#{field}' not to be '#{message}' but it was."
38
40
  end
41
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
39
42
 
40
43
  private
41
44
 
@@ -3,6 +3,7 @@ module ElabsMatchers
3
3
  module HaveHeader
4
4
  rspec :type => :request
5
5
  rspec :type => :feature
6
+ rspec :type => :system
6
7
 
7
8
  class HaveHeaderMatcher < Struct.new(:text)
8
9
  attr_reader :page
@@ -17,14 +18,16 @@ module ElabsMatchers
17
18
  page.has_no_selector?(selector_type, selector, :text => text)
18
19
  end
19
20
 
20
- def failure_message_for_should
21
+ def failure_message
21
22
  headers = page.all(selector_type, selector).map { |h| "'#{h.text}'" }.to_sentence
22
23
  "Expected header to be '#{text}' but it had the headers #{headers}."
23
24
  end
25
+ alias_method :failure_message_for_should, :failure_message
24
26
 
25
- def failure_message_for_should_not
27
+ def failure_message_when_negated
26
28
  "Expected header not to be '#{text}' but it was."
27
29
  end
30
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
28
31
 
29
32
  private
30
33
 
@@ -3,6 +3,7 @@ module ElabsMatchers
3
3
  module HaveImage
4
4
  rspec :type => :request
5
5
  rspec :type => :feature
6
+ rspec :type => :system
6
7
 
7
8
  class HaveImageMatcher < Struct.new(:value)
8
9
  attr_reader :page
@@ -17,7 +18,7 @@ module ElabsMatchers
17
18
  page.has_no_selector?(selector_type, selector)
18
19
  end
19
20
 
20
- def failure_message_for_should
21
+ def failure_message
21
22
  images = page.all("img").map do |image|
22
23
  hash = {}
23
24
  hash[:alt] = image[:alt] if image[:alt].present?
@@ -33,10 +34,12 @@ module ElabsMatchers
33
34
  "expected to find image '#{value}' but only had the images: #{images}."
34
35
  end
35
36
  end
37
+ alias_method :failure_message_for_should, :failure_message
36
38
 
37
- def failure_message_for_should_not
39
+ def failure_message_when_negated
38
40
  "expected image not to be '#{value}' but it was."
39
41
  end
42
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
40
43
 
41
44
  private
42
45
 
@@ -7,19 +7,31 @@ module ElabsMatchers
7
7
  attr_reader :actual
8
8
 
9
9
  def matches?(actual)
10
+ deprecated
11
+
10
12
  @actual = actual
11
13
  elements.uniq.length == elements.length and
12
14
  actual.length == elements.length and
13
15
  elements.all? { |element| actual.include?(element) }
14
16
  end
15
17
 
16
- def failure_message_for_should
18
+ def failure_message
17
19
  "Expected #{actual.inspect} to only include #{elements.inspect}."
18
20
  end
21
+ alias_method :failure_message_for_should, :failure_message
19
22
 
20
- def failure_message_for_should_not
23
+ def failure_message_when_negated
21
24
  "Expected #{actual.inspect} to not only include #{elements.inspect}, but it did."
22
25
  end
26
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
27
+
28
+ private
29
+
30
+ def deprecated
31
+ warn %Q{
32
+ [DEPRECATION] `only_include` is deprecated. Please use rspec's `contain_exactly` instead. Called from #{Kernel.caller.first}
33
+ }
34
+ end
23
35
  end
24
36
 
25
37
  ##
@@ -15,13 +15,19 @@ module ElabsMatchers
15
15
  @final_value == value
16
16
  end
17
17
 
18
- def failure_message_for_should
18
+ def failure_message
19
19
  "Expected #{attribute} to be persisted and retain its value of #{value.inspect} but the value was #{@final_value.inspect}."
20
20
  end
21
+ alias_method :failure_message_for_should, :failure_message
21
22
 
22
- def failure_message_for_should_not
23
+ def failure_message_when_negated
23
24
  "Expected #{attribute} not to be persisted and retain its value of #{value.inspect} but it did."
24
25
  end
26
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
27
+
28
+ def description
29
+ "persist #{attribute}"
30
+ end
25
31
  end
26
32
 
27
33
  ##