Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

… fixed broken spec
  • Loading branch information...
commit 4957a55e123ba13495949e10cc31238f6b9a2edf 1 parent 3a024e6
Christian Meier authored October 01, 2009
1  Manifest.txt
@@ -13,6 +13,7 @@ generators/datamapper_rspec_model/datamapper_rspec_model_generator.rb
13 13
 generators/datamapper_rspec_model/templates/model_spec.rb
14 14
 generators/datamapper_rspec_scaffold/datamapper_rspec_scaffold_generator.rb
15 15
 generators/datamapper_rspec_scaffold/templates/controller_spec.rb
  16
+generators/datamapper_rspec_scaffold/templates/edit_erb_spec.rb
16 17
 generators/datamapper_scaffold/datamapper_scaffold_generator.rb
17 18
 generators/datamapper_scaffold/templates/controller.rb
18 19
 generators/datamapper_scaffold/templates/functional_test.rb
6  generators/datamapper_install/templates/datamapper.rake
@@ -44,6 +44,12 @@ namespace :db do
44 44
     ::DataMapper.auto_upgrade!
45 45
   end
46 46
 
  47
+  # this is needed for rspec and test tasks  
  48
+  namespace :test do
  49
+    RAILS_ENV = 'test'
  50
+    task :prepare => :automigrate
  51
+  end
  52
+
47 53
   namespace :migrate do
48 54
     task :load => :environment do
49 55
       require 'dm-migrations/migration_runner'
25  generators/datamapper_rspec_scaffold/templates/edit_erb_spec.rb
... ...
@@ -0,0 +1,25 @@
  1
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
  2
+
  3
+<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
  4
+describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
  5
+  include <%= controller_class_name %>Helper
  6
+
  7
+  before(:each) do
  8
+    assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %>,
  9
+      :new_record? => false<%= output_attributes.empty? ? '' : ',' %>
  10
+<% output_attributes.each_with_index do |attribute, attribute_index| -%>
  11
+      :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
  12
+<% end -%>
  13
+    )
  14
+  end
  15
+
  16
+  it "renders the edit <%= file_name %> form" do
  17
+    render
  18
+
  19
+    response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>.key)}][method=post]") do
  20
+<% for attribute in output_attributes -%>
  21
+      with_tag('<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]")
  22
+<% end -%>
  23
+    end
  24
+  end
  25
+end

0 notes on commit 4957a55

Please sign in to comment.
Something went wrong with that request. Please try again.