grimen-dry_scaffold 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/config/scaffold.yml CHANGED
@@ -11,7 +11,7 @@ dry_scaffold:
11
11
  views: true
12
12
  helpers: true
13
13
  tests: true
14
- tunit: true
14
+ test_unit: true
15
15
  shoulda: false
16
16
  rspec: false
17
17
  fixtures: true
@@ -23,8 +23,9 @@ dry_model:
23
23
  migration: true
24
24
  timestamps: true
25
25
  tests: true
26
- tunit: true
26
+ test_unit: true
27
27
  shoulda: false
28
+ rspec: false
28
29
  fixtures: true
29
30
  fgirl: false
30
31
  machinist: false
@@ -6,6 +6,6 @@ describe <%= class_name %> do
6
6
 
7
7
  <% end -%>
8
8
  it "should be valid" do
9
- Comment.new.should be_valid
9
+ <%= class_name %>.new.should be_valid
10
10
  end
11
11
  end
@@ -5,7 +5,11 @@ describe <%= controller_class_name %>Controller do
5
5
  fixtures :all
6
6
  <% end -%>
7
7
  integrate_views
8
-
8
+ <% unless options[:factory_framework]==:fixtures %>
9
+ before(:each) do
10
+ <%= build_object %>
11
+ end
12
+ <% end %>
9
13
  <% if actions.include?(:index) -%>
10
14
  it "index action should render index template" do
11
15
  get :index
@@ -15,7 +19,7 @@ describe <%= controller_class_name %>Controller do
15
19
  <% end %>
16
20
  <% if actions.include?(:show) -%>
17
21
  it "show action should render show template" do
18
- get :show, :id => Duck.first
22
+ get :show, :id => <%= class_name %>.first
19
23
  response.should render_template(:show)
20
24
  end
21
25
 
@@ -29,45 +33,45 @@ describe <%= controller_class_name %>Controller do
29
33
  <% end %>
30
34
  <% if actions.include?(:create) -%>
31
35
  it "create action should render new template when model is invalid" do
32
- Duck.any_instance.stubs(:valid?).returns(false)
36
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
33
37
  post :create
34
38
  response.should render_template(:new)
35
39
  end
36
40
 
37
41
  it "create action should redirect when model is valid" do
38
- Duck.any_instance.stubs(:valid?).returns(true)
42
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
39
43
  post :create
40
- response.should redirect_to(duck_url(assigns[:duck]))
44
+ response.should redirect_to(<%= singular_name %>_url(assigns[:<%= singular_name %>]))
41
45
  end
42
46
 
43
47
  <% end %>
44
48
  <% if actions.include?(:edit) -%>
45
49
  it "edit action should render edit template" do
46
- get :edit, :id => Duck.first
50
+ get :edit, :id => <%= class_name %>.first
47
51
  response.should render_template(:edit)
48
52
  end
49
53
 
50
54
  <% end %>
51
55
  <% if actions.include?(:update) -%>
52
56
  it "update action should render edit template when model is invalid" do
53
- Duck.any_instance.stubs(:valid?).returns(false)
54
- put :update, :id => Duck.first
57
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
58
+ put :update, :id => <%= class_name %>.first
55
59
  response.should render_template(:edit)
56
60
  end
57
61
 
58
62
  it "update action should redirect when model is valid" do
59
- Duck.any_instance.stubs(:valid?).returns(true)
60
- put :update, :id => Duck.first
61
- response.should redirect_to(duck_url(assigns[:duck]))
63
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
64
+ put :update, :id => <%= class_name %>.first
65
+ response.should redirect_to(<%= singular_name %>_url(assigns[:<%= singular_name %>]))
62
66
  end
63
67
 
64
68
  <% end %>
65
69
  <% if actions.include?(:destroy) -%>
66
70
  it "destroy action should destroy model and redirect to index action" do
67
- duck = Duck.first
68
- delete :destroy, :id => duck
69
- response.should redirect_to(ducks_url)
70
- Duck.exists?(duck.id).should be_false
71
+ <%= singular_name %> = <%= class_name %>.first
72
+ delete :destroy, :id => <%= singular_name %>
73
+ response.should redirect_to(<%= plural_name %>_url)
74
+ <%= class_name %>.exists?(<%= singular_name %>.id).should be_false
71
75
  end
72
76
 
73
77
  <% end %>
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- describe <%= controller_class_name %>HelperTest
3
+ describe <%= controller_class_name %>Helper do
4
4
 
5
5
  it 'should do something' do
6
6
  assert true
data/lib/dry_generator.rb CHANGED
@@ -12,7 +12,6 @@ class DryGenerator < Rails::Generator::NamedBase
12
12
  custom_config_file = File.expand_path(File.join(Rails.root, 'config', 'scaffold.yml'))
13
13
  config_file = File.join(File.exist?(custom_config_file) ? custom_config_file : default_config_file)
14
14
  config = YAML::load(File.open(config_file))
15
-
16
15
  CONFIG_ARGS = config['dry_scaffold']['args'] rescue nil
17
16
  CONFIG_OPTIONS = config['dry_scaffold']['options'] rescue nil
18
17
  end
@@ -48,7 +47,7 @@ class DryGenerator < Rails::Generator::NamedBase
48
47
  :factory_girl => CONFIG_OPTIONS['factory_girl'] || CONFIG_OPTIONS['fgirl'] || false,
49
48
  :machinist => CONFIG_OPTIONS['machinist'] || false,
50
49
  :object_daddy => CONFIG_OPTIONS['object_daddy'] || CONFIG_OPTIONS['odaddy'] || false,
51
- :test_unit => CONFIG_OPTIONS['test_unit'] || CONFIG_OPTIONS['tunit'] || true,
50
+ :test_unit => CONFIG_OPTIONS['test_unit'] || CONFIG_OPTIONS['tunit'] || false,
52
51
  :shoulda => CONFIG_OPTIONS['shoulda'] || false,
53
52
  :rspec => CONFIG_OPTIONS['rspec'] || false
54
53
  }.freeze
@@ -70,12 +69,12 @@ class DryGenerator < Rails::Generator::NamedBase
70
69
 
71
70
  TESTS_PATH = File.join('test').freeze
72
71
  FUNCTIONAL_TESTS_PATH = {
73
- :test => 'functional',
72
+ :test_unit => 'functional',
74
73
  :shoulda => 'functional',
75
74
  :rspec => 'controllers'
76
75
  }
77
76
  UNIT_TESTS_PATH = {
78
- :test => 'unit',
77
+ :test_unit => 'unit',
79
78
  :shoulda => 'unit',
80
79
  :rspec => 'models',
81
80
  }
@@ -89,7 +88,9 @@ class DryGenerator < Rails::Generator::NamedBase
89
88
  def initialize(runtime_args, runtime_options = {})
90
89
  super(runtime_args, runtime_options)
91
90
 
92
- @test_framework = options[:test_framework] || DEFAULT_TEST_FRAMEWORK
91
+ @test_framework = ( options[:test_framework] && options[:test_framework].to_sym ) ||
92
+ [:rspec,:test_unit,:shoulda].detect{|t|options[t]} ||
93
+ DEFAULT_TEST_FRAMEWORK
93
94
  end
94
95
 
95
96
  protected
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grimen-dry_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Grimfelt
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-18 00:00:00 -07:00
12
+ date: 2009-09-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: A DRYer scaffold generator for Rails. Generates dry semantic and standards compliant views, and dry RESTful controllers. Has support for Rspec, Shoulda, Formtastic, Inherited Resources, Factory Girl, Machinist, Object Daddy, Will Paginate
16
+ description: A DRYer scaffold generator for Rails. Generates dry semantic and standards compliant views, and dry RESTful controllers.
17
17
  email: grimen@gmail.com
18
18
  executables:
19
19
  - dscaffold
@@ -101,6 +101,7 @@ files:
101
101
  - tasks/dry_scaffold.rake
102
102
  has_rdoc: false
103
103
  homepage: http://github.com/grimen/dry_scaffold/tree/master
104
+ licenses:
104
105
  post_install_message:
105
106
  rdoc_options:
106
107
  - --charset=UTF-8
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  requirements: []
122
123
 
123
124
  rubyforge_project:
124
- rubygems_version: 1.2.0
125
+ rubygems_version: 1.3.5
125
126
  signing_key:
126
127
  specification_version: 3
127
128
  summary: A DRYer scaffold generator for Rails. Generates dry semantic and standards compliant views, and dry RESTful controllers.