rspec_rails_scaffold_templates 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8bdc50dc2870358191dbe48e27e78da86f218b6f
4
+ data.tar.gz: 82770019be22c3c5ff24238d9cd584563d3dec92
5
+ SHA512:
6
+ metadata.gz: 3dbb78cac857cc3c7888f055c4dae3c5c53c8ee80ad3d41b2a3d6558f58531f3f90ebfd9ba2587081473021b45c8b5f98f6929f5da820278011b5a87aeffe023
7
+ data.tar.gz: 54c3a1b787c41211fd1b20f6dc180715a253a8fa8146092e0fd6326171840618f2fa4ba8b7ffb1b86aec7d17a5b0863dffa7ba7f960677cb0a76a41613dc4ae2
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 3.1"
10
+ gem "rdoc", "~> 4.1"
11
+ gem "bundler", "~> 1.6"
12
+ gem "jeweler", "~> 2.0"
13
+ gem "simplecov", "~> 0.0"
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Dmitri Koulikoff (acer)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,38 @@
1
+ = rspec_rails_scaffold_templates
2
+
3
+ RSpec scaffold generator templates that
4
+ * uses FactoryGirl to simplify form valid parameters
5
+ * if gem WiceGrid is used prepares all the staff for index spec
6
+ * makes all necessary stubs to use with cancan (cancancan) gem
7
+
8
+ == Installation
9
+
10
+ Add to your Gemfile
11
+
12
+ gem 'rspec_rails_scaffold_templates'
13
+
14
+ Then bundle as usual.
15
+
16
+ == Usage
17
+
18
+ Next time you run
19
+
20
+ rails generate scaffold SomeModel ...
21
+
22
+ you will get the needed specs for controller and views.
23
+
24
+ == Contributing to rspec_rails_scaffold_templates
25
+
26
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
27
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
28
+ * Fork the project.
29
+ * Start a feature/bugfix branch.
30
+ * Commit and push until you are happy with your contribution.
31
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
32
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
33
+
34
+ == Copyright
35
+
36
+ Copyright (c) 2014 Dmitri Koulikoff. See LICENSE.txt for
37
+ further details.
38
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "rspec_rails_scaffold_templates"
18
+ gem.homepage = "http://github.com/dima4p/rspec_rails_scaffold_templates"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{RSpec scaffold generator templates that use FactoryGirl and WiceGrid}
21
+ gem.description = %Q{RSpec scaffold generator templates that use FactoryGirl and WiceGrid}
22
+ gem.email = "dima@koulikoff.ru"
23
+ gem.authors = ["Dmitri Koulikoff"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = "true"
37
+ Rake::Task['spec'].execute
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "rspec_rails_scaffold_templates #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,7 @@
1
+ module RspecRailsScaffoldTemplates
2
+ class Railtie < Rails::Railtie
3
+ config.app_generators do |g|
4
+ g.templates.unshift File::expand_path('../templates', __FILE__)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ <% if File.exist?(File.join %w[spec rails_helper.rb]) -%>
2
+ require 'rails_helper'
3
+ <% else -%>
4
+ require 'spec_helper'
5
+ <% end -%>
6
+
7
+ describe "<%= class_name.pluralize %>", type: :request do
8
+ before :each do
9
+ allow_any_instance_of(<%= class_name.pluralize %>Controller).to receive(:current_user).and_return(current_user)
10
+ end
11
+
12
+ describe "GET /<%= table_name %>" do
13
+ it "works! (now write some real specs)" do
14
+ get <%= index_helper %>_path
15
+ # expect(response.status).to have_http_status(200)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,170 @@
1
+ <% if File.exist?(File.join %w[spec rails_helper.rb]) -%>
2
+ require 'rails_helper'
3
+ <% else -%>
4
+ require 'spec_helper'
5
+ <% end -%>
6
+
7
+ <% module_namespacing do -%>
8
+ describe <%= controller_class_name %>Controller, :type => :controller do
9
+
10
+ before :each do
11
+ allow(controller).to receive(:current_user).and_return(current_user)
12
+ end
13
+
14
+ # This should return the minimal set of attributes required to create a valid
15
+ # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
16
+ # adjust the attributes here as well. The list could not be empty.
17
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
18
+ <% attribute = attributes.detect{|a| attributes.detect{|a| a.name == 'name'} || attributes.detect{|a| a.name == 'title'} || attributes.first} -%>
19
+ <% attribute_name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
20
+ let(:valid_attributes) {FactoryGirl.build(:<%=file_name%>).attributes.slice *%w[<%= attribute_name %>]}
21
+ <% else -%>
22
+ let(:valid_attributes) {
23
+ skip("Add a hash of attributes valid for your model")
24
+ }
25
+ <% end -%>
26
+
27
+ let(:invalid_attributes) {
28
+ skip("Add a hash of attributes invalid for your model")
29
+ }
30
+
31
+ # This should return the minimal set of values that should be in the session
32
+ # in order to pass any filters (e.g. authentication) defined in
33
+ # <%= controller_class_name %>Controller. Be sure to keep this updated too.
34
+ let(:valid_session) { {} }
35
+
36
+ <% unless options[:singleton] -%>
37
+ describe "GET index" do
38
+ it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
39
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
40
+ get :index, {}, valid_session
41
+ expect(assigns(:<%= table_name %>)).to be_kind_of(ActiveRecord::Relation)
42
+ expect(assigns(:<%= table_name %>)).to eq([<%= file_name %>])
43
+ end
44
+ end
45
+
46
+ <% end -%>
47
+ describe "GET show" do
48
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
49
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
50
+ get :show, {:id => <%= file_name %>.to_param}, valid_session
51
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
52
+ end
53
+ end
54
+
55
+ describe "GET new" do
56
+ it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
57
+ get :new, {}, valid_session
58
+ expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
59
+ end
60
+ end
61
+
62
+ describe "GET edit" do
63
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
64
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
65
+ get :edit, {:id => <%= file_name %>.to_param}, valid_session
66
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
67
+ end
68
+ end
69
+
70
+ describe "POST create" do
71
+ describe "with valid params" do
72
+ it "creates a new <%= class_name %>" do
73
+ expect {
74
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
75
+ }.to change(<%= class_name %>, :count).by(1)
76
+ end
77
+
78
+ it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
79
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
80
+ expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
81
+ expect(assigns(:<%= ns_file_name %>)).to be_persisted
82
+ end
83
+
84
+ it "redirects to the created <%= ns_file_name %>" do
85
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
86
+ expect(response).to redirect_to(<%= class_name %>.last)
87
+ # expect(response).to redirect_to(<%= index_helper %>_url)
88
+ end
89
+ end
90
+
91
+ describe "with invalid params" do
92
+ it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
93
+ # allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
94
+ post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
95
+ expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
96
+ end
97
+
98
+ it "re-renders the 'new' template" do
99
+ # allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
100
+ post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
101
+ expect(response).to render_template("new")
102
+ end
103
+ end
104
+ end
105
+
106
+ describe "PUT update" do
107
+ describe "with valid params" do
108
+ let(:new_attributes) {
109
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
110
+ FactoryGirl.build(:<%=file_name%>).attributes.slice *%w[<%= attribute_name %>]
111
+ <% else -%>
112
+ skip("Add a hash of attributes valid for your model")
113
+ <% end -%>
114
+ }
115
+
116
+ it "updates the requested <%= ns_file_name %>" do
117
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
118
+ expect_any_instance_of(<%= class_name %>).to receive(:update).with(new_attributes.inject({}){|_, (k, v)| _[k] = v.to_s; _})
119
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
120
+ <%= file_name %>.reload
121
+ skip("Add assertions for updated state")
122
+ end
123
+
124
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
125
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
126
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
127
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
128
+ end
129
+
130
+ it "redirects to the <%= ns_file_name %>" do
131
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
132
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
133
+ expect(response).to redirect_to(<%= file_name %>)
134
+ end
135
+ end
136
+
137
+ describe "with invalid params" do
138
+ it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
139
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
140
+ # allow_any_instance_of(<%= class_name %>).to receive(:update).and_return(false)
141
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
142
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
143
+ end
144
+
145
+ it "re-renders the 'edit' template" do
146
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
147
+ # allow_any_instance_of(<%= class_name %>).to receive(:update).and_return(false)
148
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
149
+ expect(response).to render_template("edit")
150
+ end
151
+ end
152
+ end
153
+
154
+ describe "DELETE destroy" do
155
+ it "destroys the requested <%= ns_file_name %>" do
156
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
157
+ expect {
158
+ delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
159
+ }.to change(<%= class_name %>, :count).by(-1)
160
+ end
161
+
162
+ it "redirects to the <%= table_name %> list" do
163
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
164
+ delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
165
+ expect(response).to redirect_to(<%= index_helper %>_url)
166
+ end
167
+ end
168
+
169
+ end
170
+ <% end -%>
@@ -0,0 +1,33 @@
1
+ <% if File.exist?(File.join %w[spec rails_helper.rb]) -%>
2
+ require 'rails_helper'
3
+ <% else -%>
4
+ require 'spec_helper'
5
+ <% end -%>
6
+
7
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
8
+ describe "<%= ns_table_name %>/edit", :type => :view do
9
+ before(:each) do
10
+ allow(controller).to receive(:can?).and_return(true)
11
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
12
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, create(:<%= ns_file_name %>))
13
+ <% else -%>
14
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
15
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
16
+ :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
17
+ <% end -%>
18
+ <%= output_attributes.empty? ? "" : " ))\n" -%>
19
+ <% end -%>
20
+ end
21
+
22
+ it "renders the edit <%= ns_file_name %> form" do
23
+ render
24
+
25
+ assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(@<%= ns_file_name %>), "post" do
26
+ <% for attribute in output_attributes -%>
27
+ <% name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
28
+ <% input_type = attribute.reference? ? 'select' : attribute.input_type -%>
29
+ assert_select '<%= input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]', '<%= ns_file_name %>[<%= name %>]'
30
+ <% end -%>
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,59 @@
1
+ <% if File.exist?(File.join %w[spec rails_helper.rb]) -%>
2
+ require 'rails_helper'
3
+ <% else -%>
4
+ require 'spec_helper'
5
+ <% end -%>
6
+
7
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
8
+ describe "<%= ns_table_name %>/index", :type => :view do
9
+ before(:each) do
10
+ allow(controller).to receive(:can?).and_return(true)
11
+ <% if options[:fixture_replacement] == :factory_girl -%>
12
+ # options[:fixture_replacement] == :factory_girl
13
+ <% end -%>
14
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
15
+ <% size = 1 -%>
16
+ @<%= ns_file_name %> = create(:<%= ns_file_name %>)
17
+ <% if not defined? Wice::WiceGrid -%>
18
+ assign(:<%= table_name %>, [@<%= ns_file_name %>, @<%= ns_file_name %>])
19
+ <% end -%>
20
+ <% else -%>
21
+ <% size = 2 -%>
22
+ <% if defined? Wice::WiceGrid -%>
23
+ result_set = assign(:<%= table_name %>, [
24
+ <% else -%>
25
+ assign(:<%= table_name %>, [
26
+ <% end -%>
27
+ # if you got an exception here add gem 'rspec-activemodel-mocks' to your Gemfile
28
+ <% [1,2].each_with_index do |id, model_index| -%>
29
+ <%= class_name %>.create(<%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : '' %>
30
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
31
+ :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
32
+ <% end -%>
33
+ <% if !output_attributes.empty? -%>
34
+ <%= model_index == 1 ? ')' : '),' %>
35
+ <% end -%>
36
+ <% end -%>
37
+ ])
38
+ <% end -%>
39
+ <% if defined? Wice::WiceGrid -%>
40
+ assign(:grid, Wice::WiceGrid.new(<%= class_name %>, controller))
41
+ <% end -%>
42
+ end
43
+
44
+ it "renders a list of <%= table_name %>" do
45
+ render
46
+
47
+ <% for attribute in output_attributes -%>
48
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
49
+ <% if attribute.reference? -%>
50
+ assert_select 'tr>td', text: @<%= ns_file_name %>.<%= attribute.name %>.name, count: <%= size %>
51
+ <% else -%>
52
+ assert_select 'tr>td', text: @<%= ns_file_name %>.<%= attribute.name %>.to_s, count: <%= size %>
53
+ <% end -%>
54
+ <% else -%>
55
+ assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => <%= size %>
56
+ <% end -%>
57
+ <% end -%>
58
+ end
59
+ end
@@ -0,0 +1,33 @@
1
+ <% if File.exist?(File.join %w[spec rails_helper.rb]) -%>
2
+ require 'rails_helper'
3
+ <% else -%>
4
+ require 'spec_helper'
5
+ <% end -%>
6
+
7
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
8
+ describe "<%= ns_table_name %>/new", :type => :view do
9
+ before(:each) do
10
+ allow(controller).to receive(:can?).and_return(true)
11
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
12
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, build(:<%= ns_file_name %>))
13
+ end
14
+ <% else -%>
15
+ assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %>
16
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
17
+ :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
18
+ <% end -%>
19
+ <%= !output_attributes.empty? ? " ))\n end" : " end" %>
20
+ <% end -%>
21
+
22
+ it "renders new <%= ns_file_name %> form" do
23
+ render
24
+
25
+ assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
26
+ <% for attribute in output_attributes -%>
27
+ <% name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
28
+ <% input_type = attribute.reference? ? 'select' : attribute.input_type -%>
29
+ assert_select '<%= input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]', '<%= ns_file_name %>[<%= name %>]'
30
+ <% end -%>
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,38 @@
1
+ <% if File.exist?(File.join %w[spec rails_helper.rb]) -%>
2
+ require 'rails_helper'
3
+ <% else -%>
4
+ require 'spec_helper'
5
+ <% end -%>
6
+
7
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
8
+ describe "<%= ns_table_name %>/show", :type => :view do
9
+ before(:each) do
10
+ allow(controller).to receive(:can?).and_return(true)
11
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
12
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, create(:<%= ns_file_name %>))
13
+ <% else -%>
14
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
15
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
16
+ :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
17
+ <% end -%>
18
+ <% if !output_attributes.empty? -%>
19
+ ))
20
+ <% end -%>
21
+ <% end -%>
22
+ end
23
+
24
+ it "renders attributes in <p>" do
25
+ render
26
+ <% for attribute in output_attributes -%>
27
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
28
+ <% if attribute.reference? -%>
29
+ expect(rendered).to match(Regexp.new @<%= ns_file_name %>.<%= attribute.name %>.name)
30
+ <% else -%>
31
+ expect(rendered).to match(Regexp.new @<%= ns_file_name %>.<%= attribute.name %>.to_s)
32
+ <% end -%>
33
+ <% else -%>
34
+ expect(rendered).to match(/<%= raw_value_for(attribute) %>/)
35
+ <% end -%>
36
+ <% end -%>
37
+ end
38
+ end
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: rspec_rails_scaffold_templates 1.0.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "rspec_rails_scaffold_templates"
9
+ s.version = "1.0.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Dmitri Koulikoff"]
14
+ s.date = "2014-09-12"
15
+ s.description = "RSpec scaffold generator templates that use FactoryGirl and WiceGrid"
16
+ s.email = "dima@koulikoff.ru"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/rspec_rails_scaffold_templates.rb",
30
+ "lib/templates/rspec/integration/request_spec.rb",
31
+ "lib/templates/rspec/scaffold/controller_spec.rb",
32
+ "lib/templates/rspec/scaffold/edit_spec.rb",
33
+ "lib/templates/rspec/scaffold/index_spec.rb",
34
+ "lib/templates/rspec/scaffold/new_spec.rb",
35
+ "lib/templates/rspec/scaffold/show_spec.rb",
36
+ "rspec_rails_scaffold_templates.gemspec",
37
+ "spec/rspec_rails_scaffold_templates_spec.rb",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+ s.homepage = "http://github.com/dima4p/rspec_rails_scaffold_templates"
41
+ s.licenses = ["MIT"]
42
+ s.rubygems_version = "2.2.2"
43
+ s.summary = "RSpec scaffold generator templates that use FactoryGirl and WiceGrid"
44
+
45
+ if s.respond_to? :specification_version then
46
+ s.specification_version = 4
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<rspec>, ["~> 3.1"])
50
+ s.add_development_dependency(%q<rdoc>, ["~> 4.1"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 1.6"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
53
+ s.add_development_dependency(%q<simplecov>, ["~> 0.0"])
54
+ else
55
+ s.add_dependency(%q<rspec>, ["~> 3.1"])
56
+ s.add_dependency(%q<rdoc>, ["~> 4.1"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
58
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
59
+ s.add_dependency(%q<simplecov>, ["~> 0.0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<rspec>, ["~> 3.1"])
63
+ s.add_dependency(%q<rdoc>, ["~> 4.1"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
65
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
66
+ s.add_dependency(%q<simplecov>, ["~> 0.0"])
67
+ end
68
+ end
69
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "RspecRailsScaffoldTemplates" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
+
20
+ require 'rspec'
21
+ require 'rspec_rails_scaffold_templates'
22
+
23
+ # Requires supporting files with custom matchers and macros, etc,
24
+ # in ./support/ and its subdirectories.
25
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
26
+
27
+ RSpec.configure do |config|
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec_rails_scaffold_templates
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitri Koulikoff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.0'
83
+ description: RSpec scaffold generator templates that use FactoryGirl and WiceGrid
84
+ email: dima@koulikoff.ru
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.rdoc
90
+ files:
91
+ - ".document"
92
+ - ".rspec"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.rdoc
96
+ - Rakefile
97
+ - VERSION
98
+ - lib/rspec_rails_scaffold_templates.rb
99
+ - lib/templates/rspec/integration/request_spec.rb
100
+ - lib/templates/rspec/scaffold/controller_spec.rb
101
+ - lib/templates/rspec/scaffold/edit_spec.rb
102
+ - lib/templates/rspec/scaffold/index_spec.rb
103
+ - lib/templates/rspec/scaffold/new_spec.rb
104
+ - lib/templates/rspec/scaffold/show_spec.rb
105
+ - rspec_rails_scaffold_templates.gemspec
106
+ - spec/rspec_rails_scaffold_templates_spec.rb
107
+ - spec/spec_helper.rb
108
+ homepage: http://github.com/dima4p/rspec_rails_scaffold_templates
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.2.2
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: RSpec scaffold generator templates that use FactoryGirl and WiceGrid
132
+ test_files: []