nice-n-easy 1.0.0

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.
@@ -0,0 +1,52 @@
1
+ require 'active_support'
2
+ require 'rexml/document'
3
+ require 'action_controller/vendor/html-scanner'
4
+ require 'action_controller/assertions/selector_assertions'
5
+
6
+ module TagMatchingAssertions
7
+ include ActionController::Assertions::SelectorAssertions
8
+
9
+ def assert_tag_in(*opts)
10
+ target = opts.shift
11
+ tag_opts = find_tag_opts(opts)
12
+ assert !find_tag_in(target, tag_opts).nil?,
13
+ "#{tag_opts.inspect} was not found in \n#{target.inspect}"
14
+ end
15
+
16
+ # Identical to +assert_tag_in+, but asserts that a matching tag does _not_
17
+ # exist. (See +assert_tag_in+ for a full discussion of the syntax.)
18
+ def assert_tag_not_in(*opts)
19
+ target = opts.shift
20
+ tag_opts = find_tag_opts(opts)
21
+ assert find_tag_in(target, tag_opts).nil?,
22
+ "#{tag_opts.inspect} was found in \n#{target.inspect}"
23
+ end
24
+
25
+ def assert_select_in(*args, &block)
26
+ if @selected
27
+ root = HTML::Node.new(nil)
28
+ root.children.concat @selected
29
+ else
30
+ # Start with mandatory target.
31
+ target = args.shift
32
+ root = HTML::Document.new(target, false, false).root
33
+ end
34
+ assert_select(*args.unshift(root), &block)
35
+ end
36
+
37
+ private
38
+
39
+ def find_tag_opts(opts)
40
+ if opts.size > 1
41
+ find_opts = opts.last.merge({ :tag => opts.first.to_s })
42
+ else
43
+ find_opts = opts.first.is_a?(Symbol) ? { :tag => opts.first.to_s } : opts.first
44
+ end
45
+ find_opts
46
+ end
47
+
48
+ def find_tag_in(target, opts = {})
49
+ target = HTML::Document.new(target, false, false)
50
+ target.find(opts)
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'contest'
4
+ require 'ruby-debug'
5
+ Debugger.start
6
+ Debugger.settings[:autoeval] = true
7
+
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ require 'sinatra/nice_easy_helpers'
11
+ require 'tag_matcher'
12
+
13
+ class Test::Unit::TestCase
14
+ include TagMatchingAssertions
15
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nice-n-easy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Landau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-28 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sinatra
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "0.9"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: "2.3"
34
+ version:
35
+ description: A set of Sinatra HTML view helpers to make your life nicer and easier. Helpers for forms, links, and assets.
36
+ email: brian.landau@viget.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.md
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.md
49
+ - Rakefile
50
+ - VERSION
51
+ - lib/sinatra/nice_easy_helpers.rb
52
+ - nice-n-easy.gemspec
53
+ - tasks/rdoc.rb
54
+ - tasks/test.rb
55
+ - tasks/vendor/sdoc-helpers/markdown.rb
56
+ - tasks/vendor/sdoc-helpers/pages.rb
57
+ - test/nice_easy_helpers_test.rb
58
+ - test/tag_matcher.rb
59
+ - test/test_helper.rb
60
+ has_rdoc: true
61
+ homepage: http://github.com/brianjlandau/nice-n-easy
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --charset=UTF-8
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.3.5
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Sinatra HTML helpers that are nice-n-easy to use.
88
+ test_files:
89
+ - test/nice_easy_helpers_test.rb
90
+ - test/tag_matcher.rb
91
+ - test/test_helper.rb