rspec-rails 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +27 -0
  5. data/README.md +12 -3
  6. data/lib/generators/rspec.rb +2 -0
  7. data/lib/generators/rspec/controller/templates/controller_spec.rb +2 -2
  8. data/lib/generators/rspec/controller/templates/view_spec.rb +1 -1
  9. data/lib/generators/rspec/feature/templates/feature_spec.rb +1 -1
  10. data/lib/generators/rspec/helper/templates/helper_spec.rb +1 -1
  11. data/lib/generators/rspec/install/templates/spec/rails_helper.rb +3 -3
  12. data/lib/generators/rspec/integration/templates/request_spec.rb +1 -1
  13. data/lib/generators/rspec/job/templates/job_spec.rb.erb +1 -1
  14. data/lib/generators/rspec/mailer/mailer_generator.rb +6 -0
  15. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +1 -1
  16. data/lib/generators/rspec/mailer/templates/preview.rb +13 -0
  17. data/lib/generators/rspec/model/templates/model_spec.rb +1 -1
  18. data/lib/generators/rspec/observer/templates/observer_spec.rb +1 -1
  19. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +12 -12
  20. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
  21. data/lib/generators/rspec/scaffold/templates/index_spec.rb +1 -1
  22. data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
  23. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +1 -1
  24. data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
  25. data/lib/generators/rspec/view/templates/view_spec.rb +1 -1
  26. data/lib/rspec-rails.rb +33 -0
  27. data/lib/rspec/rails.rb +6 -1
  28. data/lib/rspec/rails/active_record.rb +21 -0
  29. data/lib/rspec/rails/adapters.rb +39 -0
  30. data/lib/rspec/rails/example/controller_example_group.rb +1 -1
  31. data/lib/rspec/rails/example/feature_example_group.rb +37 -0
  32. data/lib/rspec/rails/feature_check.rb +20 -0
  33. data/lib/rspec/rails/matchers.rb +0 -11
  34. data/lib/rspec/rails/version.rb +1 -1
  35. metadata +63 -31
  36. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7082373e70e8e1b7a77e4a29acde414d3a0f88d
4
- data.tar.gz: 0a6fd867ecf7f7d201e2b6f8d3ebaaef7357b6bd
3
+ metadata.gz: 027f378aa2e20a95523b0a2c7db67603858cab97
4
+ data.tar.gz: 767ac26b5cac44dc1be51ff6e053d2492235d3d4
5
5
  SHA512:
6
- metadata.gz: edae3eef56dee24c9ef3b6aa78e971ac353c83058a38a9bbc05efb7da6cd8ed00b89f4add64f54c5d606cf88b4df8ba0846d9315f966b4dc0709583bf51b1b50
7
- data.tar.gz: ac61c06796d8788ba676bb95d1ee3551b727e4757e1b78c2bbecfdba86551fb4bfbc9d141c594f42a03ed6c8008009dea09237ea1ba2b75d3440a809ad2256c6
6
+ metadata.gz: 629452b4ef924f97a6b036b462476254b6dad7962f1a44dfc44110f8fea02cca43b4fb52a9a0a6391b0a7ef163ea36248d9df277a63161c6d4fb0f0a83d5cb12
7
+ data.tar.gz: e800239d5939a807e15cd4082a4b1277878886fb7fe5f5d8633b335e5f935e5cffabaaf877fc4a6a3fa7445cf907670f5368cb48be1430b228c9e0cc522483cc
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,28 @@
1
+ ### 3.2.0 / 2015-02-03
2
+ [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.1.0...v3.2.0)
3
+
4
+ Enhancements:
5
+
6
+ * Include generator for `ActionMailer` mailer previews (Takashi Nakagawa, #1185)
7
+ * Configure the `ActionMailer` preview path via a Railtie (Aaron Kromer, #1236)
8
+ * Show all RSpec generators when running `rails generate` (Eliot Sykes, #1248)
9
+ * Support Ruby 2.2 with Rails 3.2 and 4.x (Aaron Kromer, #1264, #1277)
10
+ * Improve `instance_double` to support verifying dynamic column methods defined
11
+ by `ActiveRecord` (Jon Rowe, #1238)
12
+ * Mirror the use of Ruby 1.9 hash syntax for the `type` tags in the spec
13
+ generators on Rails 4. (Michael Stock, #1292)
14
+
15
+ Bug Fixes:
16
+
17
+ * Fix `rspec:feature` generator to use `RSpec` namespace preventing errors when
18
+ monkey-patching is disabled. (Rebecca Skinner, #1231)
19
+ * Fix `NoMethodError` caused by calling `RSpec.feature` when Capybara is not
20
+ available or the Capybara version is < 2.4.0. (Aaron Kromer, #1261)
21
+ * Fix `ArgumentError` when using an anonymous controller which inherits an
22
+ outer group's anonymous controller. (Yuji Nakayama, #1260)
23
+ * Fix "Test is not a class (TypeError)" error when using a custom `Test` class
24
+ in Rails 4.1 and 4.2. (Aaron Kromer, #1295)
25
+
1
26
  ### 3.1.0 / 2014-09-04
2
27
  [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.0.2...v3.1.0)
3
28
 
@@ -10,6 +35,8 @@ Enhancements:
10
35
  * Improve support for non-ActiveRecord apps by not loading ActiveRecord related
11
36
  settings in the generated `rails_helper`. (Aaron Kromer, #1150)
12
37
  * Remove Ruby warnings as a suggested configuration. (Aaron Kromer, #1163)
38
+ * Improve the semantics of the controller spec for scaffolds. (Griffin Smith, #1204)
39
+ * Use `#method` syntax in all generated controller specs. (Griffin Smith, #1206)
13
40
 
14
41
  Bug Fixes:
15
42
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rspec-rails [![Build Status](https://secure.travis-ci.org/rspec/rspec-rails.png?branch=master)](http://travis-ci.org/rspec/rspec-rails) [![Code Climate](https://codeclimate.com/github/rspec/rspec-rails.png)](https://codeclimate.com/github/rspec/rspec-rails)
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
2
  **rspec-rails** is a testing framework for Rails 3.x and 4.x.
3
3
 
4
4
  Use **[rspec-rails 1.x](http://github.com/dchelimsky/rspec-rails)** for Rails
@@ -11,7 +11,16 @@ 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.0.0'
14
+ gem 'rspec-rails', '~> 3.0'
15
+ end
16
+ ```
17
+
18
+ Want to run against the `master` branch? You'll need to include the dependent
19
+ RSpec repos as well. Add the following to your `Gemfile`:
20
+
21
+ ```ruby
22
+ %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
23
+ gem lib, :git => "git://github.com/rspec/#{lib}.git", :branch => 'master'
15
24
  end
16
25
  ```
17
26
 
@@ -203,7 +212,7 @@ RSpec.describe "home page", :type => :request do
203
212
  end
204
213
  ```
205
214
 
206
- The above example uses only standard Rails and RSpec API's, but many
215
+ The above example uses only standard Rails and RSpec APIs, but many
207
216
  RSpec/Rails users like to use extension libraries like
208
217
  [FactoryGirl](https://github.com/thoughtbot/factory_girl) and
209
218
  [Capybara](https://github.com/jnicklas/capybara):
@@ -7,6 +7,8 @@ module Rspec
7
7
  module Generators
8
8
  # @private
9
9
  class Base < ::Rails::Generators::NamedBase
10
+ include RSpec::Rails::FeatureCheck
11
+
10
12
  def self.source_root(path = nil)
11
13
  if path
12
14
  @_rspec_source_root = path
@@ -1,10 +1,10 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= class_name %>Controller, :type => :controller do
4
+ RSpec.describe <%= class_name %>Controller, <%= type_metatag(:controller) %> do
5
5
 
6
6
  <% for action in actions -%>
7
- describe "GET <%= action %>" do
7
+ describe "GET #<%= action %>" do
8
8
  it "returns http success" do
9
9
  get :<%= action %>
10
10
  expect(response).to have_http_status(:success)
@@ -1,5 +1,5 @@
1
1
  require 'rails_helper'
2
2
 
3
- RSpec.describe "<%= file_name %>/<%= @action %>.html.<%= options[:template_engine] %>", :type => :view do
3
+ RSpec.describe "<%= file_name %>/<%= @action %>.html.<%= options[:template_engine] %>", <%= type_metatag(:view) %> do
4
4
  pending "add some examples to (or delete) #{__FILE__}"
5
5
  end
@@ -1,5 +1,5 @@
1
1
  require 'rails_helper'
2
2
 
3
- feature "<%= class_name.pluralize %>", :type => :feature do
3
+ RSpec.feature "<%= class_name.pluralize %>", <%= type_metatag(:feature) %> do
4
4
  pending "add some scenarios (or delete) #{__FILE__}"
5
5
  end
@@ -11,7 +11,7 @@ require 'rails_helper'
11
11
  # end
12
12
  # end
13
13
  <% module_namespacing do -%>
14
- RSpec.describe <%= class_name %>Helper, :type => :helper do
14
+ RSpec.describe <%= class_name %>Helper, <%= type_metatag(:helper) %> do
15
15
  pending "add some examples to (or delete) #{__FILE__}"
16
16
  end
17
17
  <% end -%>
@@ -1,7 +1,7 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
3
  require 'spec_helper'
4
- require File.expand_path("../../config/environment", __FILE__)
4
+ require File.expand_path('../../config/environment', __FILE__)
5
5
  require 'rspec/rails'
6
6
  # Add additional requires below this line. Rails is not loaded until this point!
7
7
 
@@ -18,7 +18,7 @@ require 'rspec/rails'
18
18
  # directory. Alternatively, in the individual `*_spec.rb` files, manually
19
19
  # require only the support files necessary.
20
20
  #
21
- # Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
21
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
22
22
 
23
23
  <% if RSpec::Rails::FeatureCheck.can_maintain_test_schema? -%>
24
24
  # Checks for pending migrations before tests are run.
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- RSpec.describe "<%= class_name.pluralize %>", :type => :request do
3
+ RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
4
4
  describe "GET /<%= table_name %>" do
5
5
  it "works! (now write some real specs)" do
6
6
  get <%= index_helper %>_path
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= class_name %>Job, :type => :job do
4
+ RSpec.describe <%= class_name %>Job, <%= type_metatag(:job) %> do
5
5
  pending "add some examples to (or delete) #{__FILE__}"
6
6
  end
7
7
  <% end -%>
@@ -1,4 +1,5 @@
1
1
  require 'generators/rspec'
2
+ require "rspec/rails/feature_check"
2
3
 
3
4
  module Rspec
4
5
  module Generators
@@ -16,6 +17,11 @@ module Rspec
16
17
  template "fixture", File.join("spec/fixtures", @path)
17
18
  end
18
19
  end
20
+
21
+ def generate_preview_files
22
+ return unless RSpec::Rails::FeatureCheck.has_action_mailer_preview?
23
+ template "preview.rb", File.join("spec/mailers/previews", class_path, "#{file_name}_preview.rb")
24
+ end
19
25
  end
20
26
  end
21
27
  end
@@ -1,7 +1,7 @@
1
1
  require "rails_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= class_name %>, :type => :mailer do
4
+ RSpec.describe <%= class_name %>, <%= type_metatag(:mailer) %> do
5
5
  <% for action in actions -%>
6
6
  describe "<%= action %>" do
7
7
  let(:mail) { <%= class_name %>.<%= action %> }
@@ -0,0 +1,13 @@
1
+ <% module_namespacing do -%>
2
+ # Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>
3
+ class <%= class_name %>Preview < ActionMailer::Preview
4
+ <% actions.each do |action| -%>
5
+
6
+ # Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>
7
+ def <%= action %>
8
+ <%= class_name %>.<%= action %>
9
+ end
10
+ <% end -%>
11
+
12
+ end
13
+ <% end -%>
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= class_name %>, :type => :model do
4
+ RSpec.describe <%= class_name %>, <%= type_metatag(:model) %> do
5
5
  pending "add some examples to (or delete) #{__FILE__}"
6
6
  end
7
7
  <% end -%>
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= class_name %>Observer, :type => :observer do
4
+ RSpec.describe <%= class_name %>Observer, <%= type_metatag(:observer) %> do
5
5
  pending "add some examples to (or delete) #{__FILE__}"
6
6
  end
7
7
  <% end -%>
@@ -19,7 +19,7 @@ require 'rails_helper'
19
19
  # that an instance is receiving a specific message.
20
20
 
21
21
  <% module_namespacing do -%>
22
- RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
22
+ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:controller) %> do
23
23
 
24
24
  # This should return the minimal set of attributes required to create a valid
25
25
  # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
@@ -38,7 +38,7 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
38
38
  let(:valid_session) { {} }
39
39
 
40
40
  <% unless options[:singleton] -%>
41
- describe "GET index" do
41
+ describe "GET #index" do
42
42
  it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
43
43
  <%= file_name %> = <%= class_name %>.create! valid_attributes
44
44
  get :index, {}, valid_session
@@ -47,7 +47,7 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
47
47
  end
48
48
 
49
49
  <% end -%>
50
- describe "GET show" do
50
+ describe "GET #show" do
51
51
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
52
52
  <%= file_name %> = <%= class_name %>.create! valid_attributes
53
53
  get :show, {:id => <%= file_name %>.to_param}, valid_session
@@ -55,14 +55,14 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
55
55
  end
56
56
  end
57
57
 
58
- describe "GET new" do
58
+ describe "GET #new" do
59
59
  it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
60
60
  get :new, {}, valid_session
61
61
  expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
62
62
  end
63
63
  end
64
64
 
65
- describe "GET edit" do
65
+ describe "GET #edit" do
66
66
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
67
67
  <%= file_name %> = <%= class_name %>.create! valid_attributes
68
68
  get :edit, {:id => <%= file_name %>.to_param}, valid_session
@@ -70,8 +70,8 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
70
70
  end
71
71
  end
72
72
 
73
- describe "POST create" do
74
- describe "with valid params" do
73
+ describe "POST #create" do
74
+ context "with valid params" do
75
75
  it "creates a new <%= class_name %>" do
76
76
  expect {
77
77
  post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
@@ -90,7 +90,7 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
90
90
  end
91
91
  end
92
92
 
93
- describe "with invalid params" do
93
+ context "with invalid params" do
94
94
  it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
95
95
  post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
96
96
  expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
@@ -103,8 +103,8 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
103
103
  end
104
104
  end
105
105
 
106
- describe "PUT update" do
107
- describe "with valid params" do
106
+ describe "PUT #update" do
107
+ context "with valid params" do
108
108
  let(:new_attributes) {
109
109
  skip("Add a hash of attributes valid for your model")
110
110
  }
@@ -129,7 +129,7 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
129
129
  end
130
130
  end
131
131
 
132
- describe "with invalid params" do
132
+ context "with invalid params" do
133
133
  it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
134
134
  <%= file_name %> = <%= class_name %>.create! valid_attributes
135
135
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
@@ -144,7 +144,7 @@ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
144
144
  end
145
145
  end
146
146
 
147
- describe "DELETE destroy" do
147
+ describe "DELETE #destroy" do
148
148
  it "destroys the requested <%= ns_file_name %>" do
149
149
  <%= file_name %> = <%= class_name %>.create! valid_attributes
150
150
  expect {
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- RSpec.describe "<%= ns_table_name %>/edit", :type => :view do
4
+ RSpec.describe "<%= ns_table_name %>/edit", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
6
  @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- RSpec.describe "<%= ns_table_name %>/index", :type => :view do
4
+ RSpec.describe "<%= ns_table_name %>/index", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
6
  assign(:<%= table_name %>, [
7
7
  <% [1,2].each_with_index do |id, model_index| -%>
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- RSpec.describe "<%= ns_table_name %>/new", :type => :view do
4
+ RSpec.describe "<%= ns_table_name %>/new", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
6
  assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
@@ -1,7 +1,7 @@
1
1
  require "rails_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= controller_class_name %>Controller, :type => :routing do
4
+ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:routing) %> do
5
5
  describe "routing" do
6
6
 
7
7
  <% unless options[:singleton] -%>
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- RSpec.describe "<%= ns_table_name %>/show", :type => :view do
4
+ RSpec.describe "<%= ns_table_name %>/show", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
6
  @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
@@ -1,5 +1,5 @@
1
1
  require 'rails_helper'
2
2
 
3
- RSpec.describe "<%= file_path %>/<%= @action %>", :type => :view do
3
+ RSpec.describe "<%= file_path %>/<%= @action %>", <%= type_metatag(:view) %> do
4
4
  pending "add some examples to (or delete) #{__FILE__}"
5
5
  end
@@ -1,3 +1,5 @@
1
+ require 'rspec/rails/feature_check'
2
+
1
3
  # Namespace for all core RSpec projects.
2
4
  module RSpec
3
5
  # Namespace for rspec-rails code.
@@ -9,9 +11,40 @@ module RSpec
9
11
  generators.integration_tool :rspec
10
12
  generators.test_framework :rspec
11
13
 
14
+ generators do
15
+ ::Rails::Generators.hidden_namespaces.reject! { |namespace| namespace.start_with?("rspec") }
16
+ end
17
+
12
18
  rake_tasks do
13
19
  load "rspec/rails/tasks/rspec.rake"
14
20
  end
21
+
22
+ # This is called after the environment has been loaded but before Rails
23
+ # sets the default for the `preview_path`
24
+ initializer "rspec_rails.action_mailer",
25
+ :before => "action_mailer.set_configs" do |app|
26
+ if ::RSpec::Rails::FeatureCheck.has_action_mailer_preview?
27
+ options = app.config.action_mailer
28
+ # Rails 4.1 does not have `show_previews`
29
+ if ::ActionMailer::Base.respond_to?(:show_previews=)
30
+ options.show_previews ||= ::Rails.env.development?
31
+ set_preview_path = options.show_previews
32
+ else
33
+ set_preview_path = ::Rails.env.development?
34
+ end
35
+
36
+ if set_preview_path
37
+ rspec_preview_path = "#{::Rails.root}/spec/mailers/previews"
38
+ config_preview_path = options.preview_path
39
+ if config_preview_path.blank?
40
+ options.preview_path = rspec_preview_path
41
+ elsif config_preview_path != rspec_preview_path
42
+ warn "Action Mailer `preview_path` is not the RSpec default. " \
43
+ "Preview path is set to: #{config_preview_path}"
44
+ end
45
+ end
46
+ end
47
+ end
15
48
  end
16
49
  end
17
50
  end
@@ -1,11 +1,16 @@
1
1
  require 'rspec/core'
2
2
  require 'rails/version'
3
+
4
+ # Load any of our adapters and extensions early in the process
5
+ require 'rspec/rails/adapters'
3
6
  require 'rspec/rails/extensions'
7
+
8
+ # Load the rspec-rails parts
4
9
  require 'rspec/rails/view_rendering'
5
- require 'rspec/rails/adapters'
6
10
  require 'rspec/rails/matchers'
7
11
  require 'rspec/rails/fixture_support'
8
12
  require 'rspec/rails/example'
9
13
  require 'rspec/rails/vendor/capybara'
10
14
  require 'rspec/rails/configuration'
15
+ require 'rspec/rails/active_record'
11
16
  require 'rspec/rails/feature_check'
@@ -0,0 +1,21 @@
1
+ module RSpec
2
+ module Rails
3
+ # Fake class to document RSpec ActiveRecord configuration options. In practice,
4
+ # these are dynamically added to the normal RSpec configuration object.
5
+ class ActiveRecordConfiguration
6
+ # @private
7
+ def self.initialize_activerecord_configuration(config)
8
+ config.before :suite do
9
+ # This allows dynamic columns etc to be used on ActiveRecord models when creating instance_doubles
10
+ if defined?(ActiveRecord) && defined?(::RSpec::Mocks)
11
+ ::RSpec::Mocks.configuration.when_declaring_verifying_double do |possible_model|
12
+ possible_model.target.define_attribute_methods if possible_model.target.respond_to?(:define_attribute_methods)
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ initialize_activerecord_configuration RSpec.configuration
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,7 @@
1
1
  require 'delegate'
2
2
  require 'active_support'
3
3
  require 'active_support/concern'
4
+ require 'active_support/core_ext/string'
4
5
 
5
6
  module RSpec
6
7
  module Rails
@@ -14,6 +15,44 @@ module RSpec
14
15
  # Constant aliased to either Minitest or TestUnit, depending on what is
15
16
  # loaded.
16
17
  Assertions = Minitest::Assertions
18
+ elsif RUBY_VERSION >= '2.2.0'
19
+ # Minitest / TestUnit has been removed from ruby core. However, we are
20
+ # on an old Rails version and must load the appropriate gem
21
+ if ::Rails::VERSION::STRING >= '4.0.0'
22
+ # ActiveSupport 4.0.x has the minitest '~> 4.2' gem as a dependency
23
+ # This gem has no `lib/minitest.rb` file.
24
+ gem 'minitest' if defined?(Kernel.gem)
25
+ require 'minitest/unit'
26
+ Assertions = MiniTest::Assertions
27
+ elsif ::Rails::VERSION::STRING >= '3.2.21'
28
+ # TODO: Change the above check to >= '3.2.22' once it's released
29
+ begin
30
+ # Test::Unit "helpfully" sets up autoload for its `AutoRunner`.
31
+ # While we do not reference it directly, when we load the `TestCase`
32
+ # classes from AS (ActiveSupport), AS kindly references `AutoRunner`
33
+ # for everyone.
34
+ #
35
+ # To handle this we need to pre-emptively load 'test/unit' and make
36
+ # sure the version installed has `AutoRunner` (the 3.x line does to
37
+ # date). If so, we turn the auto runner off.
38
+ require 'test/unit'
39
+ require 'test/unit/assertions'
40
+ Test::Unit::AutoRunner.need_auto_run = false if defined?(Test::Unit::AutoRunner)
41
+ rescue LoadError => e
42
+ raise LoadError, <<-ERR.squish, e.backtrace
43
+ Ruby 2.2+ has removed test/unit from the core library. Rails
44
+ requires this as a dependency. Please add test-unit gem to your
45
+ Gemfile: `gem 'test-unit', '~> 3.0'` (#{e.message})"
46
+ ERR
47
+ end
48
+ Assertions = Test::Unit::Assertions
49
+ else
50
+ abort <<-MSG.squish
51
+ Ruby 2.2+ is not supported on Rails #{::Rails::VERSION::STRING}.
52
+ Check the Rails release notes for the appropriate update with
53
+ support.
54
+ MSG
55
+ end
17
56
  else
18
57
  begin
19
58
  require 'test/unit/assertions'
@@ -64,7 +64,7 @@ module RSpec
64
64
  if superclass == root_controller || superclass.abstract?
65
65
  "AnonymousController"
66
66
  else
67
- superclass.to_s
67
+ superclass.name
68
68
  end
69
69
  end
70
70
  end
@@ -33,3 +33,40 @@ module RSpec
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ unless RSpec.respond_to?(:feature)
38
+ opts = {
39
+ :capybara_feature => true,
40
+ :type => :feature,
41
+ :skip => <<-EOT.squish
42
+ Feature specs require the Capybara (http://github.com/jnicklas/capybara)
43
+ gem, version 2.2.0 or later. We recommend version 2.4.0 or later to avoid
44
+ some deprecation warnings and have support for
45
+ `config.expose_dsl_globally = false`.
46
+ EOT
47
+ }
48
+
49
+ # Capybara's monkey patching causes us to have to jump through some hoops
50
+ top_level = self
51
+ main_feature = nil
52
+ if defined?(Capybara) && ::Capybara::VERSION.to_f < 2.4
53
+ # Capybara 2.2 and 2.3 do not use `alias_example_xyz`
54
+ opts[:skip] = <<-EOT.squish
55
+ Capybara < 2.4.0 does not support RSpec's namespace or
56
+ `config.expose_dsl_globally = false`. Upgrade to Capybara >= 2.4.0.
57
+ EOT
58
+ main_feature = top_level.method(:feature) if top_level.respond_to?(:feature)
59
+ end
60
+
61
+ RSpec.configure do |c|
62
+ main_feature = nil unless c.expose_dsl_globally?
63
+ c.alias_example_group_to :feature, opts
64
+ c.alias_example_to :scenario
65
+ c.alias_example_to :xscenario
66
+ end
67
+
68
+ # Due to load order issues and `config.expose_dsl_globally?` defaulting to
69
+ # `true` we need to put Capybara's monkey patch method back. Otherwise,
70
+ # app upgrades have a high likelyhood of having all feature specs skipped.
71
+ top_level.define_singleton_method(:feature, &main_feature) if main_feature
72
+ end
@@ -29,6 +29,26 @@ module RSpec
29
29
  def has_active_record_migration?
30
30
  has_active_record? && defined?(::ActiveRecord::Migration)
31
31
  end
32
+
33
+ def has_action_mailer?
34
+ defined?(::ActionMailer)
35
+ end
36
+
37
+ def has_action_mailer_preview?
38
+ has_action_mailer? && defined?(::ActionMailer::Preview)
39
+ end
40
+
41
+ def has_1_9_hash_syntax?
42
+ ::Rails::VERSION::STRING > '4.0'
43
+ end
44
+
45
+ def type_metatag(type)
46
+ if has_1_9_hash_syntax?
47
+ "type: :#{type}"
48
+ else
49
+ ":type => :#{type}"
50
+ end
51
+ end
32
52
  end
33
53
  # rubocop:enable Style/IndentationConsistency
34
54
  end
@@ -9,17 +9,6 @@ module RSpec
9
9
  end
10
10
  end
11
11
 
12
- begin
13
- require 'test/unit/assertionfailederror'
14
- rescue LoadError
15
- module Test
16
- module Unit
17
- class AssertionFailedError < StandardError
18
- end
19
- end
20
- end
21
- end
22
-
23
12
  require 'rspec/rails/matchers/have_rendered'
24
13
  require 'rspec/rails/matchers/redirect_to'
25
14
  require 'rspec/rails/matchers/routing_matchers'
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Rails.
4
4
  module Version
5
5
  # Current version of RSpec Rails, in semantic versioning format.
6
- STRING = '3.1.0'
6
+ STRING = '3.2.0'
7
7
  end
8
8
  end
9
9
  end
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.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -11,28 +11,40 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDjjCCAnagAwIBAgIBATANBgkqhkiG9w0BAQUFADBGMRIwEAYDVQQDDAlyc3Bl
15
- Yy1kZXYxGzAZBgoJkiaJk/IsZAEZFgtnb29nbGVnb3VwczETMBEGCgmSJomT8ixk
16
- ARkWA2NvbTAeFw0xMzExMDcxOTQyNTlaFw0xNDExMDcxOTQyNTlaMEYxEjAQBgNV
17
- BAMMCXJzcGVjLWRldjEbMBkGCgmSJomT8ixkARkWC2dvb2dsZWdvdXBzMRMwEQYK
18
- CZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
19
- nhCeZouDLXWO55no+EdZNCtjXjfJQ1X9TbPcvBDD29OypIUce2h/VdKXB2gI7ZHs
20
- F5NkPggslTErGFmWAtIiur7u943RVqHOsyoIsy065F9fCtrykkA+22elvTDha4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+hrW
33
+ Vv35J+TeMB8GA1UdIwQYMBaAFPPvQ5XT0Nvuhi6k+hrWVv35J+TeMAwGA1UdEwQF
34
+ MAMBAf8wDQYJKoZIhvcNAQEFBQADggIBAIqbQSWH2aAF537DKwAMB8nMFsoe24MD
35
+ gtuQAyjTtbH+QBE4N2RdQF/sU7Y3PYR7nqdrCsYc3RxyqM5XXi7I3IYdpfe1RuxY
36
+ +pyPzVQsPPDhMlJlCrwJsADnxlpxZlAgxYSLKOan55ihscaAWA90wqRUrf/ZJM36
37
+ 8LWCPVn5teIt5aaxZWX68RMxa+AXvpbtJOBwXLkIFk3apD8CX4DhelIdw67DbkUe
38
+ ghUd/u62qrnqBTVgditt7OoWIZjzh24/Fda5d0MxZyvLILGOrf5bN4cTbe/q9Cid
39
+ Xrik7Upm+mu3y3yQIfrw85xybHq6iNXyYHvCdSrFfCIKrGpd/0CAdmYnJlx59Fk/
40
+ UbD3Eyx4psBSkU+WKO0Uf+3zNI7N/nVeNIwU/Ft+l8l7/K+427656c+ZGWDO0Gt/
41
+ BeEOSTDKP7qQ1T+JvMrBcBQo+i0cnRT10J1aoV90BhxsvWTRizIbugbaqR6Tq3bj
42
+ Akt00cIlNSplL6DenIAKSh5kF7s0tRD0tC3bNkZmNjNGkdoGEcUODEpTB3RHKKiu
43
+ e6k2Jg6m00z5vGFQhOnROG/QaUzMA3A3mFBe1RHFo07xd0pFeoeWL3vF69Gx9Jwp
44
+ ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
45
+ F3MdtaDehhjC
34
46
  -----END CERTIFICATE-----
35
- date: 2014-09-05 00:00:00.000000000 Z
47
+ date: 2015-02-03 00:00:00.000000000 Z
36
48
  dependencies:
37
49
  - !ruby/object:Gem::Dependency
38
50
  name: activesupport
@@ -41,6 +53,9 @@ dependencies:
41
53
  - - ">="
42
54
  - !ruby/object:Gem::Version
43
55
  version: '3.0'
56
+ - - "<="
57
+ - !ruby/object:Gem::Version
58
+ version: '4.2'
44
59
  type: :runtime
45
60
  prerelease: false
46
61
  version_requirements: !ruby/object:Gem::Requirement
@@ -48,6 +63,9 @@ dependencies:
48
63
  - - ">="
49
64
  - !ruby/object:Gem::Version
50
65
  version: '3.0'
66
+ - - "<="
67
+ - !ruby/object:Gem::Version
68
+ version: '4.2'
51
69
  - !ruby/object:Gem::Dependency
52
70
  name: actionpack
53
71
  requirement: !ruby/object:Gem::Requirement
@@ -55,6 +73,9 @@ dependencies:
55
73
  - - ">="
56
74
  - !ruby/object:Gem::Version
57
75
  version: '3.0'
76
+ - - "<="
77
+ - !ruby/object:Gem::Version
78
+ version: '4.2'
58
79
  type: :runtime
59
80
  prerelease: false
60
81
  version_requirements: !ruby/object:Gem::Requirement
@@ -62,6 +83,9 @@ dependencies:
62
83
  - - ">="
63
84
  - !ruby/object:Gem::Version
64
85
  version: '3.0'
86
+ - - "<="
87
+ - !ruby/object:Gem::Version
88
+ version: '4.2'
65
89
  - !ruby/object:Gem::Dependency
66
90
  name: railties
67
91
  requirement: !ruby/object:Gem::Requirement
@@ -69,6 +93,9 @@ dependencies:
69
93
  - - ">="
70
94
  - !ruby/object:Gem::Version
71
95
  version: '3.0'
96
+ - - "<="
97
+ - !ruby/object:Gem::Version
98
+ version: '4.2'
72
99
  type: :runtime
73
100
  prerelease: false
74
101
  version_requirements: !ruby/object:Gem::Requirement
@@ -76,62 +103,65 @@ dependencies:
76
103
  - - ">="
77
104
  - !ruby/object:Gem::Version
78
105
  version: '3.0'
106
+ - - "<="
107
+ - !ruby/object:Gem::Version
108
+ version: '4.2'
79
109
  - !ruby/object:Gem::Dependency
80
110
  name: rspec-core
81
111
  requirement: !ruby/object:Gem::Requirement
82
112
  requirements:
83
113
  - - "~>"
84
114
  - !ruby/object:Gem::Version
85
- version: 3.1.0
115
+ version: 3.2.0
86
116
  type: :runtime
87
117
  prerelease: false
88
118
  version_requirements: !ruby/object:Gem::Requirement
89
119
  requirements:
90
120
  - - "~>"
91
121
  - !ruby/object:Gem::Version
92
- version: 3.1.0
122
+ version: 3.2.0
93
123
  - !ruby/object:Gem::Dependency
94
124
  name: rspec-expectations
95
125
  requirement: !ruby/object:Gem::Requirement
96
126
  requirements:
97
127
  - - "~>"
98
128
  - !ruby/object:Gem::Version
99
- version: 3.1.0
129
+ version: 3.2.0
100
130
  type: :runtime
101
131
  prerelease: false
102
132
  version_requirements: !ruby/object:Gem::Requirement
103
133
  requirements:
104
134
  - - "~>"
105
135
  - !ruby/object:Gem::Version
106
- version: 3.1.0
136
+ version: 3.2.0
107
137
  - !ruby/object:Gem::Dependency
108
138
  name: rspec-mocks
109
139
  requirement: !ruby/object:Gem::Requirement
110
140
  requirements:
111
141
  - - "~>"
112
142
  - !ruby/object:Gem::Version
113
- version: 3.1.0
143
+ version: 3.2.0
114
144
  type: :runtime
115
145
  prerelease: false
116
146
  version_requirements: !ruby/object:Gem::Requirement
117
147
  requirements:
118
148
  - - "~>"
119
149
  - !ruby/object:Gem::Version
120
- version: 3.1.0
150
+ version: 3.2.0
121
151
  - !ruby/object:Gem::Dependency
122
152
  name: rspec-support
123
153
  requirement: !ruby/object:Gem::Requirement
124
154
  requirements:
125
155
  - - "~>"
126
156
  - !ruby/object:Gem::Version
127
- version: 3.1.0
157
+ version: 3.2.0
128
158
  type: :runtime
129
159
  prerelease: false
130
160
  version_requirements: !ruby/object:Gem::Requirement
131
161
  requirements:
132
162
  - - "~>"
133
163
  - !ruby/object:Gem::Version
134
- version: 3.1.0
164
+ version: 3.2.0
135
165
  - !ruby/object:Gem::Dependency
136
166
  name: rake
137
167
  requirement: !ruby/object:Gem::Requirement
@@ -217,6 +247,7 @@ files:
217
247
  - lib/generators/rspec/mailer/mailer_generator.rb
218
248
  - lib/generators/rspec/mailer/templates/fixture
219
249
  - lib/generators/rspec/mailer/templates/mailer_spec.rb
250
+ - lib/generators/rspec/mailer/templates/preview.rb
220
251
  - lib/generators/rspec/model/model_generator.rb
221
252
  - lib/generators/rspec/model/templates/fixtures.yml
222
253
  - lib/generators/rspec/model/templates/model_spec.rb
@@ -233,6 +264,7 @@ files:
233
264
  - lib/generators/rspec/view/view_generator.rb
234
265
  - lib/rspec-rails.rb
235
266
  - lib/rspec/rails.rb
267
+ - lib/rspec/rails/active_record.rb
236
268
  - lib/rspec/rails/adapters.rb
237
269
  - lib/rspec/rails/configuration.rb
238
270
  - lib/rspec/rails/example.rb
@@ -287,6 +319,6 @@ rubyforge_project: rspec
287
319
  rubygems_version: 2.2.2
288
320
  signing_key:
289
321
  specification_version: 4
290
- summary: rspec-rails-3.1.0
322
+ summary: rspec-rails-3.2.0
291
323
  test_files: []
292
324
  has_rdoc:
metadata.gz.sig CHANGED
Binary file