merb 0.5.1 → 0.5.2
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.
- data/Rakefile +1 -1
- data/SVN_REVISION +1 -1
- data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +1 -1
- data/app_generators/merb/templates/config/merb_init.rb +1 -1
- data/lib/merb.rb +1 -1
- data/lib/merb/mixins/controller.rb +5 -3
- data/lib/merb/mixins/general_controller.rb +8 -6
- data/lib/merb/mixins/view_context.rb +34 -7
- data/lib/merb/test/helper.rb +121 -12
- data/lib/merb/test/multipart.rb +12 -4
- data/lib/merb/test/rspec_matchers/controller_matchers.rb +2 -2
- data/lib/merb/version.rb +2 -2
- data/lib/tasks/merb.rake +1 -1
- data/spec/merb/controller_spec.rb +10 -0
- data/spec/merb/dispatch_spec.rb +4 -7
- data/spec/merb/multipart_spec.rb +2 -1
- data/spec/merb/request_spec.rb +1 -0
- data/spec/merb/view_context_spec.rb +44 -12
- data/spec/spec_helper.rb +3 -0
- data/spec/spec_helpers/url_shared_behaviour.rb +2 -0
- metadata +105 -98
data/Rakefile
CHANGED
@@ -168,7 +168,7 @@ end
|
|
168
168
|
|
169
169
|
task :release => :package do
|
170
170
|
if ENV["RELEASE"]
|
171
|
-
|
171
|
+
puts %{rubyforge add_release merb merb "#{ENV["RELEASE"]}" pkg/#{NAME}-#{Merb::VERSION}.gem}
|
172
172
|
else
|
173
173
|
puts "Usage: rake release RELEASE='Clever tag line goes here'"
|
174
174
|
end
|
data/SVN_REVISION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1297
|
@@ -131,7 +131,7 @@
|
|
131
131
|
<div class="header">
|
132
132
|
<h1><%= @exception.name.humanize %> <sup class="error_<%= @exception.class::STATUS %>"><%= @exception.class::STATUS %></sup></h1>
|
133
133
|
<% if show_details = ::Merb::Config[:exception_details] -%>
|
134
|
-
<h2><%= @exception.message %></h2>
|
134
|
+
<h2><%= ERB::Util.html_escape @exception.message %></h2>
|
135
135
|
<% else -%>
|
136
136
|
<h2>Sorry about that...</h2>
|
137
137
|
<% end -%>
|
@@ -13,5 +13,5 @@ puts "Loading Application..."
|
|
13
13
|
Merb::BootLoader.load_application
|
14
14
|
|
15
15
|
# Load environment-specific configuration
|
16
|
-
environment_config = File.join(Merb.root, 'config', 'environments', Merb.environment)
|
16
|
+
environment_config = File.join(Merb.root, 'config', 'environments', Merb.environment + '.rb')
|
17
17
|
require environment_config if File.exist?(environment_config)
|
data/lib/merb.rb
CHANGED
@@ -64,10 +64,12 @@ module Merb
|
|
64
64
|
#
|
65
65
|
# +url+ - URL to redirect to; it can be either a relative or
|
66
66
|
# fully-qualified URL.
|
67
|
+
# +permanent+ - Whether to use permanent redirection.
|
67
68
|
#
|
68
|
-
def redirect(url)
|
69
|
-
|
70
|
-
|
69
|
+
def redirect(url, permanent = false)
|
70
|
+
status = permanent ? 301 : 302
|
71
|
+
Merb.logger.info("Redirecting to: #{url} status: #{status}")
|
72
|
+
set_status(status)
|
71
73
|
headers['Location'] = url
|
72
74
|
"<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>"
|
73
75
|
end
|
@@ -161,7 +161,7 @@ module Merb
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# +format_extension+ dictates when named route URLs generated by the url
|
164
|
-
# method will have a file extension. It will return either
|
164
|
+
# method will have a file extension. It will return either nil or the format
|
165
165
|
# extension to append.
|
166
166
|
#
|
167
167
|
# ==== Configuration Options
|
@@ -192,12 +192,14 @@ module Merb
|
|
192
192
|
# # => /products/3
|
193
193
|
#
|
194
194
|
def format_extension(new_params={})
|
195
|
-
|
196
|
-
if
|
197
|
-
|
198
|
-
use_format = prms[:format] != 'html' && prms[:format]
|
195
|
+
format = params.merge(new_params)[:format] || 'html'
|
196
|
+
if format != 'html' || always_use_format_extension?
|
197
|
+
format || 'html'
|
199
198
|
end
|
200
|
-
|
199
|
+
end
|
200
|
+
|
201
|
+
def always_use_format_extension?
|
202
|
+
Merb::Config[:use_format_in_urls]
|
201
203
|
end
|
202
204
|
|
203
205
|
|
@@ -488,9 +488,6 @@ module Merb
|
|
488
488
|
#
|
489
489
|
# throw_content(:header, "Hello World")
|
490
490
|
#
|
491
|
-
# In Haml Templates, use the
|
492
|
-
#
|
493
|
-
#
|
494
491
|
def throw_content(name, content = "", &block)
|
495
492
|
content << capture(&block) if block_given?
|
496
493
|
controller.thrown_content[name] << content
|
@@ -507,12 +504,42 @@ module Merb
|
|
507
504
|
_buffer( binding ) << string
|
508
505
|
end
|
509
506
|
|
507
|
+
# Creates a generic HTML tag. You can invoke it a variety of ways.
|
508
|
+
#
|
509
|
+
# tag :div
|
510
|
+
# # <div></div>
|
511
|
+
#
|
512
|
+
# tag :div, 'content'
|
513
|
+
# # <div>content</div>
|
514
|
+
#
|
515
|
+
# tag :div, :class => 'class'
|
516
|
+
# # <div class="class"></div>
|
517
|
+
#
|
518
|
+
# tag :div, 'content', :class => 'class'
|
519
|
+
# # <div class="class">content</div>
|
520
|
+
#
|
521
|
+
# tag :div do
|
522
|
+
# 'content'
|
523
|
+
# end
|
524
|
+
# # <div>content</div>
|
525
|
+
#
|
526
|
+
# tag :div, :class => 'class' do
|
527
|
+
# 'content'
|
528
|
+
# end
|
529
|
+
# # <div class="class">content</div>
|
530
|
+
#
|
531
|
+
def tag(name, contents = nil, attrs = {}, &block)
|
532
|
+
attrs = contents if contents.is_a?(Hash)
|
533
|
+
contents = capture(&block) if block_given?
|
534
|
+
open_tag(name, attrs) + contents.to_s + close_tag(name)
|
535
|
+
end
|
536
|
+
|
510
537
|
# Creates the opening tag with attributes for the provided +name+
|
511
538
|
# attrs is a hash where all members will be mapped to key="value"
|
512
539
|
#
|
513
540
|
# Note: This tag will need to be closed
|
514
541
|
def open_tag(name, attrs = nil)
|
515
|
-
"<#{name}#{
|
542
|
+
"<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}>"
|
516
543
|
end
|
517
544
|
|
518
545
|
# Creates a closing tag
|
@@ -525,7 +552,7 @@ module Merb
|
|
525
552
|
# +name+ : the name of the tag to create
|
526
553
|
# +attrs+ : a hash where all members will be mapped to key="value"
|
527
554
|
def self_closing_tag(name, attrs = nil)
|
528
|
-
"<#{name}#{' ' + attrs.to_html_attributes if attrs}/>"
|
529
|
-
end
|
530
|
-
end
|
555
|
+
"<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}/>"
|
556
|
+
end
|
557
|
+
end
|
531
558
|
end
|
data/lib/merb/test/helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'merb/test/fake_request'
|
2
2
|
require 'merb/test/hpricot'
|
3
|
+
require 'merb/test/multipart'
|
3
4
|
include HpricotTestHelper
|
4
5
|
|
5
6
|
module Merb
|
@@ -14,16 +15,41 @@ module Merb
|
|
14
15
|
end
|
15
16
|
|
16
17
|
# For integration/functional testing
|
17
|
-
|
18
|
+
#
|
19
|
+
# This helper is the basis of the <tt>get</tt>, <tt>post</tt>, <tt>put</tt>, and <tt>delete</tt> helper
|
20
|
+
#
|
21
|
+
# By default a fake request is yielded to the block for local modification.
|
22
|
+
# +opts+ takes any options that you want pass to the methods, plus some reserved ones
|
23
|
+
#
|
24
|
+
# ===Yielding
|
25
|
+
# You can get the request helper to yield either a fake request object, or a controller
|
26
|
+
# Do this with the +:yield+ option. Values can be +:request+, or +:controller+. +:request+ is default
|
27
|
+
# When you yield the controller, it is available inside the block with the controller method, so you don't need to
|
28
|
+
# explicitly set it in the block chute.
|
29
|
+
# ====Example
|
30
|
+
# request( :get, '/', :yields => :controller) do |controller|
|
31
|
+
# controller.stub!(:render)
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# You can also pass in a fake request object which may be useful if your yielding a controller.
|
35
|
+
# Use the opts[:fake_request] to do this.
|
36
|
+
# ====Example
|
37
|
+
# request( :get, '/', :yields => :controller, :fake_request => @my_fake_request) do
|
38
|
+
# controller.stub!(:render)
|
39
|
+
# end
|
40
|
+
def request(verb, path, opts = {}, &block)
|
18
41
|
response = StringIO.new
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
42
|
+
|
43
|
+
request = opts.delete(:fake_request) || Merb::Test::FakeRequest.with(path, opts.merge(:request_method => (verb.to_s.upcase rescue 'GET')))
|
44
|
+
yield_to_controller = opts.delete(:yields)
|
45
|
+
|
46
|
+
if yield_to_controller == :controller
|
47
|
+
request_yielding_controller(request, response, &block)
|
48
|
+
else
|
49
|
+
request_yielding_request(request, response, &block)
|
50
|
+
end
|
24
51
|
end
|
25
|
-
|
26
|
-
|
52
|
+
|
27
53
|
# Makes a get request routed to +path+ with any options encoded into the
|
28
54
|
# request url
|
29
55
|
# Example
|
@@ -31,7 +57,7 @@ module Merb
|
|
31
57
|
# get "/users", :user => {:login => "dave", :email => "email@example.com"}
|
32
58
|
# }}}
|
33
59
|
def get(path, opts = {}, &block)
|
34
|
-
request("GET",
|
60
|
+
request("GET", path, opts, &block)
|
35
61
|
end
|
36
62
|
|
37
63
|
# Makes a post request routed to +path+ with any options encoded into the
|
@@ -41,7 +67,7 @@ module Merb
|
|
41
67
|
# post "/users", :user => {:login => "dave", :email => "email@example.com"}
|
42
68
|
# }}}
|
43
69
|
def post(path, opts = {}, &block)
|
44
|
-
request("POST",
|
70
|
+
request("POST",path, opts, &block)
|
45
71
|
end
|
46
72
|
|
47
73
|
# Makes a put request routed to +path+ with any options encoded into the
|
@@ -51,7 +77,7 @@ module Merb
|
|
51
77
|
# put "/users/1", :user => {:login => "dave", :email => "email@example.com"}
|
52
78
|
# }}}
|
53
79
|
def put(path,opts = {}, &block)
|
54
|
-
request("PUT",
|
80
|
+
request("PUT",path, opts, &block)
|
55
81
|
end
|
56
82
|
|
57
83
|
# Makes a delete request routed to +path+ with any options encoded into the request url
|
@@ -60,7 +86,21 @@ module Merb
|
|
60
86
|
# delete "/users/1", :user => {:login => "dave", :email => "email@example.com"}
|
61
87
|
# }}}
|
62
88
|
def delete(path, opts= {}, &block)
|
63
|
-
request("DELETE",
|
89
|
+
request("DELETE",path, opts, &block)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Posts multipart form data to a path
|
93
|
+
# pass the +path+ to send and the parameters. For file uploads, just include a file as the option value.
|
94
|
+
# ===Example
|
95
|
+
# multipart_post("/my_collection", :foo => "bar", :user => { :login => "joe", :image => File.open("my_image.png")})
|
96
|
+
def multipart_post(path, params = {}, &block)
|
97
|
+
multipart_request(path, params.merge!(:request_method => 'POST'), &block)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Posts multipart form data to a path
|
101
|
+
# Same as +multipart_post+ but used for PUT(ting) data to the server
|
102
|
+
def multipart_put(path, params = {}, &block)
|
103
|
+
multipart_request(path, params.merge!(:request_method => 'PUT'), &block)
|
64
104
|
end
|
65
105
|
|
66
106
|
def controller
|
@@ -130,6 +170,75 @@ module Merb
|
|
130
170
|
path = path << "?" << params_to_query_string(opts) unless opts.empty?
|
131
171
|
path
|
132
172
|
end
|
173
|
+
|
174
|
+
protected
|
175
|
+
|
176
|
+
def request_yielding_request(request, response, &block)
|
177
|
+
# response = StringIO.new
|
178
|
+
# @request = Merb::Test::FakeRequest.with(path, :request_method => (verb.to_s.upcase rescue 'GET'))
|
179
|
+
@request = request
|
180
|
+
|
181
|
+
yield @request if block_given?
|
182
|
+
|
183
|
+
@controller, @action = Merb::Dispatcher.handle @request, response
|
184
|
+
end
|
185
|
+
|
186
|
+
def request_yielding_controller(request, response, &block)
|
187
|
+
# response = StringIO.new
|
188
|
+
# @request = Merb::Test::FakeRequest.with(path, :request_method => (verb.to_s.upcase rescue 'GET'))
|
189
|
+
@request = Merb::Request.new(request)
|
190
|
+
|
191
|
+
check_request_for_route(@request)
|
192
|
+
|
193
|
+
dispatch_fake_request(@request, response, &block)
|
194
|
+
end
|
195
|
+
|
196
|
+
def multipart_request(path, params = {}, &block)
|
197
|
+
response = StringIO.new
|
198
|
+
request = request_with_multipart_params(path, params)
|
199
|
+
check_request_for_route(request)
|
200
|
+
dispatch_fake_request(request, response, &block)
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
def check_request_for_route(request)
|
205
|
+
if request.route_params.empty?
|
206
|
+
raise ControllerExceptions::BadRequest, "No routes match the request"
|
207
|
+
elsif request.controller_name.nil?
|
208
|
+
raise ControllerExceptions::BadRequest, "Route matched, but route did not specify a controller"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Used for yielding a controller with request and multipart helpers
|
213
|
+
def dispatch_fake_request(request, response, status = 200, &block)
|
214
|
+
klass = request.controller_class
|
215
|
+
@controller = klass.build(request, response, status)
|
216
|
+
|
217
|
+
@controller.send(:setup_session)
|
218
|
+
@controller.stub!(:setup_session).and_return(true)
|
219
|
+
|
220
|
+
yield @controller if block_given?
|
221
|
+
|
222
|
+
@controller.dispatch(request.action)
|
223
|
+
[@controller, request.action]
|
224
|
+
|
225
|
+
rescue => exception
|
226
|
+
exception = Dispatcher.send(:controller_exception, exception)
|
227
|
+
@controller, @action = Dispatcher.send(:dispatch_exception, request, response, exception)
|
228
|
+
end
|
229
|
+
|
230
|
+
def request_with_multipart_params(path, params = {})
|
231
|
+
request_method = params.delete(:request_method) || "GET"
|
232
|
+
request = Merb::Test::FakeRequest.new(:request_uri => path)
|
233
|
+
m = Merb::Test::Multipart::Post.new(params)
|
234
|
+
body, head = m.to_multipart
|
235
|
+
request['REQUEST_METHOD'] = request_method
|
236
|
+
request['CONTENT_TYPE'] = head
|
237
|
+
request['CONTENT_LENGTH'] = body.length
|
238
|
+
request.post_body = body
|
239
|
+
Merb::Request.new(request)
|
240
|
+
end
|
241
|
+
|
133
242
|
end
|
134
243
|
end
|
135
244
|
end
|
data/lib/merb/test/multipart.rb
CHANGED
@@ -38,12 +38,19 @@ module Merb
|
|
38
38
|
push_params(params)
|
39
39
|
end
|
40
40
|
|
41
|
-
def push_params(params)
|
41
|
+
def push_params(params, prefix = nil)
|
42
42
|
params.sort_by {|k| k.to_s}.each do |key, value|
|
43
|
+
param_key = prefix.nil? ? key : "#{prefix}[#{key}]"
|
43
44
|
if value.respond_to?(:read)
|
44
|
-
@multipart_params << FileParam.new(
|
45
|
+
@multipart_params << FileParam.new(param_key, value.path, value.read)
|
45
46
|
else
|
46
|
-
|
47
|
+
if value.is_a?(Hash) || value.is_a?(Mash)
|
48
|
+
value.keys.each do |k|
|
49
|
+
push_params(value, param_key)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
@multipart_params << Param.new(param_key, value)
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
49
56
|
end
|
@@ -52,7 +59,8 @@ module Merb
|
|
52
59
|
query = @multipart_params.collect { |param| "--" + BOUNDARY + "\r\n" + param.to_multipart }.join("") + "--" + BOUNDARY + "--"
|
53
60
|
return query, CONTENT_TYPE
|
54
61
|
end
|
55
|
-
end
|
62
|
+
end
|
63
|
+
|
56
64
|
end
|
57
65
|
end
|
58
66
|
end
|
@@ -5,7 +5,7 @@ module Merb
|
|
5
5
|
class BeRedirect
|
6
6
|
def matches?(target)
|
7
7
|
@target = target
|
8
|
-
|
8
|
+
[301, 302].include? target
|
9
9
|
end
|
10
10
|
def failure_message
|
11
11
|
"expected to redirect"
|
@@ -75,7 +75,7 @@ module Merb
|
|
75
75
|
(400..499).include?(@target.status)
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
78
|
+
def failure_message
|
79
79
|
"expected #{@target} to be missing but was #{@target.status}"
|
80
80
|
end
|
81
81
|
|
data/lib/merb/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Merb
|
2
|
-
VERSION = '0.5.
|
2
|
+
VERSION = '0.5.2' unless defined?(::Merb::VERSION)
|
3
3
|
|
4
4
|
class << self
|
5
5
|
def svn_revision
|
@@ -41,6 +41,6 @@ module Merb
|
|
41
41
|
# You should never check in to trunk with this changed. It should
|
42
42
|
# stay 'svn'. Change it to nil in release tags.
|
43
43
|
unless defined?(::Merb::RELEASE)
|
44
|
-
RELEASE = "svn#{" r#{svn_revision_from_file}" if svn_revision_from_file}"
|
44
|
+
RELEASE = nil #"svn#{" r#{svn_revision_from_file}" if svn_revision_from_file}"
|
45
45
|
end
|
46
46
|
end
|
data/lib/tasks/merb.rake
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
def install_merb_script
|
2
2
|
script_filepath = Merb.root / 'script/merb'
|
3
3
|
FileUtils.rm script_filepath if File.exist? script_filepath
|
4
|
-
tmpl = "#!/usr/bin/env ruby\nrequire File.expand_path(File.dirname(__FILE__)+'/../framework/merb/server')\nMerb::Server.run\n"
|
4
|
+
tmpl = "#!/usr/bin/env ruby\nrequire File.expand_path(File.dirname(__FILE__)+'/../config/merb/boot')\nrequire File.expand_path(File.dirname(__FILE__)+'/../framework/merb/server')\nMerb::Server.run\n"
|
5
5
|
File.open(script_filepath, 'wb') {|f|
|
6
6
|
f.write tmpl
|
7
7
|
f.chmod(0744)
|
@@ -94,6 +94,9 @@ describe "Controller", "redirect spec helpers" do
|
|
94
94
|
end
|
95
95
|
def show
|
96
96
|
end
|
97
|
+
def permanent
|
98
|
+
redirect("/foo",:permanent)
|
99
|
+
end
|
97
100
|
end
|
98
101
|
|
99
102
|
before(:each) do
|
@@ -113,4 +116,11 @@ describe "Controller", "redirect spec helpers" do
|
|
113
116
|
@controller.should_not redirect
|
114
117
|
@controller.should_not redirect_to("/foo")
|
115
118
|
end
|
119
|
+
|
120
|
+
it "should be able to match permanent redirects" do
|
121
|
+
@controller.dispatch('permanent')
|
122
|
+
@controller.status.should be_redirect
|
123
|
+
@controller.should redirect
|
124
|
+
@controller.should redirect_to("/foo")
|
125
|
+
end
|
116
126
|
end
|
data/spec/merb/dispatch_spec.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
$TESTING = true
|
2
|
+
require_fixtures '/controllers/dispatch_spec_controllers'
|
5
3
|
|
6
4
|
describe Merb::Dispatcher do
|
7
|
-
|
8
|
-
before(:all) do
|
5
|
+
before :all do
|
9
6
|
Merb::Config[:allow_reloading] = false
|
10
7
|
Merb::Router.prepare do |r|
|
11
8
|
r.resource :icon
|
@@ -288,6 +285,7 @@ describe Merb::Dispatcher do
|
|
288
285
|
controller.params[:id].should == '1'
|
289
286
|
controller.body.should == :edit
|
290
287
|
end
|
288
|
+
|
291
289
|
it "should handle request: GET /posts/1/edit and return Posts#edit" do
|
292
290
|
controller, action = request(:get, '/posts/1/edit')
|
293
291
|
controller.class.should == Posts
|
@@ -336,7 +334,6 @@ describe Merb::Dispatcher do
|
|
336
334
|
controller.body.should == :create
|
337
335
|
end
|
338
336
|
|
339
|
-
|
340
337
|
it "should handle request: POST /posts.xml and return Posts#create format xml" do
|
341
338
|
controller, action = request(:post, '/posts.xml')
|
342
339
|
controller.class.should == Posts
|
@@ -526,6 +523,6 @@ describe Merb::Dispatcher do
|
|
526
523
|
it "should support actionargs with nil as defaults" do
|
527
524
|
controller, action = request(:get, '/bar/bam?a=1')
|
528
525
|
controller.body.should == "1 nil"
|
529
|
-
end
|
526
|
+
end
|
530
527
|
end
|
531
528
|
end
|
data/spec/merb/multipart_spec.rb
CHANGED
@@ -46,4 +46,5 @@ describe Merb::Test::Multipart::Post, '.to_multipart' do
|
|
46
46
|
content_type.should == "multipart/form-data, boundary=----------0xKhTmLbOuNdArY"
|
47
47
|
query.should == "------------0xKhTmLbOuNdArY\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.txt\"\r\nContent-Type: text/plain\r\n\r\nfile contents\r\n------------0xKhTmLbOuNdArY\r\nContent-Disposition: form-data; name=\"normal\"\r\n\r\nnormal_param\r\n------------0xKhTmLbOuNdArY--"
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
50
|
+
|
data/spec/merb/request_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require_fixtures '/controllers/render_spec_controllers'
|
2
3
|
|
3
4
|
describe "View Context", "image tag" do
|
4
5
|
|
@@ -309,26 +310,57 @@ describe "View Context", "throw_content, catch_content" do
|
|
309
310
|
end
|
310
311
|
|
311
312
|
describe Merb::ViewContextMixin do
|
312
|
-
|
313
|
+
# The use of this here is to avoid conflict with the tag()
|
314
|
+
# Hpricot test helper invoked via match_tag() when testing the
|
315
|
+
# tag() view context helper.
|
316
|
+
class FakeViewContext
|
317
|
+
include Merb::ErubisCaptureMixin, Merb::ViewContextMixin
|
318
|
+
end
|
319
|
+
|
320
|
+
before :each do
|
321
|
+
@view = FakeViewContext.new
|
322
|
+
end
|
323
|
+
|
313
324
|
it "should render the start of a tag" do
|
314
|
-
open_tag(:div).should
|
325
|
+
@view.open_tag(:div).should match_tag(:div)
|
315
326
|
end
|
316
|
-
|
327
|
+
|
317
328
|
it "should render the start of a tag with attributes" do
|
318
|
-
|
319
|
-
|
329
|
+
@view.open_tag(:div, :id => 1, :class => "CLASS").
|
330
|
+
should match_tag(:div, :id => "1", :class => "CLASS")
|
320
331
|
end
|
321
|
-
|
332
|
+
|
322
333
|
it "should render a self closing tag" do
|
323
|
-
self_closing_tag(:br).should
|
334
|
+
@view.self_closing_tag(:br).should match_tag(:br)
|
324
335
|
end
|
325
|
-
|
336
|
+
|
326
337
|
it "should render a self closing tag with attributes" do
|
327
|
-
self_closing_tag(:img, :src => "SOURCE").
|
338
|
+
@view.self_closing_tag(:img, :src => "SOURCE").
|
339
|
+
should match_tag(:img, :src => "SOURCE")
|
328
340
|
end
|
329
|
-
|
341
|
+
|
330
342
|
it "should render a closing tag" do
|
331
|
-
close_tag(:div).should == "</div>"
|
343
|
+
@view.close_tag(:div).should == "</div>"
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'should render a tag with content' do
|
347
|
+
@view.tag(:div, 'divs rool').should match_tag(:div, :content => 'divs rool')
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'should render a tag with content and attributes' do
|
351
|
+
@view.tag(:div, 'divs rool', :class => 'classy').
|
352
|
+
should match_tag(:div, :content => 'divs rool', :class => 'classy')
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'should render a tag using a block for its contents' do
|
356
|
+
@view.tag(:div) do
|
357
|
+
'divs rool'
|
358
|
+
end.should match_tag(:div, :content => 'divs rool')
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'should render a tag with attributes using a block for its contents' do
|
362
|
+
@view.tag(:div, :class => 'classy') do
|
363
|
+
'divs rool'
|
364
|
+
end.should match_tag(:div, :content => 'divs rool', :class => 'classy')
|
332
365
|
end
|
333
|
-
|
334
366
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,9 @@ require 'merb'
|
|
14
14
|
require 'merb/test/helper'
|
15
15
|
|
16
16
|
FIXTURES = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) unless defined?(FIXTURES)
|
17
|
+
def require_fixtures(path)
|
18
|
+
require File.expand_path(File.join(FIXTURES, path))
|
19
|
+
end
|
17
20
|
|
18
21
|
require File.join(File.dirname(__FILE__), "spec_helpers", "url_shared_behaviour")
|
19
22
|
|
metadata
CHANGED
@@ -1,33 +1,90 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: merb
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2008-01-10 00:00:00 -08:00
|
8
|
-
summary: Merb == Mongrel + Erb. Pocket rocket web framework.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: ez@engineyard.com
|
12
|
-
homepage: http://merb.devjavu.com
|
13
|
-
rubyforge_project:
|
14
|
-
description: Merb == Mongrel + Erb. Pocket rocket web framework.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.8.4
|
24
|
-
version:
|
4
|
+
version: 0.5.2
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Ezra Zygmuntowicz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-14 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mongrel
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: erubis
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: mime-types
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rubigen
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rake
|
53
|
+
version_requirement:
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: ruby2ruby
|
62
|
+
version_requirement:
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json_pure
|
71
|
+
version_requirement:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
description: Merb == Mongrel + Erb. Pocket rocket web framework.
|
79
|
+
email: ez@engineyard.com
|
80
|
+
executables:
|
81
|
+
- merb
|
82
|
+
extensions: []
|
83
|
+
|
84
|
+
extra_rdoc_files:
|
85
|
+
- README
|
86
|
+
- LICENSE
|
87
|
+
- TODO
|
31
88
|
files:
|
32
89
|
- LICENSE
|
33
90
|
- README
|
@@ -401,81 +458,31 @@ files:
|
|
401
458
|
- test_unit_generators/merb_model_test/templates/model_test_unit_template.erb
|
402
459
|
- script/destroy
|
403
460
|
- script/generate
|
404
|
-
|
405
|
-
|
461
|
+
has_rdoc: true
|
462
|
+
homepage: http://merb.devjavu.com
|
463
|
+
post_install_message:
|
406
464
|
rdoc_options: []
|
407
465
|
|
408
|
-
|
409
|
-
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
-
|
414
|
-
|
415
|
-
|
466
|
+
require_paths:
|
467
|
+
- lib
|
468
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
469
|
+
requirements:
|
470
|
+
- - ">="
|
471
|
+
- !ruby/object:Gem::Version
|
472
|
+
version: 1.8.4
|
473
|
+
version:
|
474
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
475
|
+
requirements:
|
476
|
+
- - ">="
|
477
|
+
- !ruby/object:Gem::Version
|
478
|
+
version: "0"
|
479
|
+
version:
|
416
480
|
requirements:
|
417
481
|
- install the json gem to get faster json parsing
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
- !ruby/object:Gem::Version
|
426
|
-
version: 0.0.0
|
427
|
-
version:
|
428
|
-
- !ruby/object:Gem::Dependency
|
429
|
-
name: erubis
|
430
|
-
version_requirement:
|
431
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
432
|
-
requirements:
|
433
|
-
- - ">"
|
434
|
-
- !ruby/object:Gem::Version
|
435
|
-
version: 0.0.0
|
436
|
-
version:
|
437
|
-
- !ruby/object:Gem::Dependency
|
438
|
-
name: mime-types
|
439
|
-
version_requirement:
|
440
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
441
|
-
requirements:
|
442
|
-
- - ">"
|
443
|
-
- !ruby/object:Gem::Version
|
444
|
-
version: 0.0.0
|
445
|
-
version:
|
446
|
-
- !ruby/object:Gem::Dependency
|
447
|
-
name: rubigen
|
448
|
-
version_requirement:
|
449
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
450
|
-
requirements:
|
451
|
-
- - ">"
|
452
|
-
- !ruby/object:Gem::Version
|
453
|
-
version: 0.0.0
|
454
|
-
version:
|
455
|
-
- !ruby/object:Gem::Dependency
|
456
|
-
name: rake
|
457
|
-
version_requirement:
|
458
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
459
|
-
requirements:
|
460
|
-
- - ">"
|
461
|
-
- !ruby/object:Gem::Version
|
462
|
-
version: 0.0.0
|
463
|
-
version:
|
464
|
-
- !ruby/object:Gem::Dependency
|
465
|
-
name: ruby2ruby
|
466
|
-
version_requirement:
|
467
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
468
|
-
requirements:
|
469
|
-
- - ">"
|
470
|
-
- !ruby/object:Gem::Version
|
471
|
-
version: 0.0.0
|
472
|
-
version:
|
473
|
-
- !ruby/object:Gem::Dependency
|
474
|
-
name: json_pure
|
475
|
-
version_requirement:
|
476
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
477
|
-
requirements:
|
478
|
-
- - ">"
|
479
|
-
- !ruby/object:Gem::Version
|
480
|
-
version: 0.0.0
|
481
|
-
version:
|
482
|
+
rubyforge_project:
|
483
|
+
rubygems_version: 0.9.5
|
484
|
+
signing_key:
|
485
|
+
specification_version: 2
|
486
|
+
summary: Merb == Mongrel + Erb. Pocket rocket web framework.
|
487
|
+
test_files: []
|
488
|
+
|