merb 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/README +21 -14
  2. data/Rakefile +157 -108
  3. data/SVN_REVISION +1 -0
  4. data/app_generators/merb/templates/Rakefile +20 -4
  5. data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +1 -1
  6. data/app_generators/merb/templates/config/boot.rb +1 -1
  7. data/app_generators/merb/templates/config/dependencies.rb +3 -3
  8. data/app_generators/merb/templates/config/merb.yml +5 -0
  9. data/app_generators/merb/templates/config/merb_init.rb +3 -3
  10. data/app_generators/merb/templates/script/destroy +3 -0
  11. data/app_generators/merb/templates/script/generate +1 -1
  12. data/app_generators/merb/templates/spec/spec_helper.rb +2 -2
  13. data/app_generators/merb/templates/test/test_helper.rb +1 -1
  14. data/app_generators/merb_plugin/merb_plugin_generator.rb +4 -0
  15. data/bin/merb +1 -3
  16. data/lib/merb.rb +144 -76
  17. data/lib/merb/abstract_controller.rb +6 -5
  18. data/lib/merb/assets.rb +119 -0
  19. data/lib/merb/boot_loader.rb +217 -0
  20. data/lib/merb/caching.rb +1 -1
  21. data/lib/merb/caching/action_cache.rb +1 -1
  22. data/lib/merb/caching/fragment_cache.rb +1 -1
  23. data/lib/merb/caching/store/file_cache.rb +1 -1
  24. data/lib/merb/config.rb +290 -0
  25. data/lib/merb/controller.rb +5 -5
  26. data/lib/merb/core_ext/get_args.rb +1 -0
  27. data/lib/merb/core_ext/hash.rb +182 -169
  28. data/lib/merb/core_ext/kernel.rb +57 -26
  29. data/lib/merb/dispatcher.rb +6 -6
  30. data/lib/merb/drb_server.rb +1 -1
  31. data/lib/merb/generators/merb_generator_helpers.rb +7 -6
  32. data/lib/merb/logger.rb +1 -1
  33. data/lib/merb/mail_controller.rb +3 -4
  34. data/lib/merb/mailer.rb +2 -2
  35. data/lib/merb/mixins/basic_authentication.rb +2 -2
  36. data/lib/merb/mixins/controller.rb +1 -1
  37. data/lib/merb/mixins/general_controller.rb +13 -20
  38. data/lib/merb/mixins/inline_partial.rb +32 -0
  39. data/lib/merb/mixins/render.rb +3 -3
  40. data/lib/merb/mixins/responder.rb +1 -1
  41. data/lib/merb/mixins/view_context.rb +159 -33
  42. data/lib/merb/mongrel_handler.rb +9 -9
  43. data/lib/merb/plugins.rb +1 -1
  44. data/lib/merb/request.rb +25 -1
  45. data/lib/merb/router.rb +264 -226
  46. data/lib/merb/server.rb +66 -560
  47. data/lib/merb/session/cookie_store.rb +14 -13
  48. data/lib/merb/session/mem_cache_session.rb +20 -10
  49. data/lib/merb/session/memory_session.rb +21 -11
  50. data/lib/merb/template.rb +2 -2
  51. data/lib/merb/template/erubis.rb +3 -33
  52. data/lib/merb/template/haml.rb +8 -3
  53. data/lib/merb/test/fake_request.rb +8 -3
  54. data/lib/merb/test/helper.rb +66 -22
  55. data/lib/merb/test/rspec.rb +9 -155
  56. data/lib/merb/test/rspec_matchers/controller_matchers.rb +117 -0
  57. data/lib/merb/test/rspec_matchers/markup_matchers.rb +98 -0
  58. data/lib/merb/upload_handler.rb +2 -1
  59. data/lib/merb/version.rb +38 -3
  60. data/lib/merb/view_context.rb +1 -2
  61. data/lib/tasks/merb.rake +11 -11
  62. data/merb_generators/part_controller/USAGE +5 -0
  63. data/merb_generators/part_controller/part_controller_generator.rb +27 -0
  64. data/merb_generators/part_controller/templates/controller.rb +8 -0
  65. data/merb_generators/part_controller/templates/helper.rb +5 -0
  66. data/merb_generators/part_controller/templates/index.html.erb +3 -0
  67. data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +1 -1
  68. data/script/destroy +14 -0
  69. data/script/generate +14 -0
  70. data/spec/fixtures/controllers/dispatch_spec_controllers.rb +9 -1
  71. data/spec/fixtures/controllers/render_spec_controllers.rb +5 -5
  72. data/spec/fixtures/models/router_spec_models.rb +10 -0
  73. data/spec/merb/abstract_controller_spec.rb +2 -2
  74. data/spec/merb/assets_spec.rb +207 -0
  75. data/spec/merb/caching_spec.rb +2 -2
  76. data/spec/merb/controller_spec.rb +7 -2
  77. data/spec/merb/cookie_store_spec.rb +1 -1
  78. data/spec/merb/core_ext/class_spec.rb +97 -0
  79. data/spec/merb/core_ext/enumerable_spec.rb +27 -0
  80. data/spec/merb/core_ext/hash_spec.rb +251 -0
  81. data/spec/merb/core_ext/inflector_spec.rb +34 -0
  82. data/spec/merb/core_ext/kernel_spec.rb +25 -0
  83. data/spec/merb/core_ext/numeric_spec.rb +26 -0
  84. data/spec/merb/core_ext/object_spec.rb +47 -0
  85. data/spec/merb/core_ext/string_spec.rb +22 -0
  86. data/spec/merb/core_ext/symbol_spec.rb +7 -0
  87. data/spec/merb/dependency_spec.rb +22 -0
  88. data/spec/merb/dispatch_spec.rb +23 -12
  89. data/spec/merb/fake_request_spec.rb +8 -0
  90. data/spec/merb/generator_spec.rb +140 -21
  91. data/spec/merb/handler_spec.rb +5 -5
  92. data/spec/merb/mail_controller_spec.rb +3 -3
  93. data/spec/merb/render_spec.rb +1 -1
  94. data/spec/merb/responder_spec.rb +3 -3
  95. data/spec/merb/router_spec.rb +260 -191
  96. data/spec/merb/server_spec.rb +5 -5
  97. data/spec/merb/upload_handler_spec.rb +7 -0
  98. data/spec/merb/version_spec.rb +33 -0
  99. data/spec/merb/view_context_spec.rb +217 -59
  100. data/spec/spec_generator_helper.rb +15 -0
  101. data/spec/spec_helper.rb +5 -3
  102. data/spec/spec_helpers/url_shared_behaviour.rb +5 -7
  103. metadata +32 -7
  104. data/lib/merb/caching/store/memcache.rb +0 -20
  105. data/lib/merb/mixins/form_control.rb +0 -332
  106. data/lib/patch +0 -69
  107. data/spec/merb/core_ext_spec.rb +0 -464
  108. data/spec/merb/form_control_mixin_spec.rb +0 -431
@@ -1,19 +1,19 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- describe Merb::Server do
3
+ describe Merb::Config do
4
4
  it "should apply environment from the command line option --environment" do
5
- options = Merb::Server.merb_config(["--environment", "performance_testing"])
5
+ options = Merb::Config.parse_args(["--environment", "performance_testing"])
6
6
  options[:environment].should == "performance_testing"
7
7
  end
8
8
 
9
9
  it "should apply environment from the command line option -e" do
10
- options = Merb::Server.merb_config(["-e", "selenium"])
10
+ options = Merb::Config.parse_args(["-e", "selenium"])
11
11
  options[:environment].should == "selenium"
12
12
  end
13
13
 
14
14
  it "should load the yaml file for the environment if it exists" do
15
- options = Merb::Server.merb_config(["-e", "environment_config_test"])
15
+ options = Merb::Config.parse_args(["-e", "environment_config_test"])
16
16
  options[:loaded_config_for_environment_config_test].should == true
17
17
  end
18
-
18
+
19
19
  end
@@ -64,6 +64,13 @@ describe MerbUploadHandler do
64
64
  @handler.request_aborted(@params)
65
65
  end
66
66
 
67
+ it 'should log info about aborted requests' do
68
+ @handler.stub!(:valid_upload?).and_return(@upload_id)
69
+ Mongrel::Uploads.should_receive(:finish).with(@upload_id)
70
+ Merb.logger.should_receive :info
71
+ @handler.request_aborted(@params)
72
+ end
73
+
67
74
  it "should not send Mongrel::Uploads :finish unless the request is a valid upload" do
68
75
  Mongrel::Uploads.should_not_receive(:finish)
69
76
  @handler.stub!(:valid_upload?).and_return(false)
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe 'Merb version.rb svn revision methods' do
4
+ it 'should give a path to a file containing the svn revision' do
5
+ Merb.svn_revision_file_path.should ==
6
+ File.expand_path(File.join(Dir.pwd, Merb.svn_revision_filename))
7
+ end
8
+
9
+ it "should create the #{Merb.svn_revision_filename} file if it does not exist" do
10
+ File.delete Merb.svn_revision_file_path
11
+ Merb.svn_revision_from_file
12
+ File.file?(Merb.svn_revision_file_path).should == true
13
+ end
14
+
15
+ it 'should not raise permissions error' do
16
+ File.should_receive(:open).and_raise(Errno::EACCES)
17
+ Merb.svn_revision_from_file.should_not raise_error(Errno::EACCES)
18
+ end
19
+
20
+ it 'should get the svn revision' do
21
+ Merb.svn_revision.should > 0
22
+ end
23
+
24
+ it "should get the svn revision from the #{Merb.svn_revision_filename} file" do
25
+ Merb.svn_revision_from_file.should > 0
26
+ end
27
+
28
+ it 'should get the same number from the helper and the file' do
29
+ Merb.svn_revision.should == Merb.svn_revision_from_file
30
+ end
31
+
32
+ it 'should get the svn revision via git'
33
+ end
@@ -1,103 +1,201 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "View Context", "image tag" do
4
-
4
+
5
5
  include Merb::ViewContextMixin
6
- it "should render an link" do
7
- the_link = link_to( "NAME", "http://example.com", :title => "TITLE", :target => "TARGET" )
8
- the_link.should match( /<a.+>NAME<\/a>/ )
9
- the_link.should match( /href="http:\/\/example.com"/)
10
- the_link.should match( /title="TITLE"/)
11
- the_link.should match( /target="TARGET"/ )
6
+ it "should render a link" do
7
+ tag = link_to("NAME", "http://example.com", :title => "TITLE", :target => "TARGET")
8
+ tag.should match_tag(:a, :href => "http://example.com",
9
+ :title => "TITLE",
10
+ :target => "TARGET",
11
+ :content => "NAME")
12
12
  end
13
13
 
14
14
  it "should render local image" do
15
- image_tag('foo.gif').clean.should == %[<img src="/images/foo.gif"/>].clean
15
+ tag = image_tag('foo.gif')
16
+ tag.should match_tag(:img, :src => "/images/foo.gif")
16
17
  end
17
18
 
18
19
  it "should render a local image with a path_prefix" do
19
- Merb::Server.config[:path_prefix] = '/inky'
20
- image_tag('foo.gif').clean.should == %[<img src="/inky/images/foo.gif"/>].clean
21
- Merb::Server.config.delete(:path_prefix)
20
+ Merb::Config[:path_prefix] = '/inky'
21
+
22
+ tag = image_tag('foo.gif')
23
+ tag.should match_tag(:img, :src => "/inky/images/foo.gif")
24
+
25
+ Merb::Config.delete(:path_prefix)
22
26
  end
23
-
27
+
24
28
  it "should render local image with class" do
25
- image_tag('foo.gif', :class => 'bar').clean.should == %[<img src="/images/foo.gif" class="bar" />].clean
29
+ tag = image_tag('foo.gif', :class => 'bar')
30
+ tag.should match_tag(:img, :src => "/images/foo.gif", :class => "bar")
26
31
  end
27
32
 
28
33
  it "should render local image with class and explicit path" do
29
- image_tag('foo.gif', :class => 'bar', :path => '/files/').clean.should == %[<img src="/files/foo.gif" class="bar" />].clean
34
+ tag = image_tag('foo.gif', :class => 'bar', :path => '/files/')
35
+ tag.should match_tag(:img, :src => "/files/foo.gif", :class => "bar")
30
36
  end
31
37
 
32
38
  it "should render remote image" do
33
- image_tag('http://test.com/foo.gif').clean.should == %[<img src="http://test.com/foo.gif"/>].clean
39
+ tag = image_tag('http://test.com/foo.gif')
40
+ tag.should match_tag(:img, :src => "http://test.com/foo.gif")
34
41
  end
35
42
 
36
43
  it "should render remote SSL image" do
37
- image_tag('https://test.com/foo.gif').clean.should == %[<img src="https://test.com/foo.gif"/>].clean
44
+ tag = image_tag('https://test.com/foo.gif')
45
+ tag.should match_tag(:img, :src => "https://test.com/foo.gif")
38
46
  end
39
47
 
40
48
  end
41
49
 
42
50
  describe "View Context", "css tag" do
43
-
51
+
44
52
  include Merb::ViewContextMixin
45
-
53
+
46
54
  it "should render a link tag with the css_include_tag method" do
47
- css_include_tag('foo.css').clean.should ==
48
- %[<link href="/stylesheets/foo.css" media="all" rel="Stylesheet" type="text/css"/>].clean
55
+ tag = css_include_tag('foo.css')
56
+ tag.should match_tag(:link, :href => "/stylesheets/foo.css",
57
+ :media => "all",
58
+ :rel => "Stylesheet",
59
+ :type => "text/css",
60
+ :content => nil)
49
61
 
50
62
  css_include_tag('foo').should == css_include_tag('foo.css')
51
-
52
63
  css_include_tag('foo', 'bar').should ==
53
- css_include_tag('foo') +
54
- css_include_tag('bar')
64
+ css_include_tag('foo') + css_include_tag('bar')
55
65
  end
56
66
 
67
+ it "should alter the 'media' attribute based on the provided options" do
68
+ tag = css_include_tag('foo.css', :media => :screen)
69
+ tag.should match_tag(:link, :href => "/stylesheets/foo.css",
70
+ :media => "screen",
71
+ :rel => "Stylesheet",
72
+ :type => "text/css",
73
+ :content => nil)
74
+ end
75
+
57
76
  it "should render a link tag with a path_prefix" do
58
- Merb::Server.config[:path_prefix] = '/inky'
59
- css_include_tag('foo.css').clean.should ==
60
- %[<link href="/inky/stylesheets/foo.css" media="all" rel="Stylesheet" type="text/css"/>].clean
61
- Merb::Server.config.delete(:path_prefix)
77
+ Merb::Config[:path_prefix] = '/inky'
78
+
79
+ tag = css_include_tag('foo.css')
80
+ tag.should match_tag(:link, :href => "/inky/stylesheets/foo.css",
81
+ :media => "all",
82
+ :rel => "Stylesheet",
83
+ :type => "text/css",
84
+ :content => nil)
85
+
86
+ Merb::Config.delete(:path_prefix)
62
87
  end
63
-
88
+
64
89
  it "should not generate a script tag with the include_required_css" do
65
90
  include_required_css.clean.should == ''
66
91
  end
67
-
92
+
68
93
  it "should generate script tags with the include_required_css" do
69
94
  require_css('foo')
70
95
  require_css('bar')
71
- include_required_css.should ==
72
- css_include_tag('foo') + css_include_tag('bar')
96
+ include_required_css.should == css_include_tag('foo') + css_include_tag('bar')
73
97
  end
74
98
  end
75
99
 
76
- describe "View Context", "script tag" do
77
-
100
+ describe "View Context", "css tag with bundles" do
101
+
78
102
  include Merb::ViewContextMixin
79
103
 
104
+ before(:each) do
105
+ @bundler = mock(:bundler)
106
+ Merb::Assets.stub!(:bundle?).and_return(true)
107
+ Merb::Assets::StylesheetAssetBundler.stub!(:new).and_return(@bundler)
108
+ @bundler.stub!(:bundle!).and_return(:all)
109
+ end
110
+
111
+ it "should not bundle stylesheets if asset bundling is disabled" do
112
+ Merb::Assets.should_receive(:bundle?).and_return(false)
113
+
114
+ tag = css_include_tag(:fonts, :colors, :bundle => true)
115
+ tag.should == css_include_tag(:fonts) + css_include_tag(:colors)
116
+ end
117
+
118
+ it "should not bundle stylesheets if only a single stylesheet was provided" do
119
+ css_include_tag(:fonts, :bundle => true).should == css_include_tag(:fonts)
120
+ end
121
+
122
+ it "should bundle all stylesheets as 'all.css' if no bundle name is provided" do
123
+ Merb::Assets.should_receive(:bundle?).and_return(true)
124
+ Merb::Assets::StylesheetAssetBundler.should_receive(:new).with(true, :fonts, :colors).and_return(@bundler)
125
+ @bundler.should_receive(:bundle!).and_return(:all)
126
+
127
+ tag = css_include_tag(:fonts, :colors, :bundle => true)
128
+ tag.should match_tag(:link, :href => "/stylesheets/all.css",
129
+ :media => "all",
130
+ :rel => "Stylesheet",
131
+ :type => "text/css",
132
+ :content => nil)
133
+ end
134
+
135
+ it "should bundle all stylesheets whatever bundle name is provided" do
136
+ Merb::Assets.should_receive(:bundle?).and_return(true)
137
+ Merb::Assets::StylesheetAssetBundler.should_receive(:new).with(:base, :fonts, :colors).and_return(@bundler)
138
+ @bundler.should_receive(:bundle!).and_return(:base)
139
+
140
+ tag = css_include_tag(:fonts, :colors, :bundle => :base)
141
+ tag.should match_tag(:link, :href => "/stylesheets/base.css",
142
+ :media => "all",
143
+ :rel => "Stylesheet",
144
+ :type => "text/css",
145
+ :content => nil)
146
+ end
147
+
148
+ it "should not generate a stylesheet tag with the include_required_css" do
149
+ include_required_css(:bundle => true).clean.should == ''
150
+ end
151
+
152
+ it "should generate stylesheet tags with the include_required_css" do
153
+ Merb::Assets.should_receive(:bundle?).and_return(true)
154
+ Merb::Assets::StylesheetAssetBundler.should_receive(:new).with(true, :fonts, :colors).and_return(@bundler)
155
+ @bundler.should_receive(:bundle!).and_return(:all)
156
+
157
+ require_css(:fonts)
158
+ require_css(:colors)
159
+ tag = include_required_css(:bundle => true)
160
+
161
+ tag.should match_tag(:link, :href => "/stylesheets/all.css",
162
+ :media => "all",
163
+ :rel => "Stylesheet",
164
+ :type => "text/css",
165
+ :content => nil)
166
+ end
167
+ end
168
+
169
+ describe "View Context", "script tag" do
170
+
171
+ include Merb::ViewContextMixin
172
+
80
173
  it "should render a script tag with the js_include_tag method" do
81
- js_include_tag('foo.js').clean.should == %[<script src="/javascripts/foo.js" type="text/javascript">//</script>].clean
174
+ tag = js_include_tag('foo.js')
175
+ tag.should match_tag(:script, :src => "/javascripts/foo.js",
176
+ :type => "text/javascript",
177
+ :content => "//")
82
178
 
83
179
  js_include_tag('foo').should == js_include_tag('foo.js')
84
-
85
180
  js_include_tag('foo', 'bar').should ==
86
- js_include_tag('foo') +
87
- js_include_tag('bar')
181
+ js_include_tag('foo') + js_include_tag('bar')
88
182
  end
89
-
183
+
90
184
  it "should render a script tag with a path_prefix" do
91
- Merb::Server.config[:path_prefix] = '/inky'
92
- js_include_tag('foo.js').clean.should ==
93
- %[<script src="/inky/javascripts/foo.js" type="text/javascript">//</script>].clean
94
- Merb::Server.config.delete(:path_prefix)
185
+ Merb::Config[:path_prefix] = '/inky'
186
+
187
+ tag = js_include_tag('foo.js')
188
+ tag.should match_tag(:script, :src => "/inky/javascripts/foo.js",
189
+ :type => "text/javascript",
190
+ :content => "//")
191
+
192
+ Merb::Config.delete(:path_prefix)
95
193
  end
96
-
194
+
97
195
  it "should not generate a script tag with the include_required_js" do
98
196
  include_required_js.clean.should == ''
99
197
  end
100
-
198
+
101
199
  it "should generate script tags with the include_required_js" do
102
200
  require_js('foo')
103
201
  require_js('bar')
@@ -105,10 +203,73 @@ describe "View Context", "script tag" do
105
203
  end
106
204
  end
107
205
 
108
- describe "View Context", "throw_content, catch_content" do
109
-
206
+ describe "View Context", "script tag with bundles" do
207
+
110
208
  include Merb::ViewContextMixin
111
209
 
210
+ before(:each) do
211
+ @bundler = mock(:bundler)
212
+ Merb::Assets.stub!(:bundle?).and_return(true)
213
+ Merb::Assets::JavascriptAssetBundler.stub!(:new).and_return(@bundler)
214
+ @bundler.stub!(:bundle!).and_return(:all)
215
+ end
216
+
217
+ it "should not bundle scripts if asset bundling is disabled" do
218
+ Merb::Assets.should_receive(:bundle?).and_return(false)
219
+
220
+ tag = js_include_tag(:prototype, :lowpro, :bundle => true)
221
+ tag.should == js_include_tag(:prototype) + js_include_tag(:lowpro)
222
+ end
223
+
224
+ it "should not bundle scripts if only a single script was provided" do
225
+ css_include_tag(:prototype, :bundle => true).should == css_include_tag(:prototype)
226
+ end
227
+
228
+ it "should bundle all scripts as 'all.js' if no bundle name is provided" do
229
+ Merb::Assets.should_receive(:bundle?).and_return(true)
230
+ Merb::Assets::JavascriptAssetBundler.should_receive(:new).with(true, :prototype, :lowpro).and_return(@bundler)
231
+ @bundler.should_receive(:bundle!).and_return(:all)
232
+
233
+ tag = js_include_tag(:prototype, :lowpro, :bundle => true)
234
+ tag.should match_tag(:script, :src => "/javascripts/all.js",
235
+ :type => "text/javascript",
236
+ :content => "//")
237
+ end
238
+
239
+ it "should bundle all stylesheets whatever bundle name is provided" do
240
+ Merb::Assets.should_receive(:bundle?).and_return(true)
241
+ Merb::Assets::JavascriptAssetBundler.should_receive(:new).with(:base, :prototype, :lowpro).and_return(@bundler)
242
+ @bundler.should_receive(:bundle!).and_return(:base)
243
+
244
+ tag = js_include_tag(:prototype, :lowpro, :bundle => :base)
245
+ tag.should match_tag(:script, :src => "/javascripts/base.js",
246
+ :type => "text/javascript",
247
+ :content => "//")
248
+ end
249
+
250
+ it "should not generate a script tag with the include_required_js" do
251
+ include_required_js(:bundle => true).clean.should == ''
252
+ end
253
+
254
+ it "should generate script tags with the include_required_js" do
255
+ Merb::Assets.should_receive(:bundle?).and_return(true)
256
+ Merb::Assets::JavascriptAssetBundler.should_receive(:new).with(true, :prototype, :lowpro).and_return(@bundler)
257
+ @bundler.should_receive(:bundle!).and_return(:all)
258
+
259
+ require_js(:prototype)
260
+ require_js(:lowpro)
261
+
262
+ tag = include_required_js(:bundle => true)
263
+ tag.should match_tag(:script, :src => "/javascripts/all.js",
264
+ :type => "text/javascript",
265
+ :content => "//")
266
+ end
267
+ end
268
+
269
+ describe "View Context", "throw_content, catch_content" do
270
+
271
+ include Merb::ViewContextMixin
272
+
112
273
  it "should throw content" do
113
274
  c = new_controller
114
275
  content = c.render :template => "examples/template_throw_content", :layout => :none
@@ -126,14 +287,14 @@ describe "View Context", "throw_content, catch_content" do
126
287
  content = c.render :template => "examples/template_catch_content", :layout => :none
127
288
  content.should match( /CAUGHT CONTENT/m)
128
289
  end
129
-
290
+
130
291
  it "should catch content with multiple throws" do
131
292
  c = new_controller
132
293
  content = c.render :template => "examples/template_catch_content", :layout => :none
133
294
  content.should match( /CAUGHT FOOTER/m )
134
295
  content.should match( /START FOOTER\s+CAUGHT FOOTER\s+END FOOTER/m )
135
296
  end
136
-
297
+
137
298
  it "should not render the block inline" do
138
299
  c = new_controller
139
300
  content = c.render :template => "examples/template_catch_content", :layout => :none
@@ -152,25 +313,22 @@ describe Merb::ViewContextMixin do
152
313
  it "should render the start of a tag" do
153
314
  open_tag(:div).should == "<div>"
154
315
  end
155
-
316
+
156
317
  it "should render the start of a tag with attributes" do
157
318
  tag = open_tag(:div, :id => 1, :class => "CLASS")
158
- tag.should match( /^<div /)
159
- tag.should match( /id="1"/)
160
- tag.should match( /class="CLASS"/)
161
- tag.should match( />$/ )
319
+ tag.should match_tag(:div, :id => "1", :class => "CLASS")
162
320
  end
163
-
321
+
164
322
  it "should render a self closing tag" do
165
- self_closing_tag( :br ).should == "<br/>"
323
+ self_closing_tag(:br).should == "<br/>"
166
324
  end
167
-
325
+
168
326
  it "should render a self closing tag with attributes" do
169
- self_closing_tag(:img, :src => "SOURCE" ).should == "<img src=\"SOURCE\"/>"
327
+ self_closing_tag(:img, :src => "SOURCE").should match_tag(:img, :src => "SOURCE")
170
328
  end
171
-
329
+
172
330
  it "should render a closing tag" do
173
331
  close_tag(:div).should == "</div>"
174
332
  end
175
-
333
+
176
334
  end
@@ -17,3 +17,18 @@ rescue LoadError
17
17
  require 'rubigen'
18
18
  end
19
19
  require 'rubigen/helpers/generator_test_helper'
20
+
21
+
22
+ def directory_should_be_created(directory)
23
+ File.should be_exist(File.join(APP_ROOT, directory))
24
+ File.should be_directory(File.join(APP_ROOT, directory))
25
+ end
26
+
27
+ def file_should_be_created(file)
28
+ File.should be_exist(File.join(APP_ROOT, file))
29
+ File.should be_file(File.join(APP_ROOT, file))
30
+ end
31
+
32
+ def file_should_be_executable(file)
33
+ File.should be_executable(File.join(APP_ROOT, file))
34
+ end