crudspec 0.1.2 → 0.2.0
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.
- data/Gemfile.lock +8 -8
- data/README.markdown +15 -4
- data/lib/crudspec/version.rb +1 -1
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/spec_generator.rb +48 -0
- data/lib/generators/templates/.DS_Store +0 -0
- data/lib/generators/templates/actions/create.rb +40 -0
- data/lib/generators/templates/actions/destroy.rb +22 -0
- data/lib/generators/templates/actions/edit.rb +21 -0
- data/lib/generators/templates/actions/index.rb +16 -0
- data/lib/generators/templates/actions/new.rb +16 -0
- data/lib/generators/templates/actions/show.rb +21 -0
- data/lib/generators/templates/actions/update.rb +40 -0
- data/lib/generators/templates/controller_spec.rb +1 -160
- data/test/generators/test_spec_generator.rb +127 -0
- metadata +13 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
crudspec (0.
|
4
|
+
crudspec (0.2.0)
|
5
5
|
rails
|
6
6
|
rspec
|
7
7
|
|
@@ -67,14 +67,14 @@ GEM
|
|
67
67
|
rake (>= 0.8.7)
|
68
68
|
thor (~> 0.14.4)
|
69
69
|
rake (0.8.7)
|
70
|
-
rspec (2.
|
71
|
-
rspec-core (~> 2.
|
72
|
-
rspec-expectations (~> 2.
|
73
|
-
rspec-mocks (~> 2.
|
74
|
-
rspec-core (2.1
|
75
|
-
rspec-expectations (2.
|
70
|
+
rspec (2.2.0)
|
71
|
+
rspec-core (~> 2.2)
|
72
|
+
rspec-expectations (~> 2.2)
|
73
|
+
rspec-mocks (~> 2.2)
|
74
|
+
rspec-core (2.2.1)
|
75
|
+
rspec-expectations (2.2.0)
|
76
76
|
diff-lcs (~> 1.1.2)
|
77
|
-
rspec-mocks (2.
|
77
|
+
rspec-mocks (2.2.0)
|
78
78
|
thor (0.14.6)
|
79
79
|
treetop (1.4.9)
|
80
80
|
polyglot (>= 0.3.1)
|
data/README.markdown
CHANGED
@@ -85,9 +85,17 @@ A controller that would work out of the box would look something like:
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
|
88
|
+
### Options
|
89
89
|
|
90
|
-
|
90
|
+
#### Specific Actions
|
91
|
+
|
92
|
+
If you are not using all the CRUD actions in your controller, you can specify the one(s) you need. For example:
|
93
|
+
|
94
|
+
rails generate crudspec:spec products_controller index show
|
95
|
+
|
96
|
+
This will only create the specs for the *index* and *show* actions. Additionally, when you specify the *new* and *edit* actions, the specs for *create* and *update* will be generated as well.
|
97
|
+
|
98
|
+
#### Devise
|
91
99
|
|
92
100
|
If you're using [devise](https://github.com/plataformatec/devise) to authenticate your users, you can easily add
|
93
101
|
that to the spec by using the *devise* option.
|
@@ -106,8 +114,11 @@ And this will add the following lines to the spec:
|
|
106
114
|
sign_in @user
|
107
115
|
end
|
108
116
|
|
117
|
+
## CHANGELOG
|
118
|
+
|
119
|
+
* 0.2.0 Create specs for specific actions
|
109
120
|
|
110
|
-
|
121
|
+
## TODO
|
111
122
|
|
112
123
|
* Option to create a test for Ruby::Test
|
113
124
|
* Option to create a cucumber feature
|
@@ -116,5 +127,5 @@ And this will add the following lines to the spec:
|
|
116
127
|
# About the Author
|
117
128
|
|
118
129
|
[Crowd Interactive](http://www.crowdint.com) is an American web design and development company that happens to work in Colima, Mexico.
|
119
|
-
We specialize in building and growing online retail stores. We don’t work with everyone
|
130
|
+
We specialize in building and growing online retail stores. We don’t work with everyone, just companies we believe in. Call us today to see if there’s a fit.
|
120
131
|
Find more info [here](http://www.crowdint.com)!
|
data/lib/crudspec/version.rb
CHANGED
Binary file
|
@@ -1,11 +1,28 @@
|
|
1
1
|
module Crudspec
|
2
2
|
module Generators
|
3
3
|
class SpecGenerator < Rails::Generators::Base
|
4
|
+
no_tasks { attr_accessor :controller_actions }
|
4
5
|
argument :controller_name, :type => :string, :banner => 'controller_name'
|
6
|
+
argument :controller_args, :type => :array, :default => [], :banner => 'controller_actions'
|
5
7
|
source_root File.expand_path("../templates", __FILE__)
|
6
8
|
desc "Create a RSpec spec for a CRUD controller"
|
7
9
|
class_option :devise, :desc => "Include steps to authenticate via devise", :type => :string, :banner => "devise_model", :required => false
|
8
10
|
|
11
|
+
def initialize(*args, &block)
|
12
|
+
super
|
13
|
+
|
14
|
+
@controller_actions = []
|
15
|
+
|
16
|
+
controller_args.each do |arg|
|
17
|
+
@controller_actions << arg
|
18
|
+
@controller_actions << 'create' if arg == 'new'
|
19
|
+
@controller_actions << 'update' if arg == 'edit'
|
20
|
+
end
|
21
|
+
|
22
|
+
@controller_actions.uniq!
|
23
|
+
@controller_actions = all_actions if @controller_actions.empty?
|
24
|
+
end
|
25
|
+
|
9
26
|
def generate_spec_file
|
10
27
|
underscored = controller_name.underscore
|
11
28
|
underscored = underscored + '_controller' unless underscored.match(/_controller$/)
|
@@ -18,6 +35,37 @@ module Crudspec
|
|
18
35
|
|
19
36
|
template('controller_spec.rb', file_path)
|
20
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def all_actions
|
41
|
+
%w[index show new create edit update destroy]
|
42
|
+
end
|
43
|
+
|
44
|
+
def controller_methods(dir_name)
|
45
|
+
controller_actions.map do |action|
|
46
|
+
read_template("#{dir_name}/#{action}.rb") if all_actions.include?(action)
|
47
|
+
end.join(" \n").strip
|
48
|
+
end
|
49
|
+
|
50
|
+
def singular_name
|
51
|
+
controller_name.underscore
|
52
|
+
end
|
53
|
+
|
54
|
+
def plural_name
|
55
|
+
controller_name.underscore.pluralize
|
56
|
+
end
|
57
|
+
|
58
|
+
def class_name
|
59
|
+
controller_name.camelize
|
60
|
+
end
|
61
|
+
|
62
|
+
def plural_class_name
|
63
|
+
plural_name.camelize
|
64
|
+
end
|
65
|
+
|
66
|
+
def read_template(relative_path)
|
67
|
+
ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
|
68
|
+
end
|
21
69
|
end
|
22
70
|
end
|
23
71
|
end
|
Binary file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
describe "POST 'create'" do
|
2
|
+
before(:each) do
|
3
|
+
@<%= @model_name %> = <%= @model_name.classify %>.new
|
4
|
+
@<%= @model_name %>.stub(:id).and_return(1)
|
5
|
+
end
|
6
|
+
|
7
|
+
context "The save is successful" do
|
8
|
+
before(:each) do
|
9
|
+
<%= @model_name.classify %>.should_receive(:new).and_return(@<%= @model_name %>)
|
10
|
+
@<%= @model_name %>.should_receive(:save).and_return(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "redirects to the 'show' action" do
|
14
|
+
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
15
|
+
response.should redirect_to(<%= @model_name %>_path(@<%= @model_name %>)) # Put the right show path here
|
16
|
+
end
|
17
|
+
|
18
|
+
it "sets a flash message" do
|
19
|
+
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
20
|
+
flash[:notice].should == '<%= @model_name.classify %> was successfully created.'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "the save fails" do
|
25
|
+
before(:each) do
|
26
|
+
@<%= @model_name %>.should_receive(:save).and_return(false)
|
27
|
+
<%= @model_name.classify %>.should_receive(:new).and_return(@<%= @model_name %>)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "renders the 'new' action" do
|
31
|
+
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
32
|
+
response.should render_template(:new)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "assigns @<%= @model_name %>" do
|
36
|
+
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
37
|
+
assigns(:<%= @model_name %>).should_not be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
describe "DELETE 'destroy'" do
|
2
|
+
before(:each) do
|
3
|
+
# Replace this with your Mock Factory, for ex: Machinist, Fabrication...
|
4
|
+
@<%= @model_name %> = <%= @model_name.pluralize %>(:one)
|
5
|
+
<%= @model_name.classify %>.should_receive(:find).with(@<%= @model_name %>.id).and_return(@<%= @model_name %>)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should delete the <%= @model_name %>" do
|
9
|
+
@<%= @model_name %>.should_receive(:delete).and_return(true)
|
10
|
+
delete :destroy, :id => @<%= @model_name %>.id
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should redirect to index page" do
|
14
|
+
delete :destroy, :id => @<%= @model_name %>.id
|
15
|
+
response.should redirect_to(:<%= @model_name.pluralize %>)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "sets a flash message" do
|
19
|
+
delete :destroy, :id => @<%= @model_name %>.id
|
20
|
+
flash[:notice].should == '<%= @model_name.classify %> was successfully destroyed.' # Your flash message here
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe "GET 'edit'" do
|
2
|
+
before(:each) do
|
3
|
+
# Replace this with your Mock Factory, for ex: Machinist, Fabrication...
|
4
|
+
@<%= @model_name %> = <%= @model_name.pluralize %>(:one)
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'is successful' do
|
8
|
+
get :edit, :id => @<%= @model_name %>.id
|
9
|
+
response.should be_success
|
10
|
+
end
|
11
|
+
|
12
|
+
it "assigns @<%= @model_name %>" do
|
13
|
+
get :edit, :id => @<%= @model_name %>.id
|
14
|
+
assigns(:<%= @model_name %>).should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "renders the 'edit' template" do
|
18
|
+
get :edit, :id => @<%= @model_name %>.id
|
19
|
+
response.should render_template('edit')
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "GET 'index'" do
|
2
|
+
it "is successful" do
|
3
|
+
get :index
|
4
|
+
response.should be_success
|
5
|
+
end
|
6
|
+
|
7
|
+
it "assigns @<%= @model_name %>" do
|
8
|
+
get :index
|
9
|
+
assigns(:<%= @model_name.pluralize %>).should_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders index template" do
|
13
|
+
get :index
|
14
|
+
response.should render_template('index')
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "GET 'new'" do
|
2
|
+
it 'is successful' do
|
3
|
+
get :new
|
4
|
+
response.should be_success
|
5
|
+
end
|
6
|
+
|
7
|
+
it "assigns @<%= @model_name %>" do
|
8
|
+
get :new
|
9
|
+
assigns(:<%= @model_name %>).should_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders the 'new' template" do
|
13
|
+
get :new
|
14
|
+
response.should render_template('new')
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe "GET 'show'" do
|
2
|
+
before(:each) do
|
3
|
+
# Replace this with your Mock Factory, for ex: Machinist, Fabrication...
|
4
|
+
@<%= @model_name %> = <%= @model_name.pluralize %>(:one)
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'is successful' do
|
8
|
+
get :show, :id => @<%= @model_name %>.id
|
9
|
+
response.should be_success
|
10
|
+
end
|
11
|
+
|
12
|
+
it "assigns @<%= @model_name %>" do
|
13
|
+
get :show, :id => @<%= @model_name %>.id
|
14
|
+
assigns(:<%= @model_name %>).should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "renders the 'show' template" do
|
18
|
+
get :show, :id => @<%= @model_name %>.id
|
19
|
+
response.should render_template('show')
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
describe "PUT 'update'" do
|
2
|
+
before(:each) do
|
3
|
+
# Replace this with your Mock Factory, for ex: Machinist, Fabrication...
|
4
|
+
@<%= @model_name %> = <%= @model_name.pluralize %>(:one)
|
5
|
+
end
|
6
|
+
|
7
|
+
context "the update is successful" do
|
8
|
+
before(:each) do
|
9
|
+
@<%= @model_name %>.should_receive(:update_attributes).and_return(true)
|
10
|
+
<%= @model_name.classify %>.should_receive(:find).with(@<%= @model_name %>.id).and_return(@<%= @model_name %>)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "redirects to 'show' action" do
|
14
|
+
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
15
|
+
response.should redirect_to(<%= @model_name %>_path(@<%= @model_name %>)) # Put the right show path here
|
16
|
+
end
|
17
|
+
|
18
|
+
it "sets a flash message" do
|
19
|
+
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
20
|
+
flash[:notice].should == '<%= @model_name.classify %> was successfully updated.' # Your flash message here
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "the update fails" do
|
25
|
+
before(:each) do
|
26
|
+
@<%= @model_name %>.should_receive(:update_attributes).and_return(false)
|
27
|
+
<%= @model_name.classify %>.should_receive(:find).with(@<%= @model_name %>.id).and_return(@<%= @model_name %>)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "renders the 'edit' action" do
|
31
|
+
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
32
|
+
response.should render_template(:edit)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "assigns @<%= @model_name %>" do
|
36
|
+
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
37
|
+
assigns(:<%= @model_name %>).should_not be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -10,164 +10,5 @@ describe <%= @class_name %> do
|
|
10
10
|
sign_in @<%= @devise %>
|
11
11
|
end
|
12
12
|
<% end %>
|
13
|
-
|
14
|
-
it "is successful" do
|
15
|
-
get :index
|
16
|
-
response.should be_success
|
17
|
-
end
|
18
|
-
|
19
|
-
it "assigns @<%= @model_name %>" do
|
20
|
-
get :index
|
21
|
-
assigns(:<%= @model_name.pluralize %>).should_not be_nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it "renders index template" do
|
25
|
-
get :index
|
26
|
-
response.should render_template('index')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "GET 'new'" do
|
31
|
-
it 'is successful' do
|
32
|
-
get :new
|
33
|
-
response.should be_success
|
34
|
-
end
|
35
|
-
|
36
|
-
it "assigns @<%= @model_name %>" do
|
37
|
-
get :new
|
38
|
-
assigns(:<%= @model_name %>).should_not be_nil
|
39
|
-
end
|
40
|
-
|
41
|
-
it "renders the 'new' template" do
|
42
|
-
get :new
|
43
|
-
response.should render_template('new')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "POST 'create'" do
|
48
|
-
before(:each) do
|
49
|
-
@<%= @model_name %> = <%= @model_name.classify %>.new
|
50
|
-
@<%= @model_name %>.stub(:id).and_return(1)
|
51
|
-
end
|
52
|
-
|
53
|
-
context "The save is successful" do
|
54
|
-
before(:each) do
|
55
|
-
<%= @model_name.classify %>.should_receive(:new).and_return(@<%= @model_name %>)
|
56
|
-
@<%= @model_name %>.should_receive(:save).and_return(true)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "redirects to the 'show' action" do
|
60
|
-
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
61
|
-
response.should redirect_to(<%= @model_name %>_path(@<%= @model_name %>)) # Put the right show path here
|
62
|
-
end
|
63
|
-
|
64
|
-
it "sets a flash message" do
|
65
|
-
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
66
|
-
flash[:notice].should == '<%= @model_name.classify %> was successfully created.'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "the save fails" do
|
71
|
-
before(:each) do
|
72
|
-
@<%= @model_name %>.should_receive(:save).and_return(false)
|
73
|
-
<%= @model_name.classify %>.should_receive(:new).and_return(@<%= @model_name %>)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "renders the 'new' action" do
|
77
|
-
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
78
|
-
response.should render_template(:new)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "assigns @<%= @model_name %>" do
|
82
|
-
post :create, :<%= @model_name %> => @<%= @model_name %>.attributes
|
83
|
-
assigns(:<%= @model_name %>).should_not be_nil
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "GET 'edit'" do
|
89
|
-
before(:each) do
|
90
|
-
# Replace this with your Mock Factory, for ex: Machinist, Fabrication...
|
91
|
-
@<%= @model_name %> = <%= @model_name.pluralize %>(:one)
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'is successful' do
|
95
|
-
get :edit, :id => @<%= @model_name %>.id
|
96
|
-
response.should be_success
|
97
|
-
end
|
98
|
-
|
99
|
-
it "assigns @<%= @model_name %>" do
|
100
|
-
get :edit, :id => @<%= @model_name %>.id
|
101
|
-
assigns(:<%= @model_name %>).should_not be_nil
|
102
|
-
end
|
103
|
-
|
104
|
-
it "renders the 'edit' template" do
|
105
|
-
get :edit, :id => @<%= @model_name %>.id
|
106
|
-
response.should render_template('edit')
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "PUT 'update'" do
|
111
|
-
before(:each) do
|
112
|
-
# Replace this with your Mock Factory, for ex: Machinist, Fabrication...
|
113
|
-
@<%= @model_name %> = <%= @model_name.pluralize %>(:one)
|
114
|
-
end
|
115
|
-
|
116
|
-
context "the update is successful" do
|
117
|
-
before(:each) do
|
118
|
-
@<%= @model_name %>.should_receive(:update_attributes).and_return(true)
|
119
|
-
<%= @model_name.classify %>.should_receive(:find).with(@<%= @model_name %>.id).and_return(@<%= @model_name %>)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "redirects to 'show' action" do
|
123
|
-
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
124
|
-
response.should redirect_to(<%= @model_name %>_path(@<%= @model_name %>)) # Put the right show path here
|
125
|
-
end
|
126
|
-
|
127
|
-
it "sets a flash message" do
|
128
|
-
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
129
|
-
flash[:notice].should == '<%= @model_name.classify %> was successfully updated.' # Your flash message here
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "the update fails" do
|
134
|
-
before(:each) do
|
135
|
-
@<%= @model_name %>.should_receive(:update_attributes).and_return(false)
|
136
|
-
<%= @model_name.classify %>.should_receive(:find).with(@<%= @model_name %>.id).and_return(@<%= @model_name %>)
|
137
|
-
end
|
138
|
-
|
139
|
-
it "renders the 'edit' action" do
|
140
|
-
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
141
|
-
response.should render_template(:edit)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "assigns @<%= @model_name %>" do
|
145
|
-
put :update, :id => @<%= @model_name %>.id, :<%= @model_name %> => {} # Add here some attributes for the model
|
146
|
-
assigns(:<%= @model_name %>).should_not be_nil
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "DELETE 'destroy'" do
|
152
|
-
before(:each) do
|
153
|
-
# Replace this with your Mock Factory, for ex: Machinist, Fabrication...
|
154
|
-
@<%= @model_name %> = <%= @model_name.pluralize %>(:one)
|
155
|
-
<%= @model_name.classify %>.should_receive(:find).with(@<%= @model_name %>.id).and_return(@<%= @model_name %>)
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should delete the <%= @model_name %>" do
|
159
|
-
@<%= @model_name %>.should_receive(:delete).and_return(true)
|
160
|
-
delete :destroy, :id => @<%= @model_name %>.id
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should redirect to index page" do
|
164
|
-
delete :destroy, :id => @<%= @model_name %>.id
|
165
|
-
response.should redirect_to(:<%= @model_name.pluralize %>)
|
166
|
-
end
|
167
|
-
|
168
|
-
it "sets a flash message" do
|
169
|
-
delete :destroy, :id => @<%= @model_name %>.id
|
170
|
-
flash[:notice].should == '<%= @model_name.classify %> was successfully destroyed.' # Your flash message here
|
171
|
-
end
|
172
|
-
end
|
13
|
+
<%= controller_methods :actions %>
|
173
14
|
end
|
@@ -25,5 +25,132 @@ class SpecGeneratorTest < Rails::Generators::TestCase
|
|
25
25
|
assert_file 'spec/controllers/admin/secrets_controller_spec.rb', /sign_in @user/
|
26
26
|
assert_file 'spec/controllers/admin/secrets_controller_spec.rb', /include Devise::TestHelpers/
|
27
27
|
end
|
28
|
+
|
29
|
+
test "the spec controller should include all the actions" do
|
30
|
+
run_generator %w(users)
|
31
|
+
|
32
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
33
|
+
assert_match "get :index", body
|
34
|
+
assert_match "get :show", body
|
35
|
+
assert_match "get :new", body
|
36
|
+
assert_match "post :create", body
|
37
|
+
assert_match "get :edit", body
|
38
|
+
assert_match "put :update", body
|
39
|
+
assert_match "delete :destroy", body
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
test "the spec controller should include only the index action" do
|
44
|
+
run_generator %w(users index)
|
45
|
+
|
46
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
47
|
+
assert_match /get :index/, body
|
48
|
+
assert_no_match /get :show/, body
|
49
|
+
assert_no_match /get :new/, body
|
50
|
+
assert_no_match /post :create/, body
|
51
|
+
assert_no_match /get :edit/, body
|
52
|
+
assert_no_match /put :update/, body
|
53
|
+
assert_no_match /delete :destroy/, body
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
test "the spec controller should include only the show action" do
|
58
|
+
run_generator %w(users show)
|
59
|
+
|
60
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
61
|
+
assert_no_match /get :index/, body
|
62
|
+
assert_match /get :show/, body
|
63
|
+
assert_no_match /get :new/, body
|
64
|
+
assert_no_match /post :create/, body
|
65
|
+
assert_no_match /get :edit/, body
|
66
|
+
assert_no_match /put :update/, body
|
67
|
+
assert_no_match /delete :destroy/, body
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
test "the spec controller should include only new and create actions" do
|
72
|
+
run_generator %w(users new)
|
73
|
+
|
74
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
75
|
+
assert_no_match /get :index/, body
|
76
|
+
assert_no_match /get :show/, body
|
77
|
+
assert_match /get :new/, body
|
78
|
+
assert_match /post :create/, body
|
79
|
+
assert_no_match /get :edit/, body
|
80
|
+
assert_no_match /put :update/, body
|
81
|
+
assert_no_match /delete :destroy/, body
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
test "the spec controller should include only the create action" do
|
86
|
+
run_generator %w(users create)
|
87
|
+
|
88
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
89
|
+
assert_no_match /get :index/, body
|
90
|
+
assert_no_match /get :show/, body
|
91
|
+
assert_no_match /get :new/, body
|
92
|
+
assert_match /post :create/, body
|
93
|
+
assert_no_match /get :edit/, body
|
94
|
+
assert_no_match /put :update/, body
|
95
|
+
assert_no_match /delete :destroy/, body
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
test "the spec controller should include only edit and update action" do
|
100
|
+
run_generator %w(users edit)
|
101
|
+
|
102
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
103
|
+
assert_no_match /get :index/, body
|
104
|
+
assert_no_match /get :show/, body
|
105
|
+
assert_no_match /get :new/, body
|
106
|
+
assert_no_match /post :create/, body
|
107
|
+
assert_match /get :edit/, body
|
108
|
+
assert_match /put :update/, body
|
109
|
+
assert_no_match /delete :destroy/, body
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
test "the spec controller should include only the update action" do
|
114
|
+
run_generator %w(users update)
|
115
|
+
|
116
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
117
|
+
assert_no_match /get :index/, body
|
118
|
+
assert_no_match /get :show/, body
|
119
|
+
assert_no_match /get :new/, body
|
120
|
+
assert_no_match /post :create/, body
|
121
|
+
assert_no_match /get :edit/, body
|
122
|
+
assert_match /put :update/, body
|
123
|
+
assert_no_match /delete :destroy/, body
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
test "the spec controller should include only the destroy action" do
|
128
|
+
run_generator %w(users destroy)
|
129
|
+
|
130
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
131
|
+
assert_no_match /get :index/, body
|
132
|
+
assert_no_match /get :show/, body
|
133
|
+
assert_no_match /get :new/, body
|
134
|
+
assert_no_match /post :create/, body
|
135
|
+
assert_no_match /get :edit/, body
|
136
|
+
assert_no_match /put :update/, body
|
137
|
+
assert_match /delete :destroy/, body
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
test "the spec controller should include only index new create actions" do
|
142
|
+
run_generator %w(users index new actual)
|
143
|
+
|
144
|
+
assert_file "spec/controllers/users_controller_spec.rb" do |body|
|
145
|
+
assert_match /get :index/, body
|
146
|
+
assert_no_match /get :show/, body
|
147
|
+
assert_match /get :new/, body
|
148
|
+
assert_match /post :create/, body
|
149
|
+
assert_no_match /get :edit/, body
|
150
|
+
assert_no_match /put :update/, body
|
151
|
+
assert_no_match /delete :destroy/, body
|
152
|
+
assert_no_match /get :actual/, body
|
153
|
+
end
|
154
|
+
end
|
28
155
|
end
|
29
156
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crudspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Padilla
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-29 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -65,7 +65,16 @@ files:
|
|
65
65
|
- crudspec.gemspec
|
66
66
|
- lib/crudspec.rb
|
67
67
|
- lib/crudspec/version.rb
|
68
|
+
- lib/generators/.DS_Store
|
68
69
|
- lib/generators/spec_generator.rb
|
70
|
+
- lib/generators/templates/.DS_Store
|
71
|
+
- lib/generators/templates/actions/create.rb
|
72
|
+
- lib/generators/templates/actions/destroy.rb
|
73
|
+
- lib/generators/templates/actions/edit.rb
|
74
|
+
- lib/generators/templates/actions/index.rb
|
75
|
+
- lib/generators/templates/actions/new.rb
|
76
|
+
- lib/generators/templates/actions/show.rb
|
77
|
+
- lib/generators/templates/actions/update.rb
|
69
78
|
- lib/generators/templates/controller_spec.rb
|
70
79
|
- test/generators/test_spec_generator.rb
|
71
80
|
- test/test_helper.rb
|