rspec-rails 3.5.2 → 3.6.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +11 -1
- data/README.md +3 -2
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +7 -68
- data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +165 -0
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +17 -51
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +4 -0
- data/lib/rspec-rails.rb +4 -0
- data/lib/rspec/rails/version.rb +1 -1
- metadata +22 -21
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ebf54e513b2bfad6ffe14c36afa43056012db04
|
4
|
+
data.tar.gz: 9418672e115bde33c829fa68f68d2c44af25be19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8716e97798de2b89ae70a4602bc635957af4bb4e0350ee9e8a1396c23eb978093ed6076c4786793cee571c5874a3fd84659edf98f69f521fd2461c18dc45b89e
|
7
|
+
data.tar.gz: 24f17af3d57c74e592fece81e6af00b0588dee7f9a5d5e279e95bde85d4ddbe341512ea997fe110166bb027da087b1e0de46c088628d4cdc2a3cfffa68c0a0d0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
###
|
1
|
+
### 3.6.0.beta1 / 2016-10-09
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.5.2...v3.6.0.beta1)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Add support for `rake notes` in Rails `>= 5.1`. (John Meehan, #1661)
|
7
|
+
* Remove `assigns` and `assert_template` from scaffold spec generators (Josh
|
8
|
+
Justice, #1689)
|
9
|
+
* Add support for generating scaffolds for api app specs. (Krzysztof Zych, #1685)
|
10
|
+
|
11
|
+
### 3.5.2 / 2016-08-26
|
2
12
|
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.5.1...v3.5.2)
|
3
13
|
|
4
14
|
Bug Fixes:
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# rspec-rails [![Build Status](https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=master)](http://travis-ci.org/rspec/rspec-rails) [![Code Climate](https://img.shields.io/codeclimate/github/rspec/rspec-rails.svg)](https://codeclimate.com/github/rspec/rspec-rails)
|
2
|
-
**rspec-rails** is a testing framework for Rails 3.x
|
2
|
+
**rspec-rails** is a testing framework for Rails 3.x, 4.x and 5.0.
|
3
3
|
|
4
4
|
Use **[rspec-rails 1.x](http://github.com/dchelimsky/rspec-rails)** for Rails
|
5
5
|
2.x.
|
@@ -11,7 +11,7 @@ Add `rspec-rails` to **both** the `:development` and `:test` groups in the
|
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
group :development, :test do
|
14
|
-
gem 'rspec-rails', '~> 3.
|
14
|
+
gem 'rspec-rails', '~> 3.5'
|
15
15
|
end
|
16
16
|
```
|
17
17
|
|
@@ -86,6 +86,7 @@ There are three particular `rspec-rails` specific changes to be aware of:
|
|
86
86
|
3. [Rails 4.x `ActiveRecord::Migration` pending migration checks](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#pending-migration-checks)
|
87
87
|
4. Extraction of `stub_model` and `mock_model` to
|
88
88
|
[`rspec-activemodel-mocks`](https://github.com/rspec/rspec-activemodel-mocks)
|
89
|
+
5. In Rails 5.x, controller testing has been moved to its own gem which is [rails-controller-testing](https://github.com/rails/rails-controller-testing). Using `assigns` in your controller specs without adding this gem will no longer work.
|
89
90
|
|
90
91
|
Please see the [RSpec Rails Upgrade
|
91
92
|
docs](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade) for full
|
@@ -12,6 +12,7 @@ module Rspec
|
|
12
12
|
class_option :orm, :desc => "ORM used to generate the controller"
|
13
13
|
class_option :template_engine, :desc => "Template engine to generate view files"
|
14
14
|
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
|
15
|
+
class_option :api, :type => :boolean, :desc => "Skip specs unnecessary for API-only apps"
|
15
16
|
|
16
17
|
class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
|
17
18
|
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
|
@@ -26,10 +27,15 @@ module Rspec
|
|
26
27
|
controller_class_path,
|
27
28
|
"#{controller_file_name}_controller_spec.rb"
|
28
29
|
)
|
29
|
-
|
30
|
+
if options[:api]
|
31
|
+
template 'api_controller_spec.rb', template_file
|
32
|
+
else
|
33
|
+
template 'controller_spec.rb', template_file
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
def generate_view_specs
|
38
|
+
return if options[:api]
|
33
39
|
return unless options[:view_specs] && options[:template_engine]
|
34
40
|
|
35
41
|
copy_view :edit
|
@@ -58,14 +64,6 @@ module Rspec
|
|
58
64
|
File.join("spec/views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
|
59
65
|
end
|
60
66
|
|
61
|
-
def formatted_hash(hash)
|
62
|
-
formatted = hash.inspect
|
63
|
-
formatted.gsub!("{", "{ ")
|
64
|
-
formatted.gsub!("}", " }")
|
65
|
-
formatted.gsub!("=>", " => ")
|
66
|
-
formatted
|
67
|
-
end
|
68
|
-
|
69
67
|
# support for namespaced-resources
|
70
68
|
def ns_file_name
|
71
69
|
ns_parts.empty? ? file_name : "#{ns_parts[0].underscore}_#{ns_parts[1].singularize.underscore}"
|
@@ -83,65 +81,6 @@ module Rspec
|
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
86
|
-
# Returns the name of the mock. For example, if the file name is user,
|
87
|
-
# it returns mock_user.
|
88
|
-
#
|
89
|
-
# If a hash is given, it uses the hash key as the ORM method and the
|
90
|
-
# value as response. So, for ActiveRecord and file name "User":
|
91
|
-
#
|
92
|
-
# mock_file_name(:save => true)
|
93
|
-
# #=> mock_user(:save => true)
|
94
|
-
#
|
95
|
-
# If another ORM is being used and another method instead of save is
|
96
|
-
# called, it will be the one used.
|
97
|
-
#
|
98
|
-
def mock_file_name(hash = nil)
|
99
|
-
if hash
|
100
|
-
method, and_return = hash.to_a.first
|
101
|
-
method = orm_instance.send(method).split('.').last.gsub(/\(.*?\)/, '')
|
102
|
-
"mock_#{ns_file_name}(:#{method} => #{and_return})"
|
103
|
-
else
|
104
|
-
"mock_#{ns_file_name}"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Receives the ORM chain and convert to expects. For ActiveRecord:
|
109
|
-
#
|
110
|
-
# should! orm_class.find(User, "37")
|
111
|
-
# #=> User.should_receive(:find).with(37)
|
112
|
-
#
|
113
|
-
# For Datamapper:
|
114
|
-
#
|
115
|
-
# should! orm_class.find(User, "37")
|
116
|
-
# #=> User.should_receive(:get).with(37)
|
117
|
-
#
|
118
|
-
def should_receive(chain)
|
119
|
-
stub_or_should_chain(:should_receive, chain)
|
120
|
-
end
|
121
|
-
|
122
|
-
# Receives the ORM chain and convert to stub. For ActiveRecord:
|
123
|
-
#
|
124
|
-
# stub orm_class.find(User, "37")
|
125
|
-
# #=> User.stub(:find).with(37)
|
126
|
-
#
|
127
|
-
# For Datamapper:
|
128
|
-
#
|
129
|
-
# stub orm_class.find(User, "37")
|
130
|
-
# #=> User.stub(:get).with(37)
|
131
|
-
#
|
132
|
-
def stub(chain)
|
133
|
-
stub_or_should_chain(:stub, chain)
|
134
|
-
end
|
135
|
-
|
136
|
-
def stub_or_should_chain(mode, chain)
|
137
|
-
receiver, method = chain.split(".")
|
138
|
-
method.gsub!(/\((.*?)\)/, '')
|
139
|
-
|
140
|
-
response = "#{receiver}.#{mode}(:#{method})"
|
141
|
-
response << ".with(#{$1})" unless $1.blank?
|
142
|
-
response
|
143
|
-
end
|
144
|
-
|
145
84
|
def value_for(attribute)
|
146
85
|
raw_value_for(attribute).inspect
|
147
86
|
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
6
|
+
#
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
9
|
+
# controller code, this generated spec may or may not pass.
|
10
|
+
#
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
14
|
+
#
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
19
|
+
# that an instance is receiving a specific message.
|
20
|
+
#
|
21
|
+
# Also compared to earlier versions of this generator, there are no longer any
|
22
|
+
# expectations of assigns and templates rendered. These features have been
|
23
|
+
# removed from Rails core in Rails 5, but can be added back in via the
|
24
|
+
# `rails-controller-testing` gem.
|
25
|
+
|
26
|
+
<% module_namespacing do -%>
|
27
|
+
RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:controller) %> do
|
28
|
+
|
29
|
+
# This should return the minimal set of attributes required to create a valid
|
30
|
+
# <%= class_name %>. As you add validations to <%= class_name %>, be sure to
|
31
|
+
# adjust the attributes here as well.
|
32
|
+
let(:valid_attributes) {
|
33
|
+
skip("Add a hash of attributes valid for your model")
|
34
|
+
}
|
35
|
+
|
36
|
+
let(:invalid_attributes) {
|
37
|
+
skip("Add a hash of attributes invalid for your model")
|
38
|
+
}
|
39
|
+
|
40
|
+
# This should return the minimal set of values that should be in the session
|
41
|
+
# in order to pass any filters (e.g. authentication) defined in
|
42
|
+
# <%= controller_class_name %>Controller. Be sure to keep this updated too.
|
43
|
+
let(:valid_session) { {} }
|
44
|
+
|
45
|
+
<% unless options[:singleton] -%>
|
46
|
+
describe "GET #index" do
|
47
|
+
it "returns a success response" do
|
48
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
49
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
50
|
+
get :index, {}, valid_session
|
51
|
+
<% else -%>
|
52
|
+
get :index, params: {}, session: valid_session
|
53
|
+
<% end -%>
|
54
|
+
expect(response).to be_success
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
<% end -%>
|
59
|
+
describe "GET #show" do
|
60
|
+
it "returns a success response" do
|
61
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
62
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
63
|
+
get :show, {:id => <%= file_name %>.to_param}, valid_session
|
64
|
+
<% else -%>
|
65
|
+
get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
|
66
|
+
<% end -%>
|
67
|
+
expect(response).to be_success
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "POST #create" do
|
72
|
+
context "with valid params" do
|
73
|
+
it "creates a new <%= class_name %>" do
|
74
|
+
expect {
|
75
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
76
|
+
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
|
77
|
+
<% else -%>
|
78
|
+
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
|
79
|
+
<% end -%>
|
80
|
+
}.to change(<%= class_name %>, :count).by(1)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "renders a JSON response with the new <%= ns_file_name %>" do
|
84
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
85
|
+
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
|
86
|
+
<% else %>
|
87
|
+
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
|
88
|
+
<% end -%>
|
89
|
+
expect(response).to have_http_status(:created)
|
90
|
+
expect(response.content_type).to eq('application/json')
|
91
|
+
expect(response.location).to eq(<%= ns_file_name %>_url(<%= class_name %>.last))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "with invalid params" do
|
96
|
+
it "renders a JSON response with errors for the new <%= ns_file_name %>" do
|
97
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
98
|
+
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
|
99
|
+
<% else %>
|
100
|
+
post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
|
101
|
+
<% end -%>
|
102
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
103
|
+
expect(response.content_type).to eq('application/json')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "PUT #update" do
|
109
|
+
context "with valid params" do
|
110
|
+
let(:new_attributes) {
|
111
|
+
skip("Add a hash of attributes valid for your model")
|
112
|
+
}
|
113
|
+
|
114
|
+
it "updates the requested <%= ns_file_name %>" do
|
115
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
116
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
117
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
|
118
|
+
<% else -%>
|
119
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
|
120
|
+
<% end -%>
|
121
|
+
<%= file_name %>.reload
|
122
|
+
skip("Add assertions for updated state")
|
123
|
+
end
|
124
|
+
|
125
|
+
it "renders a JSON response with the <%= ns_file_name %>" do
|
126
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
127
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
128
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
|
129
|
+
<% else %>
|
130
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
|
131
|
+
<% end -%>
|
132
|
+
expect(response).to have_http_status(:ok)
|
133
|
+
expect(response.content_type).to eq('application/json')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "with invalid params" do
|
138
|
+
it "renders a JSON response with errors for the <%= ns_file_name %>" do
|
139
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
140
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
141
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
|
142
|
+
<% else %>
|
143
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
|
144
|
+
<% end -%>
|
145
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
146
|
+
expect(response.content_type).to eq('application/json')
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "DELETE #destroy" do
|
152
|
+
it "destroys the requested <%= ns_file_name %>" do
|
153
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
154
|
+
expect {
|
155
|
+
<% if RUBY_VERSION < '1.9.3' -%>
|
156
|
+
delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
|
157
|
+
<% else -%>
|
158
|
+
delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
|
159
|
+
<% end -%>
|
160
|
+
}.to change(<%= class_name %>, :count).by(-1)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
<% end -%>
|
@@ -17,6 +17,11 @@ require 'rails_helper'
|
|
17
17
|
# is no simpler way to get a handle on the object needed for the example.
|
18
18
|
# Message expectations are only used when there is no simpler way to specify
|
19
19
|
# that an instance is receiving a specific message.
|
20
|
+
#
|
21
|
+
# Also compared to earlier versions of this generator, there are no longer any
|
22
|
+
# expectations of assigns and templates rendered. These features have been
|
23
|
+
# removed from Rails core in Rails 5, but can be added back in via the
|
24
|
+
# `rails-controller-testing` gem.
|
20
25
|
|
21
26
|
<% module_namespacing do -%>
|
22
27
|
RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:controller) %> do
|
@@ -39,50 +44,50 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
39
44
|
|
40
45
|
<% unless options[:singleton] -%>
|
41
46
|
describe "GET #index" do
|
42
|
-
it "
|
47
|
+
it "returns a success response" do
|
43
48
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
44
49
|
<% if RUBY_VERSION < '1.9.3' -%>
|
45
50
|
get :index, {}, valid_session
|
46
51
|
<% else -%>
|
47
52
|
get :index, params: {}, session: valid_session
|
48
53
|
<% end -%>
|
49
|
-
expect(
|
54
|
+
expect(response).to be_success
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
53
58
|
<% end -%>
|
54
59
|
describe "GET #show" do
|
55
|
-
it "
|
60
|
+
it "returns a success response" do
|
56
61
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
57
62
|
<% if RUBY_VERSION < '1.9.3' -%>
|
58
63
|
get :show, {:id => <%= file_name %>.to_param}, valid_session
|
59
64
|
<% else -%>
|
60
65
|
get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
|
61
66
|
<% end -%>
|
62
|
-
expect(
|
67
|
+
expect(response).to be_success
|
63
68
|
end
|
64
69
|
end
|
65
70
|
|
66
71
|
describe "GET #new" do
|
67
|
-
it "
|
72
|
+
it "returns a success response" do
|
68
73
|
<% if RUBY_VERSION < '1.9.3' -%>
|
69
74
|
get :new, {}, valid_session
|
70
75
|
<% else -%>
|
71
76
|
get :new, params: {}, session: valid_session
|
72
77
|
<% end -%>
|
73
|
-
expect(
|
78
|
+
expect(response).to be_success
|
74
79
|
end
|
75
80
|
end
|
76
81
|
|
77
82
|
describe "GET #edit" do
|
78
|
-
it "
|
83
|
+
it "returns a success response" do
|
79
84
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
80
85
|
<% if RUBY_VERSION < '1.9.3' -%>
|
81
86
|
get :edit, {:id => <%= file_name %>.to_param}, valid_session
|
82
87
|
<% else -%>
|
83
88
|
get :edit, params: {id: <%= file_name %>.to_param}, session: valid_session
|
84
89
|
<% end -%>
|
85
|
-
expect(
|
90
|
+
expect(response).to be_success
|
86
91
|
end
|
87
92
|
end
|
88
93
|
|
@@ -98,16 +103,6 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
98
103
|
}.to change(<%= class_name %>, :count).by(1)
|
99
104
|
end
|
100
105
|
|
101
|
-
it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
|
102
|
-
<% if RUBY_VERSION < '1.9.3' -%>
|
103
|
-
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
|
104
|
-
<% else -%>
|
105
|
-
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
|
106
|
-
<% end -%>
|
107
|
-
expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
|
108
|
-
expect(assigns(:<%= ns_file_name %>)).to be_persisted
|
109
|
-
end
|
110
|
-
|
111
106
|
it "redirects to the created <%= ns_file_name %>" do
|
112
107
|
<% if RUBY_VERSION < '1.9.3' -%>
|
113
108
|
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
|
@@ -119,22 +114,13 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
119
114
|
end
|
120
115
|
|
121
116
|
context "with invalid params" do
|
122
|
-
it "
|
117
|
+
it "returns a success response (i.e. to display the 'new' template)" do
|
123
118
|
<% if RUBY_VERSION < '1.9.3' -%>
|
124
119
|
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
|
125
120
|
<% else -%>
|
126
121
|
post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
|
127
122
|
<% end -%>
|
128
|
-
expect(
|
129
|
-
end
|
130
|
-
|
131
|
-
it "re-renders the 'new' template" do
|
132
|
-
<% if RUBY_VERSION < '1.9.3' -%>
|
133
|
-
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
|
134
|
-
<% else -%>
|
135
|
-
post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
|
136
|
-
<% end -%>
|
137
|
-
expect(response).to render_template("new")
|
123
|
+
expect(response).to be_success
|
138
124
|
end
|
139
125
|
end
|
140
126
|
end
|
@@ -156,16 +142,6 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
156
142
|
skip("Add assertions for updated state")
|
157
143
|
end
|
158
144
|
|
159
|
-
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
160
|
-
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
161
|
-
<% if RUBY_VERSION < '1.9.3' -%>
|
162
|
-
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
|
163
|
-
<% else -%>
|
164
|
-
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
|
165
|
-
<% end -%>
|
166
|
-
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
167
|
-
end
|
168
|
-
|
169
145
|
it "redirects to the <%= ns_file_name %>" do
|
170
146
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
171
147
|
<% if RUBY_VERSION < '1.9.3' -%>
|
@@ -178,24 +154,14 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
178
154
|
end
|
179
155
|
|
180
156
|
context "with invalid params" do
|
181
|
-
it "
|
182
|
-
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
183
|
-
<% if RUBY_VERSION < '1.9.3' -%>
|
184
|
-
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
|
185
|
-
<% else -%>
|
186
|
-
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
|
187
|
-
<% end -%>
|
188
|
-
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
189
|
-
end
|
190
|
-
|
191
|
-
it "re-renders the 'edit' template" do
|
157
|
+
it "returns a success response (i.e. to display the 'edit' template)" do
|
192
158
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
193
159
|
<% if RUBY_VERSION < '1.9.3' -%>
|
194
160
|
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
|
195
161
|
<% else -%>
|
196
162
|
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
|
197
163
|
<% end -%>
|
198
|
-
expect(response).to
|
164
|
+
expect(response).to be_success
|
199
165
|
end
|
200
166
|
end
|
201
167
|
end
|
@@ -10,17 +10,21 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:routing
|
|
10
10
|
end
|
11
11
|
|
12
12
|
<% end -%>
|
13
|
+
<% unless options[:api] -%>
|
13
14
|
it "routes to #new" do
|
14
15
|
expect(:get => "/<%= ns_table_name %>/new").to route_to("<%= ns_table_name %>#new")
|
15
16
|
end
|
17
|
+
<% end -%>
|
16
18
|
|
17
19
|
it "routes to #show" do
|
18
20
|
expect(:get => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#show", :id => "1")
|
19
21
|
end
|
20
22
|
|
23
|
+
<% unless options[:api] -%>
|
21
24
|
it "routes to #edit" do
|
22
25
|
expect(:get => "/<%= ns_table_name %>/1/edit").to route_to("<%= ns_table_name %>#edit", :id => "1")
|
23
26
|
end
|
27
|
+
<% end -%>
|
24
28
|
|
25
29
|
it "routes to #create" do
|
26
30
|
expect(:post => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create")
|
data/lib/rspec-rails.rb
CHANGED
@@ -6,6 +6,10 @@ module RSpec
|
|
6
6
|
module Rails
|
7
7
|
# Railtie to hook into Rails.
|
8
8
|
class Railtie < ::Rails::Railtie
|
9
|
+
# As of Rails 5.1.0 you can register directories to work with `rake notes`
|
10
|
+
if ::Rails::VERSION::STRING >= '5.1'
|
11
|
+
SourceAnnotationExtractor::Annotation.register_directories("spec")
|
12
|
+
end
|
9
13
|
# Rails-3.0.1 requires config.app_generators instead of 3.0.0's config.generators
|
10
14
|
generators = config.respond_to?(:app_generators) ? config.app_generators : config.generators
|
11
15
|
generators.integration_tool :rspec
|
data/lib/rspec/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chelimsky
|
@@ -44,7 +44,7 @@ cert_chain:
|
|
44
44
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
45
45
|
F3MdtaDehhjC
|
46
46
|
-----END CERTIFICATE-----
|
47
|
-
date: 2016-
|
47
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
48
48
|
dependencies:
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: activesupport
|
@@ -92,58 +92,58 @@ dependencies:
|
|
92
92
|
name: rspec-core
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - '='
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 3.
|
97
|
+
version: 3.6.0.beta1
|
98
98
|
type: :runtime
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - '='
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 3.
|
104
|
+
version: 3.6.0.beta1
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: rspec-expectations
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - '='
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 3.
|
111
|
+
version: 3.6.0.beta1
|
112
112
|
type: :runtime
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - '='
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 3.
|
118
|
+
version: 3.6.0.beta1
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
120
|
name: rspec-mocks
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - '='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 3.
|
125
|
+
version: 3.6.0.beta1
|
126
126
|
type: :runtime
|
127
127
|
prerelease: false
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - '='
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 3.
|
132
|
+
version: 3.6.0.beta1
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: rspec-support
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- -
|
137
|
+
- - '='
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 3.
|
139
|
+
version: 3.6.0.beta1
|
140
140
|
type: :runtime
|
141
141
|
prerelease: false
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- -
|
144
|
+
- - '='
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: 3.
|
146
|
+
version: 3.6.0.beta1
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: cucumber
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -224,6 +224,7 @@ files:
|
|
224
224
|
- lib/generators/rspec/observer/templates/observer_spec.rb
|
225
225
|
- lib/generators/rspec/request/request_generator.rb
|
226
226
|
- lib/generators/rspec/scaffold/scaffold_generator.rb
|
227
|
+
- lib/generators/rspec/scaffold/templates/api_controller_spec.rb
|
227
228
|
- lib/generators/rspec/scaffold/templates/controller_spec.rb
|
228
229
|
- lib/generators/rspec/scaffold/templates/edit_spec.rb
|
229
230
|
- lib/generators/rspec/scaffold/templates/index_spec.rb
|
@@ -286,12 +287,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
286
287
|
version: '0'
|
287
288
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
288
289
|
requirements:
|
289
|
-
- - "
|
290
|
+
- - ">"
|
290
291
|
- !ruby/object:Gem::Version
|
291
|
-
version:
|
292
|
+
version: 1.3.1
|
292
293
|
requirements: []
|
293
294
|
rubyforge_project:
|
294
|
-
rubygems_version: 2.
|
295
|
+
rubygems_version: 2.2.2
|
295
296
|
signing_key:
|
296
297
|
specification_version: 4
|
297
298
|
summary: RSpec for Rails
|
metadata.gz.sig
CHANGED
Binary file
|