Hello community,
here is the log from the commit of package rubygem-rails-dom-testing for
openSUSE:Factory checked in at 2016-05-13 09:23:47
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-rails-dom-testing (Old)
and /work/SRC/openSUSE:Factory/.rubygem-rails-dom-testing.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-rails-dom-testing"
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-rails-dom-testing/rubygem-rails-dom-testing.changes
2015-08-27 08:56:16.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-rails-dom-testing.new/rubygem-rails-dom-testing.changes
2016-05-13 09:23:48.000000000 +0200
@@ -1,0 +2,6 @@
+Mon May 9 04:45:08 UTC 2016 - [email protected]
+
+- updated to version 2.0.0
+ no changelog found
+
+-------------------------------------------------------------------
Old:
----
rails-dom-testing-1.0.7.gem
New:
----
rails-dom-testing-2.0.0.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-rails-dom-testing.spec ++++++
--- /var/tmp/diff_new_pack.18E0aH/_old 2016-05-13 09:23:49.000000000 +0200
+++ /var/tmp/diff_new_pack.18E0aH/_new 2016-05-13 09:23:49.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-rails-dom-testing
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
#
Name: rubygem-rails-dom-testing
-Version: 1.0.7
+Version: 2.0.0
Release: 0
%define mod_name rails-dom-testing
%define mod_full_name %{mod_name}-%{version}
@@ -54,7 +54,7 @@
%install
%gem_install \
- --doc-files="LICENSE.txt README.md" \
+ --doc-files="README.md" \
-f
%gem_packages
++++++ rails-dom-testing-1.0.7.gem -> rails-dom-testing-2.0.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/LICENSE.txt new/LICENSE.txt
--- old/LICENSE.txt 2015-08-14 18:10:13.000000000 +0200
+++ new/LICENSE.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,22 +0,0 @@
-Copyright (c) 2013 Kasper Timm Hansen
-
-MIT License
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2015-08-14 18:10:13.000000000 +0200
+++ new/README.md 2016-05-08 20:52:32.000000000 +0200
@@ -1,5 +1,4 @@
# Rails::Dom::Testing
-[](https://travis-ci.org/rails/rails-dom-testing)
This gem is responsible for comparing HTML doms and asserting that DOM
elements are present in Rails applications.
Doms are compared via `assert_dom_equal` and `assert_dom_not_equal`.
@@ -56,7 +55,7 @@
assert_select_email '#you-got-mail'
```
-The documentation in
[selector_assertions.rb](https://github.com/kaspth/rails-dom-testing/blob/master/lib/rails/dom/testing/assertions/selector_assertions.rb)
goes into a lot more detail of how selector assertions can be used.
+The documentation in
[selector_assertions.rb](https://github.com/rails/rails-dom-testing/blob/master/lib/rails/dom/testing/assertions/selector_assertions.rb)
goes into a lot more detail of how selector assertions can be used.
## Read more
@@ -67,10 +66,12 @@
Read more about Nokogiri:
- [Nokogiri](http://nokogiri.org)
-## Contributing
+## Contributing to Rails::Dom::Testing
-1. Fork it
-2. Create your feature branch (`git checkout -b my-new-feature`)
-3. Commit your changes (`git commit -am 'Add some feature'`)
-4. Push to the branch (`git push origin my-new-feature`)
-5. Create new Pull Request
+Rails::Dom::Testing is work of many contributors. You're encouraged to submit
pull requests, propose
+features and discuss issues.
+
+See [CONTRIBUTING](CONTRIBUTING.md).
+
+## License
+Rails::Dom::Testing is released under the [MIT License](MIT-LICENSE).
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb
new/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb
--- old/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb
2015-08-14 18:10:13.000000000 +0200
+++ new/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb
2016-05-08 20:52:32.000000000 +0200
@@ -2,12 +2,12 @@
require_relative 'substitution_context'
class HTMLSelector #:nodoc:
- attr_reader :selector, :tests, :message
+ attr_reader :css_selector, :tests, :message
def initialize(values, previous_selection = nil, &root_fallback)
@values = values
@root = extract_root(previous_selection, root_fallback)
- @selector = extract_selector
+ extract_selectors
@tests = extract_equality_tests
@message = @values.shift
@@ -16,8 +16,14 @@
end
end
+ def selecting_no_body? #:nodoc:
+ # Nokogiri gives the document a body element. Which means we can't
+ # run an assertion expecting there to not be a body.
+ @selector == 'body' && @tests[:count] == 0
+ end
+
def select
- filter @root.css(selector, context)
+ filter @root.css(@selector, context)
end
private
@@ -67,15 +73,15 @@
end
end
- def extract_selector
+ def extract_selectors
selector = @values.shift
unless selector.is_a? String
raise ArgumentError, "Expecting a selector as the first argument"
end
- context.substitute!(selector, @values)
- selector
+ @css_selector = context.substitute!(selector, @values.dup, true)
+ @selector = context.substitute!(selector, @values)
end
def extract_equality_tests
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
new/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
---
old/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
2015-08-14 18:10:13.000000000 +0200
+++
new/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
2016-05-08 20:52:32.000000000 +0200
@@ -3,10 +3,14 @@
@substitute = '?'
end
- def substitute!(selector, values)
+ def substitute!(selector, values, format_for_presentation = false)
+ selector = selector.dup
+
while !values.empty? && substitutable?(values.first) &&
selector.index(@substitute)
- selector.sub! @substitute, matcher_for(values.shift)
+ selector.sub! @substitute, matcher_for(values.shift,
format_for_presentation)
end
+
+ selector
end
def match(matches, attribute, matcher)
@@ -14,8 +18,13 @@
end
private
- def matcher_for(value)
- value.to_s.inspect # Nokogiri doesn't like arbitrary values without
quotes, hence inspect.
+ def matcher_for(value, format_for_presentation)
+ # Nokogiri doesn't like arbitrary values without quotes, hence inspect.
+ if format_for_presentation
+ value.inspect # Avoid to_s so Regexps aren't put in quotes.
+ else
+ value.to_s.inspect
+ end
end
def substitutable?(value)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/rails/dom/testing/assertions/selector_assertions.rb
new/lib/rails/dom/testing/assertions/selector_assertions.rb
--- old/lib/rails/dom/testing/assertions/selector_assertions.rb 2015-08-14
18:10:13.000000000 +0200
+++ new/lib/rails/dom/testing/assertions/selector_assertions.rb 2016-05-08
20:52:32.000000000 +0200
@@ -166,13 +166,14 @@
selector = HTMLSelector.new(args, @selected) { nodeset
document_root_element }
- if selecting_no_body?(selector)
+ if selector.selecting_no_body?
assert true
return
end
selector.select.tap do |matches|
- assert_size_match!(matches.size, selector.tests,
selector.selector, selector.message)
+ assert_size_match!(matches.size, selector.tests,
+ selector.css_selector, selector.message)
nest_selection(matches, &block) if block_given? && !matches.empty?
end
@@ -219,7 +220,9 @@
end
content = nodeset(element || @selected).map do |elem|
- elem.children.select(&:cdata?).map(&:content)
+ elem.children.select do |child|
+ child.cdata? || (child.text? && !child.blank?)
+ end.map(&:content)
end.join
selected = Nokogiri::HTML::DocumentFragment.parse(content)
@@ -282,12 +285,6 @@
end
end
- def selecting_no_body?(html_selector)
- # Nokogiri gives the document a body element. Which means we can't
- # run an assertion expecting there to not be a body.
- html_selector.selector == 'body' && html_selector.tests[:count] == 0
- end
-
def nest_selection(selection)
# Set @selected to allow nested assert_select.
# Can be nested several levels deep.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rails/dom/testing/assertions/tag_assertions.rb
new/lib/rails/dom/testing/assertions/tag_assertions.rb
--- old/lib/rails/dom/testing/assertions/tag_assertions.rb 2015-08-14
18:10:13.000000000 +0200
+++ new/lib/rails/dom/testing/assertions/tag_assertions.rb 1970-01-01
01:00:00.000000000 +0100
@@ -1,155 +0,0 @@
-require 'active_support/deprecation'
-require 'rails/deprecated_sanitizer/html-scanner'
-
-module Rails
- module Dom
- module Testing
- module Assertions
- # Pair of assertions to testing elements in the HTML output of the
response.
- module TagAssertions
- # Asserts that there is a tag/node/element in the body of the
response
- # that meets all of the given conditions. The +conditions+ parameter
must
- # be a hash of any of the following keys (all are optional):
- #
- # * <tt>:tag</tt>: the node type must match the corresponding value
- # * <tt>:attributes</tt>: a hash. The node's attributes must match
the
- # corresponding values in the hash.
- # * <tt>:parent</tt>: a hash. The node's parent must match the
- # corresponding hash.
- # * <tt>:child</tt>: a hash. At least one of the node's immediate
children
- # must meet the criteria described by the hash.
- # * <tt>:ancestor</tt>: a hash. At least one of the node's ancestors
must
- # meet the criteria described by the hash.
- # * <tt>:descendant</tt>: a hash. At least one of the node's
descendants
- # must meet the criteria described by the hash.
- # * <tt>:sibling</tt>: a hash. At least one of the node's siblings
must
- # meet the criteria described by the hash.
- # * <tt>:after</tt>: a hash. The node must be after any sibling
meeting
- # the criteria described by the hash, and at least one sibling
must match.
- # * <tt>:before</tt>: a hash. The node must be before any sibling
meeting
- # the criteria described by the hash, and at least one sibling
must match.
- # * <tt>:children</tt>: a hash, for counting children of a node.
Accepts
- # the keys:
- # * <tt>:count</tt>: either a number or a range which must equal
(or
- # include) the number of children that match.
- # * <tt>:less_than</tt>: the number of matching children must be
less
- # than this number.
- # * <tt>:greater_than</tt>: the number of matching children must be
- # greater than this number.
- # * <tt>:only</tt>: another hash consisting of the keys to use
- # to match on the children, and only matching children will be
- # counted.
- # * <tt>:content</tt>: the textual content of the node must match the
- # given value. This will not match HTML tags in the body of a
- # tag--only text.
- #
- # Conditions are matched using the following algorithm:
- #
- # * if the condition is a string, it must be a substring of the
value.
- # * if the condition is a regexp, it must match the value.
- # * if the condition is a number, the value must match number.to_s.
- # * if the condition is +true+, the value must not be +nil+.
- # * if the condition is +false+ or +nil+, the value must be +nil+.
- #
- # # Assert that there is a "span" tag
- # assert_tag tag: "span"
- #
- # # Assert that there is a "span" tag with id="x"
- # assert_tag tag: "span", attributes: { id: "x" }
- #
- # # Assert that there is a "span" tag using the short-hand
- # assert_tag :span
- #
- # # Assert that there is a "span" tag with id="x" using the
short-hand
- # assert_tag :span, attributes: { id: "x" }
- #
- # # Assert that there is a "span" inside of a "div"
- # assert_tag tag: "span", parent: { tag: "div" }
- #
- # # Assert that there is a "span" somewhere inside a table
- # assert_tag tag: "span", ancestor: { tag: "table" }
- #
- # # Assert that there is a "span" with at least one "em" child
- # assert_tag tag: "span", child: { tag: "em" }
- #
- # # Assert that there is a "span" containing a (possibly nested)
- # # "strong" tag.
- # assert_tag tag: "span", descendant: { tag: "strong" }
- #
- # # Assert that there is a "span" containing between 2 and 4 "em"
tags
- # # as immediate children
- # assert_tag tag: "span",
- # children: { count: 2..4, only: { tag: "em" } }
- #
- # # Get funky: assert that there is a "div", with an "ul" ancestor
- # # and an "li" parent (with "class" = "enum"), and containing a
- # # "span" descendant that contains text matching /hello world/
- # assert_tag tag: "div",
- # ancestor: { tag: "ul" },
- # parent: { tag: "li",
- # attributes: { class: "enum" } },
- # descendant: { tag: "span",
- # child: /hello world/ }
- #
- # <b>Please note</b>: +assert_tag+ and +assert_no_tag+ only work
- # with well-formed XHTML. They recognize a few tags as implicitly
self-closing
- # (like br and hr and such) but will not work correctly with tags
- # that allow optional closing tags (p, li, td). <em>You must
explicitly
- # close all of your tags to use these assertions.</em>
- def assert_tag(*opts)
- ActiveSupport::Deprecation.warn("assert_tag is deprecated and will
be removed at Rails 5. Use assert_select to get the same feature.")
-
- opts = opts.size > 1 ? opts.last.merge({ tag: opts.first.to_s }) :
opts.first
- tag = _find_tag(opts)
-
- assert tag, "expected tag, but no tag found matching
#{opts.inspect} in:\n#{@response.body.inspect}"
- end
-
- # Identical to +assert_tag+, but asserts that a matching tag does
_not_
- # exist. (See +assert_tag+ for a full discussion of the syntax.)
- #
- # # Assert that there is not a "div" containing a "p"
- # assert_no_tag tag: "div", descendant: { tag: "p" }
- #
- # # Assert that an unordered list is empty
- # assert_no_tag tag: "ul", descendant: { tag: "li" }
- #
- # # Assert that there is not a "p" tag with between 1 to 3 "img"
tags
- # # as immediate children
- # assert_no_tag tag: "p",
- # children: { count: 1..3, only: { tag: "img" } }
- def assert_no_tag(*opts)
- ActiveSupport::Deprecation.warn("assert_no_tag is deprecated and
will be removed at Rails 5. Use assert_select to get the same feature.")
-
- opts = opts.size > 1 ? opts.last.merge({ tag: opts.first.to_s }) :
opts.first
- tag = _find_tag(opts)
-
- assert !tag, "expected no tag, but found tag matching
#{opts.inspect} in:\n#{@response.body.inspect}"
- end
-
- def find_tag(conditions)
- ActiveSupport::Deprecation.warn("find_tag is deprecated and will
be removed at Rails 5 without replacement.")
-
- _find_tag(conditions)
- end
-
- def find_all_tag(conditions)
- ActiveSupport::Deprecation.warn("find_all_tag is deprecated and
will be removed at Rails 5 without replacement. Use assert_select to get the
same feature.")
-
- html_scanner_document.find_all(conditions)
- end
-
- private
- def _find_tag(conditions)
- html_scanner_document.find(conditions)
- end
-
- def html_scanner_document
- xml = @response.content_type =~ /xml$/
- @html_scanner_document ||= HTML::Document.new(@response.body,
false, xml)
- end
- end
- end
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rails/dom/testing/assertions.rb
new/lib/rails/dom/testing/assertions.rb
--- old/lib/rails/dom/testing/assertions.rb 2015-08-14 18:10:13.000000000
+0200
+++ new/lib/rails/dom/testing/assertions.rb 2016-05-08 20:52:32.000000000
+0200
@@ -7,13 +7,11 @@
module Assertions
autoload :DomAssertions, 'rails/dom/testing/assertions/dom_assertions'
autoload :SelectorAssertions,
'rails/dom/testing/assertions/selector_assertions'
- autoload :TagAssertions, 'rails/dom/testing/assertions/tag_assertions'
extend ActiveSupport::Concern
include DomAssertions
include SelectorAssertions
- include TagAssertions
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/rails/dom/testing/version.rb
new/lib/rails/dom/testing/version.rb
--- old/lib/rails/dom/testing/version.rb 2015-08-14 18:10:13.000000000
+0200
+++ new/lib/rails/dom/testing/version.rb 2016-05-08 20:52:32.000000000
+0200
@@ -1,7 +1,7 @@
module Rails
module Dom
module Testing
- VERSION = "1.0.7"
+ VERSION = "2.0.0"
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2015-08-14 18:10:13.000000000 +0200
+++ new/metadata 2016-05-08 20:52:32.000000000 +0200
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: rails-dom-testing
version: !ruby/object:Gem::Version
- version: 1.0.7
+ version: 2.0.0
platform: ruby
authors:
- Rafael Mendonça França
@@ -9,7 +9,7 @@
autorequire:
bindir: bin
cert_chain: []
-date: 2015-08-14 00:00:00.000000000 Z
+date: 2016-05-08 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: nokogiri
@@ -31,34 +31,20 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: 4.2.0.beta
+ version: 4.2.0
- - "<"
- !ruby/object:Gem::Version
- version: '5.0'
+ version: '6.0'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: 4.2.0.beta
+ version: 4.2.0
- - "<"
- !ruby/object:Gem::Version
- version: '5.0'
-- !ruby/object:Gem::Dependency
- name: rails-deprecated_sanitizer
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.1
- type: :runtime
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.0.1
+ version: '6.0'
- !ruby/object:Gem::Dependency
name: bundler
requirement: !ruby/object:Gem::Requirement
@@ -110,7 +96,6 @@
extensions: []
extra_rdoc_files: []
files:
-- LICENSE.txt
- README.md
- lib/rails-dom-testing.rb
- lib/rails/dom/testing/assertions.rb
@@ -119,11 +104,9 @@
- lib/rails/dom/testing/assertions/selector_assertions/count_describable.rb
- lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb
- lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
-- lib/rails/dom/testing/assertions/tag_assertions.rb
- lib/rails/dom/testing/version.rb
- test/dom_assertions_test.rb
- test/selector_assertions_test.rb
-- test/tag_assertions_test.rb
- test/test_helper.rb
homepage: https://github.com/rails/rails-dom-testing
licenses:
@@ -145,13 +128,11 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.4.7
+rubygems_version: 2.5.1
signing_key:
specification_version: 4
summary: Dom and Selector assertions for Rails applications
test_files:
- test/dom_assertions_test.rb
- test/selector_assertions_test.rb
-- test/tag_assertions_test.rb
- test/test_helper.rb
-has_rdoc:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/selector_assertions_test.rb
new/test/selector_assertions_test.rb
--- old/test/selector_assertions_test.rb 2015-08-14 18:10:13.000000000
+0200
+++ new/test/selector_assertions_test.rb 2016-05-08 20:52:32.000000000
+0200
@@ -232,6 +232,16 @@
end
end
+ def test_nested_assert_select_with_match_failure_shows_nice_regex
+ render_html %Q{<div id="1">foo</div>}
+
+ error = assert_raises Minitest::Assertion do
+ assert_select "div:match('id', ?)", /wups/
+ end
+
+ assert_match %Q{div:match('id', /wups/)}, error.message
+ end
+
def test_feed_item_encoded
render_xml <<-EOF
<rss version="2.0">
@@ -245,9 +255,7 @@
</item>
<item>
<description>
- <![CDATA[
- <p>Test 2</p>
- ]]>
+ <p>Test 2</p>
</description>
</item>
</channel>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/tag_assertions_test.rb
new/test/tag_assertions_test.rb
--- old/test/tag_assertions_test.rb 2015-08-14 18:10:13.000000000 +0200
+++ new/test/tag_assertions_test.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,218 +0,0 @@
-require 'test_helper'
-require 'rails/dom/testing/assertions/tag_assertions'
-
-HTML_TEST_OUTPUT = <<HTML
-<html>
- <body>
- <a href="/"><img src="/images/button.png" /></a>
- <div id="foo">
- <ul>
- <li class="item">hello</li>
- <li class="item">goodbye</li>
- </ul>
- </div>
- <div id="bar">
- <form action="/somewhere">
- Name: <input type="text" name="person[name]" id="person_name" />
- </form>
- </div>
- </body>
-</html>
-HTML
-
-class AssertTagTest < ActiveSupport::TestCase
- include Rails::Dom::Testing::Assertions::TagAssertions
-
- class FakeResponse
- attr_accessor :content_type, :body
-
- def initialize(content_type, body)
- @content_type, @body = content_type, body
- end
- end
-
- setup do
- @response = FakeResponse.new 'html', HTML_TEST_OUTPUT
- end
-
- def test_assert_tag_tag
- assert_deprecated do
- # there is a 'form' tag
- assert_tag tag: 'form'
- # there is not an 'hr' tag
- assert_no_tag tag: 'hr'
- end
- end
-
- def test_assert_tag_attributes
- assert_deprecated do
- # there is a tag with an 'id' of 'bar'
- assert_tag attributes: { id: "bar" }
- # there is no tag with a 'name' of 'baz'
- assert_no_tag attributes: { name: "baz" }
- end
- end
-
- def test_assert_tag_parent
- assert_deprecated do
- # there is a tag with a parent 'form' tag
- assert_tag parent: { tag: "form" }
- # there is no tag with a parent of 'input'
- assert_no_tag parent: { tag: "input" }
- end
- end
-
- def test_assert_tag_child
- assert_deprecated do
- # there is a tag with a child 'input' tag
- assert_tag child: { tag: "input" }
- # there is no tag with a child 'strong' tag
- assert_no_tag child: { tag: "strong" }
- end
- end
-
- def test_assert_tag_ancestor
- assert_deprecated do
- # there is a 'li' tag with an ancestor having an id of 'foo'
- assert_tag ancestor: { attributes: { id: "foo" } }, tag: "li"
- # there is no tag of any kind with an ancestor having an href matching
'foo'
- assert_no_tag ancestor: { attributes: { href: /foo/ } }
- end
- end
-
- def test_assert_tag_descendant
- assert_deprecated do
- # there is a tag with a descendant 'li' tag
- assert_tag descendant: { tag: "li" }
- # there is no tag with a descendant 'html' tag
- assert_no_tag descendant: { tag: "html" }
- end
- end
-
- def test_assert_tag_sibling
- assert_deprecated do
- # there is a tag with a sibling of class 'item'
- assert_tag sibling: { attributes: { class: "item" } }
- # there is no tag with a sibling 'ul' tag
- assert_no_tag sibling: { tag: "ul" }
- end
- end
-
- def test_assert_tag_after
- assert_deprecated do
- # there is a tag following a sibling 'div' tag
- assert_tag after: { tag: "div" }
- # there is no tag following a sibling tag with id 'bar'
- assert_no_tag after: { attributes: { id: "bar" } }
- end
- end
-
- def test_assert_tag_before
- assert_deprecated do
- # there is a tag preceding a tag with id 'bar'
- assert_tag before: { attributes: { id: "bar" } }
- # there is no tag preceding a 'form' tag
- assert_no_tag before: { tag: "form" }
- end
- end
-
- def test_assert_tag_children_count
- assert_deprecated do
- # there is a tag with 2 children
- assert_tag children: { count: 2 }
- # in particular, there is a <ul> tag with two children (a nameless pair
of <li>s)
- assert_tag tag: 'ul', children: { count: 2 }
- # there is no tag with 4 children
- assert_no_tag children: { count: 4 }
- end
- end
-
- def test_assert_tag_children_less_than
- assert_deprecated do
- # there is a tag with less than 5 children
- assert_tag children: { less_than: 5 }
- # there is no 'ul' tag with less than 2 children
- assert_no_tag children: { less_than: 2 }, tag: "ul"
- end
- end
-
- def test_assert_tag_children_greater_than
- assert_deprecated do
- # there is a 'body' tag with more than 1 children
- assert_tag children: { greater_than: 1 }, tag: "body"
- # there is no tag with more than 10 children
- assert_no_tag children: { greater_than: 10 }
- end
- end
-
- def test_assert_tag_children_only
- assert_deprecated do
- # there is a tag containing only one child with an id of 'foo'
- assert_tag children: { count: 1,
- only: { attributes: { id: "foo" } } }
- # there is no tag containing only one 'li' child
- assert_no_tag children: { count: 1, only: { tag: "li" } }
- end
- end
-
- def test_assert_tag_content
- assert_deprecated do
- # the output contains the string "Name"
- assert_tag content: /Name/
- # the output does not contain the string "test"
- assert_no_tag content: /test/
- end
- end
-
- def test_assert_tag_multiple
- assert_deprecated do
- # there is a 'div', id='bar', with an immediate child whose 'action'
- # attribute matches the regexp /somewhere/.
- assert_tag tag: "div", attributes: { id: "bar" },
- child: { attributes: { action: /somewhere/ } }
-
- # there is no 'div', id='foo', with a 'ul' child with more than
- # 2 "li" children.
- assert_no_tag tag: "div", attributes: { id: "foo" },
- child: { tag: "ul",
- children: { greater_than: 2, only: { tag: "li" } } }
- end
- end
-
- def test_assert_tag_children_without_content
- assert_deprecated do
- # there is a form tag with an 'input' child which is a self closing tag
- assert_tag tag: "form",
- children: { count: 1,
- only: { tag: "input" } }
-
- # the body tag has an 'a' child which in turn has an 'img' child
- assert_tag tag: "body",
- children: { count: 1,
- only: { tag: "a",
- children: { count: 1,
- only: { tag: "img" } } } }
- end
- end
-
- def test_assert_tag_attribute_matching
- assert_deprecated do
- @response.body = '<input type="text" name="my_name">'
- assert_tag tag: 'input',
- attributes: { name: /my/, type: 'text' }
- assert_no_tag tag: 'input',
- attributes: { name: 'my', type: 'text' }
- assert_no_tag tag: 'input',
- attributes: { name: /^my$/, type: 'text' }
- end
- end
-
- def test_assert_tag_content_matching
- assert_deprecated do
- @response.body = "<p>hello world</p>"
- assert_tag tag: "p", content: "hello world"
- assert_tag tag: "p", content: /hello/
- assert_no_tag tag: "p", content: "hello"
- end
- end
-end