sinatra-formhelpers-ng 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +21 -4
- data/Rakefile +5 -44
- data/lib/sinatra/form_helpers/version.rb +5 -0
- data/sinatra-formhelpers-ng.gemspec +23 -48
- metadata +58 -41
- data/.document +0 -5
- data/VERSION +0 -1
- data/spec/form_helpers_spec.rb +0 -343
- data/spec/spec_helper.rb +0 -55
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c04449886805133585ada1d57ef54f36e3092580
|
4
|
+
data.tar.gz: ef517eb4b7d145c06f24d1356eb69a195f82269b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 74bd2abb14ef2b6c9eca5d6bc71e1e79e1b3c4e57e42a5fcda332ff7705ad247fea50f16ccc572e51cd69a7fa903c8c361166592033942ac2ab58919e65b39a8
|
7
|
+
data.tar.gz: 1bb2c8a8d6f1afaf2400e6e54ba64240975ceaf5adbd1debf981ce23641c90a596f51b3b3a6e7b06c17f1238d157e28ca2d4f5afd1124d4728702c8414bad20c
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sinatra-formhelpers-ng (1.9.1)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: https://rubygems.org/
|
3
8
|
specs:
|
4
9
|
bacon (1.2.0)
|
5
|
-
rack (1.
|
6
|
-
rack-
|
10
|
+
rack (1.6.1)
|
11
|
+
rack-protection (1.5.3)
|
12
|
+
rack
|
13
|
+
rack-test (0.6.3)
|
7
14
|
rack (>= 1.0)
|
15
|
+
rake (10.4.2)
|
16
|
+
sinatra (1.4.6)
|
17
|
+
rack (~> 1.4)
|
18
|
+
rack-protection (~> 1.4)
|
19
|
+
tilt (>= 1.3, < 3)
|
20
|
+
tilt (2.0.1)
|
8
21
|
|
9
22
|
PLATFORMS
|
10
23
|
ruby
|
11
24
|
|
12
25
|
DEPENDENCIES
|
13
|
-
bacon
|
14
|
-
|
26
|
+
bacon (~> 1.2)
|
27
|
+
bundler (~> 1.8)
|
28
|
+
rack-test (~> 0.6)
|
29
|
+
rake (~> 10.0)
|
30
|
+
sinatra (~> 1.4)
|
31
|
+
sinatra-formhelpers-ng!
|
data/Rakefile
CHANGED
@@ -1,53 +1,14 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
1
2
|
require 'rake/clean'
|
2
|
-
require '
|
3
|
+
require 'rdoc/task'
|
3
4
|
require 'fileutils'
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
5
|
require 'rake'
|
7
6
|
|
8
|
-
|
9
|
-
require 'jeweler'
|
10
|
-
Jeweler::Tasks.new do |gem|
|
11
|
-
gem.name = "sinatra-formhelpers-ng"
|
12
|
-
gem.summary = %Q{Form helpers for Sinatra}
|
13
|
-
gem.description = %Q{Simple, lightweight form helpers for Sinatra.}
|
14
|
-
gem.email = "cymenvig@gmail.com"
|
15
|
-
gem.homepage = "http://github.com/cymen/sinatra-formhelpers-ng"
|
16
|
-
gem.authors = ["twilson63", "Nate Wiger", "Cymen Vig"]
|
17
|
-
gem.add_development_dependency "bacon", ">= 0"
|
18
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
-
end
|
20
|
-
|
21
|
-
rescue LoadError
|
22
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
# SPECS ===============================================================
|
27
|
-
|
28
|
-
task :test => :spec
|
29
|
-
desc "run all the specs"
|
7
|
+
desc "Run the tests"
|
30
8
|
task :spec do
|
31
9
|
sh "bacon spec/*_spec.rb"
|
32
10
|
end
|
33
11
|
|
34
|
-
begin
|
35
|
-
require 'rcov/rcovtask'
|
36
|
-
Rcov::RcovTask.new do |test|
|
37
|
-
test.libs << 'spec'
|
38
|
-
test.pattern = 'spec/**/*_spec.rb'
|
39
|
-
test.verbose = true
|
40
|
-
end
|
41
|
-
rescue LoadError
|
42
|
-
task :rcov do
|
43
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
task :default => :test
|
49
|
-
|
50
|
-
require 'rdoc/task'
|
51
12
|
Rake::RDocTask.new do |rdoc|
|
52
13
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
53
14
|
|
@@ -57,5 +18,5 @@ Rake::RDocTask.new do |rdoc|
|
|
57
18
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
19
|
end
|
59
20
|
|
60
|
-
|
61
|
-
|
21
|
+
task :test => :spec
|
22
|
+
task :default => :test
|
@@ -1,55 +1,30 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sinatra/form_helpers/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "sinatra-formhelpers-ng"
|
8
|
+
gem.version = Sinatra::FormHelpers::VERSION
|
9
|
+
gem.date = Date.today.to_s
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
s.date = "2013-08-04"
|
13
|
-
s.description = "Simple, lightweight form helpers for Sinatra."
|
14
|
-
s.email = "cymenvig@gmail.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
"Gemfile",
|
22
|
-
"Gemfile.lock",
|
23
|
-
"LICENSE",
|
24
|
-
"README.md",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/sinatra/form_helpers.rb",
|
28
|
-
"sinatra-formhelpers-ng.gemspec",
|
29
|
-
"spec/form_helpers_spec.rb",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = "http://github.com/cymen/sinatra-formhelpers-ng"
|
33
|
-
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = "1.8.25"
|
35
|
-
s.summary = "Form helpers for Sinatra"
|
11
|
+
gem.summary = "Form helpers for Sinatra"
|
12
|
+
gem.description = "Simple, lightweight, Rails-like, form helpers for Sinatra."
|
36
13
|
|
37
|
-
|
38
|
-
|
14
|
+
gem.authors = ["twilson63", "Nate Wiger", "Cymen Vig", "Laurens Duijvesteijn"]
|
15
|
+
gem.email = "l.duijvesteijn@gmail.com"
|
16
|
+
gem.homepage = "https://github.com/duijf/sinatra-formhelpers-ng"
|
39
17
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
s.add_dependency(%q<rack-test>, [">= 0"])
|
52
|
-
s.add_dependency(%q<bacon>, [">= 0"])
|
53
|
-
end
|
18
|
+
gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
|
20
|
+
gem.platform = Gem::Platform::RUBY
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
gem.rubygems_version = "2.4.5"
|
23
|
+
|
24
|
+
gem.add_development_dependency "bundler", "~> 1.8"
|
25
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
26
|
+
gem.add_development_dependency "sinatra", "~> 1.4"
|
27
|
+
gem.add_development_dependency "bacon", "~> 1.2"
|
28
|
+
gem.add_development_dependency "rack-test", "~> 0.6"
|
54
29
|
end
|
55
30
|
|
metadata
CHANGED
@@ -1,107 +1,124 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-formhelpers-ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
5
|
-
prerelease:
|
4
|
+
version: 1.9.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- twilson63
|
9
8
|
- Nate Wiger
|
10
9
|
- Cymen Vig
|
10
|
+
- Laurens Duijvesteijn
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2015-05-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: bundler
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
19
|
requirements:
|
21
|
-
- -
|
20
|
+
- - "~>"
|
22
21
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
24
|
-
type: :
|
22
|
+
version: '1.8'
|
23
|
+
type: :development
|
25
24
|
prerelease: false
|
26
25
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
26
|
requirements:
|
29
|
-
- -
|
27
|
+
- - "~>"
|
30
28
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
29
|
+
version: '1.8'
|
32
30
|
- !ruby/object:Gem::Dependency
|
33
|
-
name:
|
31
|
+
name: rake
|
34
32
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
33
|
requirements:
|
37
|
-
- -
|
34
|
+
- - "~>"
|
38
35
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
|
-
type: :
|
36
|
+
version: '10.0'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '10.0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: sinatra
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '1.4'
|
51
|
+
type: :development
|
41
52
|
prerelease: false
|
42
53
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
54
|
requirements:
|
45
|
-
- -
|
55
|
+
- - "~>"
|
46
56
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
57
|
+
version: '1.4'
|
48
58
|
- !ruby/object:Gem::Dependency
|
49
59
|
name: bacon
|
50
60
|
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
61
|
requirements:
|
53
|
-
- -
|
62
|
+
- - "~>"
|
54
63
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
64
|
+
version: '1.2'
|
56
65
|
type: :development
|
57
66
|
prerelease: false
|
58
67
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
68
|
requirements:
|
61
|
-
- -
|
69
|
+
- - "~>"
|
62
70
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
64
|
-
|
65
|
-
|
71
|
+
version: '1.2'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rack-test
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0.6'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0.6'
|
86
|
+
description: Simple, lightweight, Rails-like, form helpers for Sinatra.
|
87
|
+
email: l.duijvesteijn@gmail.com
|
66
88
|
executables: []
|
67
89
|
extensions: []
|
68
|
-
extra_rdoc_files:
|
69
|
-
- LICENSE
|
70
|
-
- README.md
|
90
|
+
extra_rdoc_files: []
|
71
91
|
files:
|
72
|
-
- .
|
92
|
+
- ".gitignore"
|
73
93
|
- Gemfile
|
74
94
|
- Gemfile.lock
|
75
95
|
- LICENSE
|
76
96
|
- README.md
|
77
97
|
- Rakefile
|
78
|
-
- VERSION
|
79
98
|
- lib/sinatra/form_helpers.rb
|
99
|
+
- lib/sinatra/form_helpers/version.rb
|
80
100
|
- sinatra-formhelpers-ng.gemspec
|
81
|
-
|
82
|
-
- spec/spec_helper.rb
|
83
|
-
homepage: http://github.com/cymen/sinatra-formhelpers-ng
|
101
|
+
homepage: https://github.com/duijf/sinatra-formhelpers-ng
|
84
102
|
licenses: []
|
103
|
+
metadata: {}
|
85
104
|
post_install_message:
|
86
105
|
rdoc_options: []
|
87
106
|
require_paths:
|
88
107
|
- lib
|
89
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
109
|
requirements:
|
92
|
-
- -
|
110
|
+
- - ">="
|
93
111
|
- !ruby/object:Gem::Version
|
94
112
|
version: '0'
|
95
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
114
|
requirements:
|
98
|
-
- -
|
115
|
+
- - ">="
|
99
116
|
- !ruby/object:Gem::Version
|
100
117
|
version: '0'
|
101
118
|
requirements: []
|
102
119
|
rubyforge_project:
|
103
|
-
rubygems_version:
|
120
|
+
rubygems_version: 2.4.5
|
104
121
|
signing_key:
|
105
|
-
specification_version:
|
122
|
+
specification_version: 4
|
106
123
|
summary: Form helpers for Sinatra
|
107
124
|
test_files: []
|
data/.document
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.0
|
data/spec/form_helpers_spec.rb
DELETED
@@ -1,343 +0,0 @@
|
|
1
|
-
require File.expand_path 'spec_helper', File.dirname(__FILE__)
|
2
|
-
|
3
|
-
# class Application < Sinatra::Base
|
4
|
-
# register Sinatra::FormHelpers
|
5
|
-
#
|
6
|
-
# set :raise_errors, false
|
7
|
-
# set :show_exceptions, false
|
8
|
-
#
|
9
|
-
# get '/link' do
|
10
|
-
#
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# class Bacon::Context
|
15
|
-
# include Rack::Test::Methods
|
16
|
-
# def app
|
17
|
-
# Application # our application
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
|
21
|
-
describe "Sinatra::FormHelpers methods" do
|
22
|
-
it "renders an anchor tag" do
|
23
|
-
fh.form(:person, :create).should == '<form action="/person" method="POST"><input type="hidden" name="_method" value="create" />'
|
24
|
-
end
|
25
|
-
it 'renders a form tag' do
|
26
|
-
fh.form(:person, :update, :action => "/people/14").should ==
|
27
|
-
'<form action="/people/14" method="POST"><input type="hidden" name="_method" value="update" />'
|
28
|
-
end
|
29
|
-
it 'renders a form tag (2)' do
|
30
|
-
fh.form("/people/7", :delete).should ==
|
31
|
-
'<form action="/people/7" method="POST"><input type="hidden" name="_method" value="delete" />'
|
32
|
-
end
|
33
|
-
it 'renders a form tag (3)' do
|
34
|
-
fh.form("/people", :create).should ==
|
35
|
-
'<form action="/people" method="POST"><input type="hidden" name="_method" value="create" />'
|
36
|
-
end
|
37
|
-
it 'renders a nested form tag' do
|
38
|
-
fh.form(:person, :create) do |f|
|
39
|
-
# f.input(:first_name)
|
40
|
-
f.input(:last_name)
|
41
|
-
end.should == '<form action="/person" method="POST"><input type="hidden" name="_method" value="create" /><fieldset>' +
|
42
|
-
# '<input id="person_first_name" name="person[first_name]" type="text" />' +
|
43
|
-
'<input id="person_last_name" name="person[last_name]" type="text" />' +
|
44
|
-
'</fieldset></form>'
|
45
|
-
end
|
46
|
-
it 'nests form elements arbitrarily' do
|
47
|
-
fh.fieldset(:person) do |n|
|
48
|
-
# n.radio(:partners, 1..6)
|
49
|
-
n.textarea(:comments, "yo yo yo!")
|
50
|
-
end.should == '<fieldset>' +
|
51
|
-
# '<input id="person_partners_1" name="person[partners]" type="radio" value="1" /> ' +
|
52
|
-
# '<input id="person_partners_2" name="person[partners]" type="radio" value="2" /> ' +
|
53
|
-
# '<input id="person_partners_3" name="person[partners]" type="radio" value="3" /> ' +
|
54
|
-
# '<input id="person_partners_4" name="person[partners]" type="radio" value="4" /> ' +
|
55
|
-
# '<input id="person_partners_5" name="person[partners]" type="radio" value="5" /> ' +
|
56
|
-
# '<input id="person_partners_6" name="person[partners]" type="radio" value="6" />' +
|
57
|
-
'<textarea id="person_comments" name="person[comments]">yo yo yo!</textarea></fieldset>'
|
58
|
-
end
|
59
|
-
it 'renders a link tag' do
|
60
|
-
fh.link('http://google.com').should == '<a href="http://google.com">http://google.com</a>'
|
61
|
-
end
|
62
|
-
it 'renders a form label tag' do
|
63
|
-
fh.label(:person, :first_name).should == '<label for="person_first_name">First Name</label>'
|
64
|
-
end
|
65
|
-
it 'renders a form checkbox tag' do
|
66
|
-
fh.checkbox(:person, :gender, %w[M F], :join => '<br />').should ==
|
67
|
-
'<input id="person_gender_m" name="person[gender][]" type="checkbox" value="M" /><label for="person_gender_m">M</label><br />' +
|
68
|
-
'<input id="person_gender_f" name="person[gender][]" type="checkbox" value="F" /><label for="person_gender_f">F</label>'
|
69
|
-
end
|
70
|
-
it 'renders a minimal text tag' do
|
71
|
-
fh.input(:q).should == %q(<input id="q" name="q" type="text" />)
|
72
|
-
end
|
73
|
-
it 'renders a minimal textarea tag' do
|
74
|
-
fh.textarea(:r).should == %q(<textarea id="r" name="r"></textarea>)
|
75
|
-
end
|
76
|
-
it 'renders a submit tag' do
|
77
|
-
fh.submit.should == %q(<input id="button_submit" name="submit" type="submit" value="Submit" />)
|
78
|
-
fh.submit("Send!").should == %q(<input id="button_send_" name="submit" type="submit" value="Send!" />)
|
79
|
-
end
|
80
|
-
it 'renders a reset tag' do
|
81
|
-
fh.reset.should == %q(<input id="button_reset" name="reset" type="reset" value="Reset" />)
|
82
|
-
fh.reset("Blark").should == %q(<input id="button_blark" name="reset" type="reset" value="Blark" />)
|
83
|
-
end
|
84
|
-
it 'supports multiple values for checkboxes' do
|
85
|
-
fh.params = {:user => {'devices' => ['iPhone', 'iPad'] }}
|
86
|
-
fh.checkbox(:user, :devices, ['iPhone', 'iPad', 'iPod', 'iPoop']).should ==
|
87
|
-
"<input checked=\"checked\" id=\"user_devices_iphone\" name=\"user[devices][]\" type=\"checkbox\" value=\"iPhone\" /><label for=\"user_devices_iphone\">iPhone</label> <input checked=\"checked\" id=\"user_devices_ipad\" name=\"user[devices][]\" type=\"checkbox\" value=\"iPad\" /><label for=\"user_devices_ipad\">iPad</label> <input id=\"user_devices_ipod\" name=\"user[devices][]\" type=\"checkbox\" value=\"iPod\" /><label for=\"user_devices_ipod\">iPod</label> <input id=\"user_devices_ipoop\" name=\"user[devices][]\" type=\"checkbox\" value=\"iPoop\" /><label for=\"user_devices_ipoop\">iPoop</label>"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "Sinatra::FormHelpers in app" do
|
92
|
-
it 'renders an anchor tag' do
|
93
|
-
app.get '/link' do
|
94
|
-
erb "<%= link 'google', 'http://www.google.com', :title => 'Google' %>"
|
95
|
-
end
|
96
|
-
|
97
|
-
get '/link'
|
98
|
-
last_response.body.should == %q(<a href="http://www.google.com" title="Google">google</a>)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'renders a label tag' do
|
102
|
-
app.get '/label' do
|
103
|
-
erb "<%= label :person, :first_name %>"
|
104
|
-
end
|
105
|
-
|
106
|
-
get '/label'
|
107
|
-
last_response.body.should == %q(<label for="person_first_name">First Name</label>)
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'renders a label tag with display input' do
|
111
|
-
app.get '/hello' do
|
112
|
-
erb "<%= label :person, :first_name, 'Hello World'%>"
|
113
|
-
end
|
114
|
-
|
115
|
-
get '/hello'
|
116
|
-
last_response.body.should == %q(<label for="person_first_name">Hello World</label>)
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'renders an input tag type text without @params' do
|
120
|
-
app.get '/text' do
|
121
|
-
erb "<%= input :person, :first_name %>"
|
122
|
-
end
|
123
|
-
|
124
|
-
get '/text'
|
125
|
-
last_response.body.should =~ /name="person\[first_name\]"/
|
126
|
-
last_response.body.should == %q(<input id="person_first_name" name="person[first_name]" type="text" />)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'accepts an input tag with custom type option' do
|
130
|
-
app.get '/input-with-custom-type' do
|
131
|
-
erb "<%= input :person, :password, type: 'password' %>"
|
132
|
-
end
|
133
|
-
|
134
|
-
get '/input-with-custom-type'
|
135
|
-
last_response.body.should == '<input id="person_password" name="person[password]" type="password" />'
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'renders an input tag type text with single arg' do
|
139
|
-
app.get '/q' do
|
140
|
-
erb "<%= input :q %>"
|
141
|
-
end
|
142
|
-
|
143
|
-
get '/q'
|
144
|
-
last_response.body.should == %q(<input id="q" name="q" type="text" />)
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'renders an input tag type text with @params' do
|
148
|
-
app.get '/tom' do
|
149
|
-
@params = { :person => {"first_name" => "Tom"}}
|
150
|
-
erb "<%= input :person, :first_name %>"
|
151
|
-
end
|
152
|
-
|
153
|
-
get '/tom'
|
154
|
-
last_response.body.should == %q(<input id="person_first_name" name="person[first_name]" type="text" value="Tom" />)
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'renders a password tag type password' do
|
158
|
-
app.get '/password' do
|
159
|
-
erb "<%= password :person, :password %>"
|
160
|
-
end
|
161
|
-
|
162
|
-
get '/password'
|
163
|
-
last_response.body.should == '<input id="person_password" name="person[password]" type="password" />'
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'renders a button tag type button' do
|
167
|
-
app.get '/button' do
|
168
|
-
erb "<%= button :new %>"
|
169
|
-
end
|
170
|
-
|
171
|
-
get '/button'
|
172
|
-
last_response.body.should == '<input id="button_new" name="button" type="button" value="new" />'
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'renders an textarea tag type text without @params' do
|
176
|
-
app.get '/notes' do
|
177
|
-
erb "<%= textarea :person, :notes %>"
|
178
|
-
end
|
179
|
-
|
180
|
-
get '/notes?person[notes]=Yeppers'
|
181
|
-
last_response.body.should == %q(<textarea id="person_notes" name="person[notes]">Yeppers</textarea>)
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'renders a textarea tag with @params' do
|
185
|
-
app.get '/notes2' do
|
186
|
-
@params = { :person => {"notes" => "This is a note"}}
|
187
|
-
erb "<%= textarea :person, :notes %>"
|
188
|
-
end
|
189
|
-
|
190
|
-
get '/notes2'
|
191
|
-
last_response.body.should == %q(<textarea id="person_notes" name="person[notes]">This is a note</textarea>)
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'renders a textarea tag with @params' do
|
195
|
-
app.get '/img' do
|
196
|
-
erb "<%= image '/images/hello.png', :alt => 'Lolcatz' %>"
|
197
|
-
end
|
198
|
-
|
199
|
-
get '/img'
|
200
|
-
last_response.body.should == '<img alt="Lolcatz" src="/images/hello.png" />'
|
201
|
-
end
|
202
|
-
|
203
|
-
it 'renders an input tag with a submit type' do
|
204
|
-
app.get '/sub' do
|
205
|
-
erb "<%= submit 'Create' %>"
|
206
|
-
end
|
207
|
-
|
208
|
-
get '/sub'
|
209
|
-
last_response.body.should == '<input id="button_create" name="submit" type="submit" value="Create" />'
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'renders an input tag with a submit type with zero args' do
|
213
|
-
app.get '/create' do
|
214
|
-
erb "<%= submit %>"
|
215
|
-
end
|
216
|
-
|
217
|
-
get '/create'
|
218
|
-
last_response.body.should == '<input id="button_submit" name="submit" type="submit" value="Submit" />'
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'renders an input tag with a checkbox type' do
|
222
|
-
app.get '/check' do
|
223
|
-
erb "<%= checkbox :person, :active, 'Yes' %>"
|
224
|
-
end
|
225
|
-
|
226
|
-
get '/check'
|
227
|
-
last_response.body.should ==
|
228
|
-
'<input id="person_active_yes" name="person[active]" type="checkbox" value="Yes" /><label for="person_active_yes">Yes</label>'
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'renders an input tag with a multiple checkbox type' do
|
232
|
-
app.get '/check2' do
|
233
|
-
erb "<%= checkbox :person, :eyes, [1,2,3] %>"
|
234
|
-
end
|
235
|
-
|
236
|
-
get '/check2'
|
237
|
-
last_response.body.should ==
|
238
|
-
'<input id="person_eyes_1" name="person[eyes][]" type="checkbox" value="1" /><label for="person_eyes_1">1</label> ' +
|
239
|
-
'<input id="person_eyes_2" name="person[eyes][]" type="checkbox" value="2" /><label for="person_eyes_2">2</label> ' +
|
240
|
-
'<input id="person_eyes_3" name="person[eyes][]" type="checkbox" value="3" /><label for="person_eyes_3">3</label>'
|
241
|
-
end
|
242
|
-
|
243
|
-
it 'renders an input tag with a radio type' do
|
244
|
-
app.get '/radio' do
|
245
|
-
erb "<%= radio :person, :gender, [['M','Male'],['F','Female'],'Other'] %>"
|
246
|
-
end
|
247
|
-
|
248
|
-
get '/radio'
|
249
|
-
last_response.body.should ==
|
250
|
-
"<input id=\"person_gender_m\" name=\"person[gender]\" type=\"radio\" value=\"M\" /><label for=\"person_gender_m\">Male</label> " +
|
251
|
-
"<input id=\"person_gender_f\" name=\"person[gender]\" type=\"radio\" value=\"F\" /><label for=\"person_gender_f\">Female</label> " +
|
252
|
-
"<input id=\"person_gender_other\" name=\"person[gender]\" type=\"radio\" value=\"Other\" /><label for=\"person_gender_other\">Other</label>"
|
253
|
-
end
|
254
|
-
|
255
|
-
it 'renders a select tag' do
|
256
|
-
app.get '/select' do
|
257
|
-
erb "<%= select :person, :relationship, ['Friend','CoWorker','Lead'] %>"
|
258
|
-
end
|
259
|
-
|
260
|
-
get '/select'
|
261
|
-
last_response.body.should == '<select id="person_relationship" name="person[relationship]">' +
|
262
|
-
'<option value="Friend">Friend</option><option value="CoWorker">CoWorker</option>' +
|
263
|
-
'<option value="Lead">Lead</option></select>'
|
264
|
-
end
|
265
|
-
|
266
|
-
it 'renders a select tag with selected option' do
|
267
|
-
app.get '/select2' do
|
268
|
-
@params = { :person => {"relationship" => "CoWorker"}}
|
269
|
-
erb "<%= select :person, :relationship, ['Friend','CoWorker','Lead'] %>"
|
270
|
-
end
|
271
|
-
|
272
|
-
get '/select2'
|
273
|
-
last_response.body.should == '<select id="person_relationship" name="person[relationship]">' +
|
274
|
-
'<option value="Friend">Friend</option><option selected="selected" value="CoWorker">CoWorker</option>' +
|
275
|
-
'<option value="Lead">Lead</option></select>'
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'renders a hidden tag with single arg' do
|
279
|
-
app.get '/hidden' do
|
280
|
-
erb "<%= hidden :q %>"
|
281
|
-
end
|
282
|
-
|
283
|
-
get '/hidden'
|
284
|
-
last_response.body.should == %q(<input id="q" name="q" type="hidden" />)
|
285
|
-
end
|
286
|
-
|
287
|
-
it 'renders a hidden tag with value' do
|
288
|
-
app.get '/hidden2' do
|
289
|
-
erb '<%= hidden :person, :id, :value => 1 %>'
|
290
|
-
end
|
291
|
-
|
292
|
-
get '/hidden2'
|
293
|
-
last_response.body.should == '<input id="person_id" name="person[id]" type="hidden" value="1" />'
|
294
|
-
end
|
295
|
-
|
296
|
-
it 'renders a form tag' do
|
297
|
-
app.get '/form' do
|
298
|
-
erb "<%= form :person, :create %>"
|
299
|
-
end
|
300
|
-
|
301
|
-
get '/form'
|
302
|
-
last_response.body.should == %q(<form action="/person" method="POST"><input type="hidden" name="_method" value="create" />)
|
303
|
-
end
|
304
|
-
|
305
|
-
# it 'renders a form_for style tag' do
|
306
|
-
# app.get '/form_for' do
|
307
|
-
# erb <<-EndTemplate
|
308
|
-
# <% form(:person, :create) do |f| %>
|
309
|
-
# <%= f.input(:login) %>
|
310
|
-
# <%= f.password(:password) %>
|
311
|
-
# <%= submit %>
|
312
|
-
# <% end %>
|
313
|
-
# EndTemplate
|
314
|
-
# end
|
315
|
-
#
|
316
|
-
# get '/form_for'
|
317
|
-
# last_response.body.should == %q(<form action="/person" method="POST">)
|
318
|
-
# end
|
319
|
-
|
320
|
-
it 'renders a fieldset group' do
|
321
|
-
app.get '/fieldset' do
|
322
|
-
erb <<-EndTemplate
|
323
|
-
<% fieldset(:user) do |f| %>
|
324
|
-
<%= f.input(:first_name) %>
|
325
|
-
<%= f.input(:last_name) %>
|
326
|
-
|
327
|
-
<%= f.input(:email, :size => 40) %>
|
328
|
-
|
329
|
-
<%= f.password(:password) %>
|
330
|
-
<%= f.password(:confirm_password) %>
|
331
|
-
|
332
|
-
<%= f.radio(:gender, ['M', 'F']) %>
|
333
|
-
<% end %>
|
334
|
-
<%= submit %>
|
335
|
-
EndTemplate
|
336
|
-
end
|
337
|
-
|
338
|
-
get '/fieldset'
|
339
|
-
last_response.body.should ==
|
340
|
-
" <input id=\"user_first_name\" name=\"user[first_name]\" type=\"text\" />\n <input id=\"user_last_name\" name=\"user[last_name]\" type=\"text\" />\n\n <input id=\"user_email\" name=\"user[email]\" size=\"40\" type=\"text\" />\n\n <input id=\"user_password\" name=\"user[password]\" type=\"password\" />\n <input id=\"user_confirm_password\" name=\"user[confirm_password]\" type=\"password\" />\n\n <input id=\"user_gender_m\" name=\"user[gender]\" type=\"radio\" value=\"M\" /><label for=\"user_gender_m\">M</label> <input id=\"user_gender_f\" name=\"user[gender]\" type=\"radio\" value=\"F\" /><label for=\"user_gender_f\">F</label>\n<input id=\"button_submit\" name=\"submit\" type=\"submit\" value=\"Submit\" />"
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
data/spec/spec_helper.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bacon'
|
3
|
-
require 'rack/test'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.expand_path File.dirname(__FILE__))
|
6
|
-
$LOAD_PATH.unshift(File.expand_path File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
-
require 'sinatra/base'
|
8
|
-
require 'sinatra/form_helpers'
|
9
|
-
|
10
|
-
class TestFormHelpers
|
11
|
-
include Sinatra::FormHelpers
|
12
|
-
attr_accessor :params
|
13
|
-
def initialize
|
14
|
-
@params = {}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
def fh
|
18
|
-
@fh ||= TestFormHelpers.new
|
19
|
-
end
|
20
|
-
|
21
|
-
class Application < Sinatra::Base
|
22
|
-
helpers Sinatra::FormHelpers
|
23
|
-
set :raise_errors, false
|
24
|
-
set :show_exceptions, false
|
25
|
-
end
|
26
|
-
|
27
|
-
Bacon.summary_on_exit
|
28
|
-
class Bacon::Context
|
29
|
-
include Rack::Test::Methods
|
30
|
-
def app
|
31
|
-
Application
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Lifted from sinatra/test_helpers (sinatra-contrib)
|
36
|
-
# def app
|
37
|
-
# @app ||= Class.new Sinatra::Base
|
38
|
-
# Rack::Lint.new @app
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# def app=(base)
|
42
|
-
# @app = base
|
43
|
-
# end
|
44
|
-
#
|
45
|
-
# def mock_app(base = Sinatra::Base, &block)
|
46
|
-
# inner = nil
|
47
|
-
# @app = Sinatra.new(base) do
|
48
|
-
# inner = self
|
49
|
-
# set :raise_errors, false
|
50
|
-
# set :show_exceptions, false
|
51
|
-
# class_eval(&block)
|
52
|
-
# end
|
53
|
-
# @settings = inner
|
54
|
-
# app
|
55
|
-
# end
|