Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

made generated spec task to run again: added db:test:prepare task and…

… fixed broken spec
  • Loading branch information...
commit 4957a55e123ba13495949e10cc31238f6b9a2edf 1 parent 3a024e6
@mkristian authored
View
1  Manifest.txt
@@ -13,6 +13,7 @@ generators/datamapper_rspec_model/datamapper_rspec_model_generator.rb
generators/datamapper_rspec_model/templates/model_spec.rb
generators/datamapper_rspec_scaffold/datamapper_rspec_scaffold_generator.rb
generators/datamapper_rspec_scaffold/templates/controller_spec.rb
+generators/datamapper_rspec_scaffold/templates/edit_erb_spec.rb
generators/datamapper_scaffold/datamapper_scaffold_generator.rb
generators/datamapper_scaffold/templates/controller.rb
generators/datamapper_scaffold/templates/functional_test.rb
View
6 generators/datamapper_install/templates/datamapper.rake
@@ -44,6 +44,12 @@ namespace :db do
::DataMapper.auto_upgrade!
end
+ # this is needed for rspec and test tasks
+ namespace :test do
+ RAILS_ENV = 'test'
+ task :prepare => :automigrate
+ end
+
namespace :migrate do
task :load => :environment do
require 'dm-migrations/migration_runner'
View
25 generators/datamapper_rspec_scaffold/templates/edit_erb_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+
+<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
+describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
+ include <%= controller_class_name %>Helper
+
+ before(:each) do
+ assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %>,
+ :new_record? => false<%= output_attributes.empty? ? '' : ',' %>
+<% output_attributes.each_with_index do |attribute, attribute_index| -%>
+ :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
+<% end -%>
+ )
+ end
+
+ it "renders the edit <%= file_name %> form" do
+ render
+
+ response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>.key)}][method=post]") do
+<% for attribute in output_attributes -%>
+ with_tag('<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]")
+<% end -%>
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.