resource_cloner 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ class ResourceCloneGeneratorTest < Rails::Generators::TestCase
11
11
  @orig_model = "person"
12
12
  @clone_model = "cloned_person"
13
13
  @args = [@clone_model, @orig_model, "--test-mode=true"]
14
+ puts "rails g resource_clone #{@args.join(" ")}"
14
15
  prepare_destination
15
16
  copy_dummy_files
16
17
  end
@@ -36,7 +37,6 @@ class ResourceCloneGeneratorTest < Rails::Generators::TestCase
36
37
  run_generator @args
37
38
 
38
39
  migr_files = Dir["#{destination_root}/db/migrate/*_create_#{@clone_model.pluralize}.rb"]
39
- #binding.pry
40
40
  assert(migr_files.count > 0, "no migration file")
41
41
  assert_file migr_files.first do |clone|
42
42
  assert_match "class Create#{@clone_model.classify.pluralize} < ActiveRecord::Migration",
@@ -51,15 +51,24 @@ class ResourceCloneGeneratorTest < Rails::Generators::TestCase
51
51
  assert_no_file "/app/controllers/#{@clone_model.pluralize}_controller.rb"
52
52
  run_generator @args
53
53
  assert_file "app/controllers/#{@clone_model.pluralize}_controller.rb" do |clone|
54
- assert_match "class #{@clone_model.classify.pluralize}Controller < ApplicationController", clone
55
54
  assert_no_match %r(@#{@orig_model.pluralize} \=), clone
56
- assert_no_match %r(\s#{@orig_model.classify}\s), clone
57
55
  assert_no_match %r(@#{@orig_model} \=), clone
56
+ assert_no_match %r(@#{@orig_model}\.), clone #@person.
58
57
  assert_no_match %r(def #{@orig_model}_params), clone
58
+ assert_no_match %r(\(#{@orig_model}_params\)), clone #using model_params method
59
+ assert_no_match %r([Created|Updated] #{@orig_model.humanize}), clone
60
+ assert_no_match %r(redirect_to #{@orig_model.pluralize}_url), clone
61
+ assert_no_match %r(redirect_to #{@orig_model}_url\(@#{@orig_model}\)), clone
62
+
63
+ assert_match "class #{@clone_model.classify.pluralize}Controller < ApplicationController", clone
59
64
  assert_match %r(@#{@clone_model.pluralize} \=), clone
60
- assert_match %r(\s#{@clone_model.classify}\s), clone
61
65
  assert_match %r(@#{@clone_model} \=), clone
62
- assert_match %r(def #{@clone_model}_params), clone
66
+ assert_match %r(@#{@clone_model}\.), clone
67
+ assert_match %r(def #{@clone_model}_params), clone
68
+ assert_match %r(\(#{@clone_model}_params\)), clone
69
+ assert_match %r([Created|Updated] #{@clone_model.humanize}), clone
70
+ assert_match %r(redirect_to #{@clone_model.pluralize}_url), clone
71
+ assert_match %r(redirect_to #{@clone_model}_url\(@#{@clone_model}\)), clone
63
72
  end
64
73
  end
65
74
 
@@ -83,8 +92,11 @@ class ResourceCloneGeneratorTest < Rails::Generators::TestCase
83
92
  end
84
93
  assert_file "app/views/#{@clone_model.pluralize}/_form.html.haml" do |clone|
85
94
  assert_no_match %r(@#{@orig_model}\s), clone
86
- #Links
87
95
  assert_match %r(@#{@clone_model}\s), clone
96
+ #Links
97
+ assert_no_match %r(\s+#{@orig_model.pluralize}_path), clone # people_path
98
+ assert_match %r(\s+#{@clone_model.pluralize}_path), clone
99
+
88
100
  end
89
101
  assert_file "app/views/#{@clone_model.pluralize}/edit.html.haml" do |clone|
90
102
  assert_no_match %r(\s#{@orig_model.humanize}\s), clone
@@ -107,6 +119,7 @@ class ResourceCloneGeneratorTest < Rails::Generators::TestCase
107
119
 
108
120
  assert_file "config/routes.rb" do |routes|
109
121
  assert_no_match "resources :#{@clone_model.pluralize}", routes
122
+ assert_no_match %r(resource\s*\:#{@clone_model}), routes
110
123
  assert_no_match new_routes_block, routes
111
124
  end
112
125
 
@@ -114,6 +127,7 @@ class ResourceCloneGeneratorTest < Rails::Generators::TestCase
114
127
 
115
128
  assert_file "config/routes.rb" do |routes|
116
129
  assert_match "resources :#{@clone_model.pluralize}", routes
130
+ assert_match %r(resource\s*:#{@clone_model}), routes
117
131
  assert_match new_routes_block, routes
118
132
  end
119
133
 
data/test/test_helper.rb CHANGED
@@ -14,3 +14,5 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
14
  if ActiveSupport::TestCase.method_defined?(:fixture_path=)
15
15
  ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
16
16
  end
17
+
18
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_cloner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John O'Malley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails