Skip to content

Commit

Permalink
Update RSpec test style across docs
Browse files Browse the repository at this point in the history
Instead of using

    describe Foo do
      # ...
    end

use

    RSpec.describe Foo, type: :model do
      # ...
    end

instead. This is not exactly official, as the former style still works,
but the latter style is highly suggested in RSpec documentation and the
like, so this is what people are used to.

[ci skip]
  • Loading branch information
mcmire committed Jun 16, 2016
1 parent a1eee11 commit afa6a7b
Show file tree
Hide file tree
Showing 32 changed files with 159 additions and 159 deletions.
4 changes: 2 additions & 2 deletions docs/errors/NonCaseSwappableValueError.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ error message explains, you have two options:
end

# RSpec
describe User do
RSpec.describe User, type: :model do
context "validations" do
subject do
# Note that "123" == "123".swapcase. This is a problem!
Expand Down Expand Up @@ -87,7 +87,7 @@ error message explains, you have two options:
end
# RSpec
describe User do
RSpec.describe User, type: :model do
context "validations" do
subject do
# Note that "123" == "123".swapcase, but it's okay
Expand Down
12 changes: 6 additions & 6 deletions lib/shoulda/matchers/action_controller/callback_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ActionController
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# it { should use_before_filter(:authenticate_user!) }
# it { should_not use_before_filter(:prevent_ssl) }
# end
Expand All @@ -34,7 +34,7 @@ def use_before_filter(callback)
# end
#
# # RSpec
# describe IssuesController do
# RSpec.describe IssuesController, type: :controller do
# it { should use_after_filter(:log_activity) }
# it { should_not use_after_filter(:destroy_user) }
# end
Expand All @@ -59,7 +59,7 @@ def use_after_filter(callback)
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# it { should use_before_action(:authenticate_user!) }
# it { should_not use_before_action(:prevent_ssl) }
# end
Expand All @@ -84,7 +84,7 @@ def use_before_action(callback)
# end
#
# # RSpec
# describe IssuesController do
# RSpec.describe IssuesController, type: :controller do
# it { should use_after_action(:log_activity) }
# it { should_not use_after_action(:destroy_user) }
# end
Expand All @@ -109,7 +109,7 @@ def use_after_action(callback)
# end
#
# # RSpec
# describe ChangesController do
# RSpec.describe ChangesController, type: :controller do
# it { should use_around_filter(:wrap_in_transaction) }
# it { should_not use_around_filter(:save_view_context) }
# end
Expand All @@ -134,7 +134,7 @@ def use_around_filter(callback)
# end
#
# # RSpec
# describe ChangesController do
# RSpec.describe ChangesController, type: :controller do
# it { should use_around_action(:wrap_in_transaction) }
# it { should_not use_around_action(:save_view_context) }
# end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ActionController
# end
#
# # RSpec
# describe ApplicationController do
# RSpec.describe ApplicationController, type: :controller do
# it { should filter_param(:secret_key) }
# end
#
Expand Down
6 changes: 3 additions & 3 deletions lib/shoulda/matchers/action_controller/permit_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module ActionController
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# it do
# params = {
# user: {
Expand Down Expand Up @@ -96,7 +96,7 @@ module ActionController
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# before do
# create(:user, id: 1)
# end
Expand Down Expand Up @@ -170,7 +170,7 @@ module ActionController
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# before do
# create(:user, id: 1)
# end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module ActionController
# <%= render 'sidebar' %>
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#
Expand All @@ -38,7 +38,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #sidebar' do
# before { get :sidebar }
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module ActionController
# end
#
# # RSpec
# describe ApplicationController do
# RSpec.describe ApplicationController, type: :controller do
# it do
# should rescue_from(ActiveRecord::RecordNotFound).
# with(:handle_not_found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
Expand All @@ -39,7 +39,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'DELETE #destroy' do
# before { delete :destroy }
#
Expand All @@ -65,7 +65,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#
Expand Down
4 changes: 2 additions & 2 deletions lib/shoulda/matchers/action_controller/route_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# it { should route(:get, '/posts').to(action: :index) }
# it { should route(:get, '/posts/1').to(action: :show, id: 1) }
# end
Expand All @@ -38,7 +38,7 @@ module ActionController
# Or you could place the tests along with other route tests:
#
# # RSpec
# describe 'Routing' do
# describe 'Routing', type: :routing do
# it do
# should route(:get, '/posts').
# to(controller: :posts, action: :index)
Expand Down
8 changes: 4 additions & 4 deletions lib/shoulda/matchers/action_controller/set_flash_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
Expand Down Expand Up @@ -58,7 +58,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
Expand Down Expand Up @@ -89,7 +89,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
Expand Down Expand Up @@ -124,7 +124,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#
Expand Down
6 changes: 3 additions & 3 deletions lib/shoulda/matchers/action_controller/set_session_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
Expand Down Expand Up @@ -58,7 +58,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
Expand Down Expand Up @@ -89,7 +89,7 @@ module ActionController
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
Expand Down
2 changes: 1 addition & 1 deletion lib/shoulda/matchers/active_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Matchers
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# context "when an admin" do
# subject { User.new(admin: true) }
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ module ActiveModel
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should allow_mass_assignment_of(:title) }
# end
#
# describe User do
# RSpec.describe User, type: :model do
# it { should_not allow_mass_assignment_of(:encrypted_password) }
# end
#
Expand Down Expand Up @@ -56,7 +56,7 @@ module ActiveModel
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should allow_mass_assignment_of(:title).as(:admin) }
# end
#
Expand Down
20 changes: 10 additions & 10 deletions lib/shoulda/matchers/active_model/allow_value_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module ActiveModel
# You can use `allow_value` to test one value at a time:
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it { should allow_value('http://foo.com').for(:website_url) }
# it { should allow_value('http://bar.com').for(:website_url) }
# end
Expand All @@ -34,7 +34,7 @@ module ActiveModel
# that none of the values cause the record to be valid:
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_values('http://foo.com', 'http://bar.com').
# for(:website_url)
Expand Down Expand Up @@ -82,7 +82,7 @@ module ActiveModel
# end
# end
#
# describe Foo do
# RSpec.describe Foo, type: :model do
# it do
# foo = Foo.new
# foo.bar = "baz"
Expand All @@ -105,7 +105,7 @@ module ActiveModel
# end
# end
#
# describe Foo do
# RSpec.describe Foo, type: :model do
# it do
# foo = Foo.new
# # This will raise an AttributeChangedValueError since `foo.bar` is now "123"
Expand All @@ -116,7 +116,7 @@ module ActiveModel
# * You're passing a value to `allow_value` that the model typecasts into
# another value:
#
# describe Foo do
# RSpec.describe Foo, type: :model do
# # Assume that `attr` is a string
# # This will raise an AttributeChangedValueError since `attr` typecasts `[]` to `"[]"`
# it { should_not allow_value([]).for(:attr) }
Expand Down Expand Up @@ -154,7 +154,7 @@ module ActiveModel
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('2013-01-01').
# for(:birthday_as_string).
Expand Down Expand Up @@ -183,7 +183,7 @@ module ActiveModel
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('open', 'closed').
# for(:state).
Expand All @@ -210,7 +210,7 @@ module ActiveModel
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('open', 'closed').
# for(:state).
Expand Down Expand Up @@ -246,7 +246,7 @@ module ActiveModel
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('Broncos', 'Titans').
# for(:sports_team).
Expand Down Expand Up @@ -276,7 +276,7 @@ module ActiveModel
# end
#
# # RSpec
# describe Address do
# RSpec.describe Address, type: :model do
# it do
# should_not allow_value([]).
# for(:zip_code).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module ActiveModel
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it { should have_secure_password }
# end
#
Expand Down
Loading

0 comments on commit afa6a7b

Please sign in to comment.