padrino 0.13.3.2 → 0.13.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33ebc108b35d53b9a5fa0e4097a256c8e8fc0b9b
4
- data.tar.gz: c27c573824973aa75a37a96832e71504a1075d61
3
+ metadata.gz: 3b7fbd5dce917ef5755f98ce35de3e65d46b54f8
4
+ data.tar.gz: 3eb8130a12322ac230f5a87a375fb11b49857449
5
5
  SHA512:
6
- metadata.gz: 326ad2b22b475b10ed66c407049a66c6320e326d731cc6d2db9b9e4ff159d94b1f8eae77d27d7dd92a2e8882e07cc0a1d333ebe00e7a42d3ff1cbb0c0a369a22
7
- data.tar.gz: 59a84f526d8350fa4bfc78456e832438d35b1fb6ad39c2baa96453781c451d060d4244dcf3f174b6fa191c690f1421581fa18b10136982d9d036ed6bf4c65d3f
6
+ metadata.gz: 6e096cb4b7b819a5f951617f2f9b0da49f2bad4b820c8a6f93f8ab725a083988c8d018f6aea3f033d0f4370fca55d8affd1739bd6c7429e53b02e5381d3c0c17
7
+ data.tar.gz: fc4448f9e4c05d4f0b040e945343abc09416052d9c2b9b011fa7e2c6a33fd45c9831509c2b1d817f45f05177245e51479c798b38712db51e607025cd8e950732
@@ -1,22 +1,4 @@
1
1
  class MiniTest::Spec
2
- # assert_has_tag(:h1, :content => "yellow") { "<h1>yellow</h1>" }
3
- # In this case, block is the html to evaluate
4
- def assert_has_tag(name, attributes = {})
5
- html = yield if block_given?
6
- assert html.html_safe?, 'output in not #html_safe?'
7
- matcher = HaveSelector.new(name, attributes)
8
- assert matcher.matches?(html), matcher.failure_message
9
- end
10
-
11
- # assert_has_no_tag(:h1, :content => "yellow") { "<h1>green</h1>" }
12
- # In this case, block is the html to evaluate
13
- def assert_has_no_tag(name, attributes = {}, &block)
14
- html = yield if block_given?
15
- assert html.html_safe?, 'output in not #html_safe?'
16
- matcher = HaveSelector.new(name, attributes)
17
- assert !matcher.matches?(html), matcher.negative_failure_message
18
- end
19
-
20
2
  # Assert_file_exists('/tmp/app')
21
3
  def assert_file_exists(file_path)
22
4
  assert File.file?(file_path), "File at path '#{file_path}' does not exist!"
@@ -0,0 +1,55 @@
1
+ require 'oga'
2
+
3
+ module Padrino
4
+ module TestMethods
5
+ def assert_html_has_tag(html, tag, attributes={})
6
+ assert html.html_safe?, 'output in not #html_safe?'
7
+ assert_has_selector(html, tag, attributes)
8
+ end
9
+
10
+ def assert_html_has_no_tag(html, tag, attributes={})
11
+ assert html.html_safe?, 'output in not #html_safe?'
12
+ assert_has_no_selector(html, tag, attributes)
13
+ end
14
+
15
+ def assert_response_has_tag(tag, attributes={})
16
+ assert_has_selector(last_response.body, tag, attributes)
17
+ end
18
+
19
+ def assert_response_has_no_tag(tag, attributes={})
20
+ assert_has_no_selector(last_response.body, tag, attributes)
21
+ end
22
+
23
+ def assert_has_selector(html, selector, attributes)
24
+ count_requirement = attributes.delete(:count)
25
+ message = "'#{selector}' with attributes #{attributes} in html\n#{html}"
26
+ matched_count = html_matched_tags(html, selector.to_s, attributes)
27
+ if count_requirement
28
+ assert_equal count_requirement, matched_count, "count of tags #{message}"
29
+ else
30
+ assert matched_count > 0, "expected a tag #{message}"
31
+ end
32
+ end
33
+
34
+ def assert_has_no_selector(html, selector, attributes)
35
+ message = "'#{selector}' with attributes #{attributes} in html\n#{html}"
36
+ matched_count = html_matched_tags(html, selector.to_s, attributes)
37
+ assert matched_count == 0, "expected no tags #{message}"
38
+ end
39
+
40
+ private
41
+
42
+ def html_matched_tags(html, selector, attributes)
43
+ @dom ||= Oga.parse_html(html)
44
+ content_requirement = attributes.delete(:content)
45
+ attributes.each do |name, value|
46
+ selector += %{[#{name}="#{value}"]}
47
+ end
48
+ tags = @dom.css(selector.to_s.gsub(/\[([^"']*?)=([^'"]*?)\]/, '[\1="\2"]'))
49
+ if content_requirement
50
+ tags = tags.select{ |tag| (tag.get('content') || tag.text).index(content_requirement) }
51
+ end
52
+ tags.count
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.3.2
4
+ version: 0.13.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-09-06 00:00:00.000000000 Z
14
+ date: 2016-11-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,98 +19,98 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.13.3.2
22
+ version: 0.13.3.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.13.3.2
29
+ version: 0.13.3.3
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: padrino-core
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 0.13.3.2
36
+ version: 0.13.3.3
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
- version: 0.13.3.2
43
+ version: 0.13.3.3
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: padrino-helpers
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - '='
49
49
  - !ruby/object:Gem::Version
50
- version: 0.13.3.2
50
+ version: 0.13.3.3
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - '='
56
56
  - !ruby/object:Gem::Version
57
- version: 0.13.3.2
57
+ version: 0.13.3.3
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: padrino-cache
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - '='
63
63
  - !ruby/object:Gem::Version
64
- version: 0.13.3.2
64
+ version: 0.13.3.3
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - '='
70
70
  - !ruby/object:Gem::Version
71
- version: 0.13.3.2
71
+ version: 0.13.3.3
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: padrino-mailer
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - '='
77
77
  - !ruby/object:Gem::Version
78
- version: 0.13.3.2
78
+ version: 0.13.3.3
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - '='
84
84
  - !ruby/object:Gem::Version
85
- version: 0.13.3.2
85
+ version: 0.13.3.3
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: padrino-gen
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - '='
91
91
  - !ruby/object:Gem::Version
92
- version: 0.13.3.2
92
+ version: 0.13.3.3
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - '='
98
98
  - !ruby/object:Gem::Version
99
- version: 0.13.3.2
99
+ version: 0.13.3.3
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: padrino-admin
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - '='
105
105
  - !ruby/object:Gem::Version
106
- version: 0.13.3.2
106
+ version: 0.13.3.3
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - '='
112
112
  - !ruby/object:Gem::Version
113
- version: 0.13.3.2
113
+ version: 0.13.3.3
114
114
  description: The Godfather of Sinatra provides a full-stack agnostic framework on
115
115
  top of Sinatra
116
116
  email: padrinorb@gmail.com
@@ -130,6 +130,7 @@ files:
130
130
  - subgems.rb
131
131
  - test/ext/minitest-spec.rb
132
132
  - test/ext/rack-test-methods.rb
133
+ - test/padrino/test-methods.rb
133
134
  - test/test_padrino.rb
134
135
  homepage: http://www.padrinorb.com
135
136
  licenses:
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  version: 1.3.6
153
154
  requirements: []
154
155
  rubyforge_project: padrino
155
- rubygems_version: 2.5.1
156
+ rubygems_version: 2.6.6
156
157
  signing_key:
157
158
  specification_version: 4
158
159
  summary: The Godfather of Sinatra