Permalink
Browse files

Working actions into test templates

  • Loading branch information...
1 parent 895396c commit d43f05f89ac549c7c6a054c6831286fb4130971a @quirkey quirkey committed Dec 23, 2008
@@ -1,10 +1,19 @@
require 'test_helper'
describe '<%= klass_name %>' do
+
+ <%- unless actions.empty? -%>
+ <% actions.each do |meth, path| %>
+ it 'should <%= meth %> <%= path %>' do
+ <%= meth %>_it '<%= path %>'
+ @response.should be_ok
+ end
+ <%- end -%>
+ <%- else -%>
it 'should load the index' do
get_it '/'
@response.should be_ok
end
-
+ <%- end -%>
end
@@ -3,6 +3,20 @@ require 'test_helper'
class <%= klass_name -%>Test < Test::Unit::TestCase
context "<%= klass_name -%>" do
+ <%- unless actions.empty? -%>
+ <% actions.each do |meth, path| %>
+ context "<%= meth %> <%= path %>" do
+ setup do
+ <%= meth %>_it '<%= path %>'
+ end
+
+ should "respond" do
+ assert @response.body
+ end
+ end
+
+ <%- end -%>
+ <%- else -%>
context "getting the index" do
setup do
get_it '/'
@@ -12,6 +26,7 @@ class <%= klass_name -%>Test < Test::Unit::TestCase
assert @response.body
end
end
+ <%- end -%>
end
end
@@ -2,9 +2,19 @@ require 'test_helper'
describe '<%= klass_name %>' do
+ <%- unless actions.empty? -%>
+ <% actions.each do |meth, path| %>
+ it 'should <%= meth %> <%= path %>' do
+ <%= meth %>_it '<%= path %>'
+ should.be.ok
+ end
+
+ <%- end -%>
+ <%- else -%>
it 'should load the index' do
get_it '/'
should.be.ok
end
+ <%- end -%>
end
@@ -2,8 +2,17 @@ require 'test_helper'
class <%= klass_name -%>Test < Test::Unit::TestCase
+ <%- unless actions.empty? -%>
+ <% actions.each do |meth, path| %>
+ def test_<%= meth %>_<%= path.gsub([^a-z0-9\_], '') %>_should
+ <%= meth %>_it '<%= path %>'
+ end
+
+ <%- end -%>
+ <%- else -%>
def test_my_default
get_it '/'
end
+ <%- end -%>
end

0 comments on commit d43f05f

Please sign in to comment.