sinatra-formhelpers-huii 0.0.2 → 0.0.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: 66e3afa1fef5cdb894505740fc84cb2b947d34f2
4
- data.tar.gz: 1736334d86153040c20804cc4984ce2fa24e9fa1
3
+ metadata.gz: 5d97b0b165937636fbee233e4a0c7b49481ec733
4
+ data.tar.gz: 7adf2ae31d39a4f939b444e75a3b847b8dc85ac8
5
5
  SHA512:
6
- metadata.gz: b7f35ade749d69b901ca5aafefb347be9eec5780ca0e0e8cb878c0aac4d795d6c29c309d63411c3b9ed9e9afc3ad3030aac61e02a6b7fb5866f8e77c0aefc0e3
7
- data.tar.gz: fe25607005f012cc61d0ea4742e1806af91e72ef08432b1329dd871f243e944f1dc11693e965b32ddd5f58fe0ca75e6da1ccfc70701b4f7dbc1dfc7652bcb990
6
+ metadata.gz: 670f0a31adf9a2803446186ab2f88f0aa44118afc90ebf065d18a716d1c0ce540c05fd645bf540b2216ef3f0e92c94fa7bdf48c56686e6498e9def4cc4dcb32a
7
+ data.tar.gz: 25df2b589d08145b79f2691237599ea09ed46e0c325818c96e893cf776e63f71fdef8cb6ea519bddcdec6cdeab7e02c59bb2d3e29c31d6e20ad84e4928308d15
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --format documentation
3
+ --require spec_helper.rb
@@ -22,7 +22,7 @@ module Sinatra
22
22
  end
23
23
  action = "/#{action}" if action.is_a? Symbol
24
24
 
25
- out = tag(:form, nil, { action: action, method: method.to_s }.merge(options)) + method_input
25
+ out = tag(:form, nil, { action: action, method: method.to_s }.merge(options), false) + method_input
26
26
  out << fieldset(action, &block) + '</form>' if block_given?
27
27
  out
28
28
  end
@@ -168,10 +168,12 @@ module Sinatra
168
168
  # Standard open and close tags
169
169
  # EX : tag :h1, "shizam", title: "shizam"
170
170
  # => <h1 title="shizam">shizam</h1>
171
- def tag(name, content, options = {})
172
- "<#{name.to_s}" +
173
- (options.length > 0 ? " #{hash_to_html_attrs(options)}" : '') +
174
- (content.nil? ? '>' : ">#{content}</#{name}>")
171
+ def tag(name, content, options = {}, close = true)
172
+ attributes = " #{ hash_to_html_attrs(options) }" if options.length > 0
173
+ open_tag = "<#{ name }#{ attributes }>"
174
+ close_tag = "</#{ name }>" if close
175
+
176
+ "#{ open_tag }#{ content }#{ close_tag }"
175
177
  end
176
178
 
177
179
  # Standard single closing tags
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module FormHelpers
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.5'
22
- spec.add_development_dependency 'rake', '~> 10.1'
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.3'
23
23
  spec.add_development_dependency 'rack-test', '~> 0.6'
24
- spec.add_development_dependency 'rspec', '~> 2.14'
25
- spec.add_development_dependency 'simplecov', '~> 0.8'
24
+ spec.add_development_dependency 'rspec', '~> 3.1'
25
+ spec.add_development_dependency 'simplecov', '~> 0.9'
26
26
  spec.add_development_dependency 'sinatra', '~> 1.4'
27
- # spec.add_development_dependency 'pry', '~> 0.9'
27
+ # spec.add_development_dependency 'pry', '~> 0.10'
28
28
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe "Sinatra::FormHelpers in app" do
1
+ RSpec.describe "Sinatra::FormHelpers in app" do
4
2
  it 'renders an anchor tag' do
5
3
  app.get '/link' do
6
4
  erb "<%= link 'google', 'http://www.google.com', title: 'Google' %>"
@@ -112,7 +110,17 @@ describe "Sinatra::FormHelpers in app" do
112
110
  expect( last_response.body ).to eq( %q(<textarea id="person_notes" name="person[notes]">This is a note</textarea>) )
113
111
  end
114
112
 
115
- it 'renders a textarea tag with @params' do
113
+ it 'renders a textarea tag with nil @params' do
114
+ app.get '/notes3' do
115
+ @params = { person: {"notes" => nil}}
116
+ erb "<%= textarea :person, :notes %>"
117
+ end
118
+
119
+ get '/notes3'
120
+ expect( last_response.body ).to eq( %q(<textarea id="person_notes" name="person[notes]"></textarea>) )
121
+ end
122
+
123
+ it 'renders an img tag with @params' do
116
124
  app.get '/img' do
117
125
  erb "<%= image '/images/hello.png', alt: 'Lolcatz' %>"
118
126
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe "Sinatra::FormHelpers methods" do
1
+ RSpec.describe "Sinatra::FormHelpers methods" do
4
2
  it 'renders an anchor tag' do
5
3
  expect( fh.form(:person, :create) ).to eq( '<form action="/person" method="post"><input type="hidden" name="_method" value="create" />' )
6
4
  end
@@ -58,6 +56,21 @@ describe "Sinatra::FormHelpers methods" do
58
56
  )
59
57
  end
60
58
 
59
+ it 'nests form elements arbitrarily with nil value' do
60
+ expect( fh.fieldset(:person) do |n|
61
+ # n.radio(:partners, 1..6)
62
+ n.textarea(:comments, nil)
63
+ end ).to eq( '<fieldset>' +
64
+ # '<input id="person_partners_1" name="person[partners]" type="radio" value="1" /> ' +
65
+ # '<input id="person_partners_2" name="person[partners]" type="radio" value="2" /> ' +
66
+ # '<input id="person_partners_3" name="person[partners]" type="radio" value="3" /> ' +
67
+ # '<input id="person_partners_4" name="person[partners]" type="radio" value="4" /> ' +
68
+ # '<input id="person_partners_5" name="person[partners]" type="radio" value="5" /> ' +
69
+ # '<input id="person_partners_6" name="person[partners]" type="radio" value="6" />' +
70
+ '<textarea id="person_comments" name="person[comments]"></textarea></fieldset>'
71
+ )
72
+ end
73
+
61
74
  it 'renders a fieldset tag with an input' do
62
75
  expect( fh.fieldset(:user) do |f|
63
76
  f.input(:last_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-formhelpers-huii
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - twilson63
@@ -11,90 +11,90 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-17 00:00:00.000000000 Z
14
+ date: 2014-11-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ~>
20
+ - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: '1.5'
22
+ version: '1.7'
23
23
  type: :development
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: '1.5'
29
+ version: '1.7'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ~>
34
+ - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: '10.1'
36
+ version: '10.3'
37
37
  type: :development
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: '10.1'
43
+ version: '10.3'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: rack-test
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ~>
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0.6'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ~>
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0.6'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ~>
62
+ - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '2.14'
64
+ version: '3.1'
65
65
  type: :development
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: '2.14'
71
+ version: '3.1'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: simplecov
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - ~>
76
+ - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: '0.8'
78
+ version: '0.9'
79
79
  type: :development
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.8'
85
+ version: '0.9'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: sinatra
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - ~>
90
+ - - "~>"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '1.4'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ~>
97
+ - - "~>"
98
98
  - !ruby/object:Gem::Version
99
99
  version: '1.4'
100
100
  description: Simple, lightweight form helpers for Sinatra.
@@ -104,9 +104,9 @@ executables: []
104
104
  extensions: []
105
105
  extra_rdoc_files: []
106
106
  files:
107
- - .gitignore
108
- - .rspec
109
- - .travis.yml
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".travis.yml"
110
110
  - Gemfile
111
111
  - Gemfile.lock
112
112
  - LICENSE
@@ -128,17 +128,17 @@ require_paths:
128
128
  - lib
129
129
  required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - '>='
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.2.2
141
+ rubygems_version: 2.4.2
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Form helpers for Sinatra