Update RSpec test style across docs

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]
This commit is contained in:
Elliot Winkler 2016-06-15 18:00:51 -06:00
parent a1eee11bac
commit afa6a7b666
32 changed files with 159 additions and 159 deletions

View File

@ -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!
@ -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

View File

@ -9,7 +9,7 @@ module Shoulda
# 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
@ -34,7 +34,7 @@ module Shoulda
# 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
@ -59,7 +59,7 @@ module Shoulda
# 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
@ -84,7 +84,7 @@ module Shoulda
# 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
@ -109,7 +109,7 @@ module Shoulda
# 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
@ -134,7 +134,7 @@ module Shoulda
# 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

View File

@ -10,7 +10,7 @@ module Shoulda
# end
#
# # RSpec
# describe ApplicationController do
# RSpec.describe ApplicationController, type: :controller do
# it { should filter_param(:secret_key) }
# end
#

View File

@ -35,7 +35,7 @@ module Shoulda
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# it do
# params = {
# user: {
@ -96,7 +96,7 @@ module Shoulda
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# before do
# create(:user, id: 1)
# end
@ -170,7 +170,7 @@ module Shoulda
# end
#
# # RSpec
# describe UsersController do
# RSpec.describe UsersController, type: :controller do
# before do
# create(:user, id: 1)
# end

View File

@ -14,7 +14,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#

View File

@ -15,7 +15,7 @@ module Shoulda
# <%= render 'sidebar' %>
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#

View File

@ -11,7 +11,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#
@ -38,7 +38,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #sidebar' do
# before { get :sidebar }
#

View File

@ -16,7 +16,7 @@ module Shoulda
# end
#
# # RSpec
# describe ApplicationController do
# RSpec.describe ApplicationController, type: :controller do
# it do
# should rescue_from(ActiveRecord::RecordNotFound).
# with(:handle_not_found)

View File

@ -13,7 +13,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
@ -39,7 +39,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'DELETE #destroy' do
# before { delete :destroy }
#
@ -65,7 +65,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#

View File

@ -24,7 +24,7 @@ module Shoulda
# 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
@ -38,7 +38,7 @@ module Shoulda
# 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)

View File

@ -16,7 +16,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
@ -58,7 +58,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
@ -89,7 +89,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
@ -124,7 +124,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #show' do
# before { get :show }
#

View File

@ -16,7 +16,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
@ -58,7 +58,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#
@ -89,7 +89,7 @@ module Shoulda
# end
#
# # RSpec
# describe PostsController do
# RSpec.describe PostsController, type: :controller do
# describe 'GET #index' do
# before { get :index }
#

View File

@ -60,7 +60,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# context "when an admin" do
# subject { User.new(admin: true) }
#

View File

@ -23,11 +23,11 @@ module Shoulda
# 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
#
@ -56,7 +56,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should allow_mass_assignment_of(:title).as(:admin) }
# end
#

View File

@ -17,7 +17,7 @@ module Shoulda
# 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
@ -34,7 +34,7 @@ module Shoulda
# 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)
@ -82,7 +82,7 @@ module Shoulda
# end
# end
#
# describe Foo do
# RSpec.describe Foo, type: :model do
# it do
# foo = Foo.new
# foo.bar = "baz"
@ -105,7 +105,7 @@ module Shoulda
# 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"
@ -116,7 +116,7 @@ module Shoulda
# * 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) }
@ -154,7 +154,7 @@ module Shoulda
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('2013-01-01').
# for(:birthday_as_string).
@ -183,7 +183,7 @@ module Shoulda
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('open', 'closed').
# for(:state).
@ -210,7 +210,7 @@ module Shoulda
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('open', 'closed').
# for(:state).
@ -246,7 +246,7 @@ module Shoulda
# end
#
# # RSpec
# describe UserProfile do
# RSpec.describe UserProfile, type: :model do
# it do
# should allow_value('Broncos', 'Titans').
# for(:sports_team).
@ -276,7 +276,7 @@ module Shoulda
# end
#
# # RSpec
# describe Address do
# RSpec.describe Address, type: :model do
# it do
# should_not allow_value([]).
# for(:zip_code).

View File

@ -15,7 +15,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it { should have_secure_password }
# end
#

View File

@ -12,7 +12,7 @@ module Shoulda
# end
#
# # RSpec
# describe PowerHungryCountry do
# RSpec.describe PowerHungryCountry, type: :model do
# it { should validate_absence_of(:nuclear_weapons) }
# end
#
@ -35,7 +35,7 @@ module Shoulda
# end
#
# # RSpec
# describe PowerHungryCountry do
# RSpec.describe PowerHungryCountry, type: :model do
# it { should validate_absence_of(:nuclear_weapons).on(:create) }
# end
#
@ -57,7 +57,7 @@ module Shoulda
# end
#
# # RSpec
# describe PowerHungryCountry do
# RSpec.describe PowerHungryCountry, type: :model do
# it do
# should validate_absence_of(:nuclear_weapons).
# with_message("there shall be peace on Earth")

View File

@ -12,7 +12,7 @@ module Shoulda
# end
#
# # RSpec
# describe Registration do
# RSpec.describe Registration, type: :model do
# it { should validate_acceptance_of(:eula) }
# end
#
@ -35,7 +35,7 @@ module Shoulda
# end
#
# # RSpec
# describe Registration do
# RSpec.describe Registration, type: :model do
# it do
# should validate_acceptance_of(:terms_of_service).
# on(:create)
@ -60,7 +60,7 @@ module Shoulda
# end
#
# # RSpec
# describe Registration do
# RSpec.describe Registration, type: :model do
# it do
# should validate_acceptance_of(:terms_of_service).
# with_message('You must accept the terms of service')

View File

@ -12,7 +12,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it { should validate_confirmation_of(:email) }
# end
#
@ -35,7 +35,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it { should validate_confirmation_of(:password).on(:create) }
# end
#
@ -57,7 +57,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it do
# should validate_confirmation_of(:password).
# with_message('Please re-enter your password')

View File

@ -16,7 +16,7 @@ module Shoulda
# end
#
# # RSpec
# describe Game do
# RSpec.describe Game, type: :model do
# it do
# should validate_exclusion_of(:supported_os).
# in_array(['Mac', 'Linux'])
@ -39,7 +39,7 @@ module Shoulda
# end
#
# # RSpec
# describe Game do
# RSpec.describe Game, type: :model do
# it do
# should validate_exclusion_of(:floors_with_enemies).
# in_range(5..8)
@ -68,7 +68,7 @@ module Shoulda
# end
#
# # RSpec
# describe Game do
# RSpec.describe Game, type: :model do
# it do
# should validate_exclusion_of(:weapon).
# in_array(['pistol', 'paintball gun', 'stick']).
@ -97,7 +97,7 @@ module Shoulda
# end
#
# # RSpec
# describe Game do
# RSpec.describe Game, type: :model do
# it do
# should validate_exclusion_of(:weapon).
# in_array(['pistol', 'paintball gun', 'stick']).

View File

@ -19,7 +19,7 @@ module Shoulda
# end
#
# # RSpec
# describe Issue do
# RSpec.describe Issue, type: :model do
# it do
# should validate_inclusion_of(:state).
# in_array(['open', 'resolved', 'unresolved'])
@ -42,7 +42,7 @@ module Shoulda
# end
#
# # RSpec
# describe Issue do
# RSpec.describe Issue, type: :model do
# it { should validate_inclusion_of(:state).in_range(1..5) }
# end
#
@ -84,7 +84,7 @@ module Shoulda
# end
#
# # RSpec
# describe Issue do
# RSpec.describe Issue, type: :model do
# it do
# should validate_inclusion_of(:severity).
# in_array(%w(low medium high)).
@ -113,7 +113,7 @@ module Shoulda
# end
#
# # RSpec
# describe Issue do
# RSpec.describe Issue, type: :model do
# it do
# should validate_inclusion_of(:severity).
# in_array(%w(low medium high)).
@ -149,7 +149,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_inclusion_of(:age).
# in_range(0..65).
@ -185,7 +185,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_inclusion_of(:age).
# in_range(0..21).
@ -215,7 +215,7 @@ module Shoulda
# end
#
# # RSpec
# describe Issue do
# RSpec.describe Issue, type: :model do
# it do
# should validate_inclusion_of(:state).
# in_array(['open', 'resolved', 'unresolved']).
@ -245,7 +245,7 @@ module Shoulda
# end
#
# # RSpec
# describe Issue do
# RSpec.describe Issue, type: :model do
# it do
# should validate_inclusion_of(:state).
# in_array(['open', 'resolved', 'unresolved']).

View File

@ -17,7 +17,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it do
# should validate_length_of(:password).
# is_at_least(10).
@ -47,7 +47,7 @@ module Shoulda
#
# # RSpec
#
# describe User do
# RSpec.describe User, type: :model do
# it { should validate_length_of(:bio).is_at_least(15) }
# end
#
@ -71,7 +71,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it { should validate_length_of(:status_update).is_at_most(140) }
# end
#
@ -94,7 +94,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it { should validate_length_of(:favorite_superhero).is_equal_to(6) }
# end
#
@ -116,7 +116,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it do
# should validate_length_of(:password).
# is_at_least(5).is_at_most(30)
@ -143,7 +143,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it do
# should validate_length_of(:password).
# is_at_least(10).
@ -172,7 +172,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it do
# should validate_length_of(:secret_key).
# is_at_least(15).
@ -201,7 +201,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it do
# should validate_length_of(:secret_key).
# is_at_most(100).

View File

@ -12,7 +12,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should validate_numericality_of(:gpa) }
# end
#
@ -35,7 +35,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_numericality_of(:number_of_dependents).
# on(:create)
@ -61,7 +61,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should validate_numericality_of(:age).only_integer }
# end
#
@ -85,7 +85,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_numericality_of(:number_of_cars).
# is_less_than(2)
@ -113,7 +113,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_numericality_of(:birth_year).
# is_less_than_or_equal_to(1987)
@ -140,7 +140,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should validate_numericality_of(:weight).is_equal_to(150) }
# end
#
@ -164,7 +164,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_numericality_of(:height).
# is_greater_than_or_equal_to(55)
@ -191,7 +191,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_numericality_of(:legal_age).
# is_greater_than(21)
@ -217,7 +217,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should validate_numericality_of(:birth_month).even }
# end
#
@ -240,7 +240,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should validate_numericality_of(:birth_day).odd }
# end
#
@ -262,7 +262,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should validate_numericality_of(:number_of_dependents).
# with_message('Number of dependents must be a number')
@ -287,7 +287,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_numericality_of(:age).allow_nil }
# end
#

View File

@ -12,7 +12,7 @@ module Shoulda
# end
#
# # RSpec
# describe Robot do
# RSpec.describe Robot, type: :model do
# it { should validate_presence_of(:arms) }
# end
#
@ -36,7 +36,7 @@ module Shoulda
# validates_presence_of :password
# end
#
# describe User do
# RSpec.describe User, type: :model do
# subject { User.new(password: '123456') }
#
# it { should validate_presence_of(:password) }
@ -69,7 +69,7 @@ module Shoulda
# end
#
# # RSpec
# describe Robot do
# RSpec.describe Robot, type: :model do
# it { should validate_presence_of(:arms).on(:create) }
# end
#
@ -90,7 +90,7 @@ module Shoulda
# end
#
# # RSpec
# describe Robot do
# RSpec.describe Robot, type: :model do
# it do
# should validate_presence_of(:legs).
# with_message('Robot has no legs')

View File

@ -9,7 +9,7 @@ module Shoulda
# end
#
# # RSpec
# describe Car do
# RSpec.describe Car, type: :model do
# it { should accept_nested_attributes_for(:doors) }
# end
#
@ -30,7 +30,7 @@ module Shoulda
# end
#
# # RSpec
# describe Car do
# RSpec.describe Car, type: :model do
# it do
# should accept_nested_attributes_for(:mirrors).
# allow_destroy(true)
@ -52,7 +52,7 @@ module Shoulda
# end
#
# # RSpec
# describe Car do
# RSpec.describe Car, type: :model do
# it do
# should accept_nested_attributes_for(:windows).
# limit(3)
@ -75,7 +75,7 @@ module Shoulda
# end
#
# # RSpec
# describe Car do
# RSpec.describe Car, type: :model do
# it do
# should accept_nested_attributes_for(:engine).
# update_only(true)

View File

@ -11,7 +11,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:organization) }
# end
#
@ -28,7 +28,7 @@ module Shoulda
# end
#
# # RSpec
# describe Comment do
# RSpec.describe Comment, type: :model do
# it { should belong_to(:commentable) }
# end
#
@ -49,7 +49,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should belong_to(:family).
# conditions(everyone_is_perfect: false)
@ -72,7 +72,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:previous_company).order('hired_on desc') }
# end
#
@ -91,7 +91,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:ancient_city).class_name('City') }
# end
#
@ -109,7 +109,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should belong_to(:great_country).
# with_primary_key('country_id')
@ -131,7 +131,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should belong_to(:great_country).
# with_foreign_key('country_id')
@ -153,7 +153,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:world).dependent(:destroy) }
# end
#
@ -165,7 +165,7 @@ module Shoulda
# To assert that *any* `:dependent` option was specified, use `true`:
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:world).dependent(true) }
# end
#
@ -176,7 +176,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:company).dependent(false) }
# end
#
@ -190,7 +190,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:organization).counter_cache(true) }
# end
#
@ -208,7 +208,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should belong_to(:organization).touch(true) }
# end
#
@ -226,7 +226,7 @@ module Shoulda
# end
#
# # RSpec
# describe Account do
# RSpec.describe Account, type: :model do
# it { should belong_to(:bank).autosave(true) }
# end
#
@ -267,7 +267,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:friends) }
# end
#
@ -284,7 +284,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:pictures) }
# end
#
@ -305,7 +305,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:coins).conditions(quality: 'mint') }
# end
#
@ -324,7 +324,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:shirts).order('color') }
# end
#
@ -343,7 +343,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:hopes).class_name('Dream') }
# end
#
@ -361,7 +361,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:worries).with_primary_key('worrier_id') }
# end
#
@ -379,7 +379,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:worries).with_foreign_key('worrier_id') }
# end
#
@ -397,7 +397,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:secret_documents).dependent(:destroy) }
# end
#
@ -416,7 +416,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:acquaintances).through(:friends) }
# end
#
@ -435,7 +435,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should have_many(:job_offers).
# through(:friends).
@ -459,7 +459,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_many(:ideas).validate(false) }
# end
#
@ -477,7 +477,7 @@ module Shoulda
# end
#
# # RSpec
# describe Player do
# RSpec.describe Player, type: :model do
# it { should have_many(:games).autosave(true) }
# end
#
@ -500,7 +500,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:partner) }
# end
#
@ -521,7 +521,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:pet).conditions('weight < 80') }
# end
#
@ -540,7 +540,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:focus).order('priority desc') }
# end
#
@ -559,7 +559,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:chance).class_name('Opportunity') }
# end
#
@ -577,7 +577,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:contract).dependent(:nullify) }
# end
#
@ -595,7 +595,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:job).with_primary_key('worker_id') }
# end
#
@ -613,7 +613,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:job).with_foreign_key('worker_id') }
# end
#
@ -632,7 +632,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:life).through(:partner) }
# end
#
@ -651,7 +651,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:car).through(:partner).source(:vehicle) }
# end
#
@ -669,7 +669,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_one(:parking_card).validate(false) }
# end
#
@ -687,7 +687,7 @@ module Shoulda
# end
#
# # RSpec
# describe Account do
# RSpec.describe Account, type: :model do
# it { should have_one(:bank).autosave(true) }
# end
#
@ -711,7 +711,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it { should have_and_belong_to_many(:awards) }
# end
#
@ -732,7 +732,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should have_and_belong_to_many(:issues).
# conditions(difficulty: 'hard')
@ -755,7 +755,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should have_and_belong_to_many(:projects).
# order('time_spent')
@ -778,7 +778,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should have_and_belong_to_many(:places_visited).
# class_name('City')
@ -801,7 +801,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should have_and_belong_to_many(:issues).
# join_table('people_tickets')
@ -823,7 +823,7 @@ module Shoulda
# end
#
# # RSpec
# describe Person do
# RSpec.describe Person, type: :model do
# it do
# should have_and_belong_to_many(:interviews).
# validate(false)
@ -845,7 +845,7 @@ module Shoulda
# end
#
# # RSpec
# describe Publisher do
# RSpec.describe Publisher, type: :model do
# it { should have_and_belong_to_many(:advertisers).autosave(true) }
# end
#

View File

@ -9,7 +9,7 @@ module Shoulda
# end
#
# # RSpec
# describe Process do
# RSpec.describe Process, type: :model do
# it { should define_enum_for(:status) }
# end
# end
@ -31,7 +31,7 @@ module Shoulda
# end
#
# # RSpec
# describe Process do
# RSpec.describe Process, type: :model do
# it do
# should define_enum_for(:status).
# with([:running, :stopped, :suspended])

View File

@ -13,7 +13,7 @@ module Shoulda
# end
#
# # RSpec
# describe Phone do
# RSpec.describe Phone, type: :model do
# it { should have_db_column(:supported_ios_version) }
# end
#
@ -37,7 +37,7 @@ module Shoulda
# end
#
# # RSpec
# describe Phone do
# RSpec.describe Phone, type: :model do
# it do
# should have_db_column(:camera_aperture).of_type(:decimal)
# end
@ -63,7 +63,7 @@ module Shoulda
# end
#
# # RSpec
# describe Phone do
# RSpec.describe Phone, type: :model do
# it do
# should have_db_column(:camera_aperture).
# with_options(precision: 1, null: false)

View File

@ -15,7 +15,7 @@ module Shoulda
# end
#
# # RSpec
# describe Blog do
# RSpec.describe Blog, type: :model do
# it { should have_db_index(:user_id) }
# end
#
@ -41,7 +41,7 @@ module Shoulda
# end
#
# # RSpec
# describe Blog do
# RSpec.describe Blog, type: :model do
# it { should have_db_index(:name).unique(true) }
# end
#
@ -54,7 +54,7 @@ module Shoulda
# leave off the argument to save some keystrokes:
#
# # RSpec
# describe Blog do
# RSpec.describe Blog, type: :model do
# it { should have_db_index(:name).unique }
# end
#

View File

@ -9,7 +9,7 @@ module Shoulda
# end
#
# # RSpec
# describe User do
# RSpec.describe User, type: :model do
# it { should have_readonly_attribute(:password) }
# end
#

View File

@ -8,7 +8,7 @@ module Shoulda
# end
#
# # RSpec
# describe Product do
# RSpec.describe Product, type: :model do
# it { should serialize(:customizations) }
# end
#
@ -38,7 +38,7 @@ module Shoulda
# end
#
# # RSpec
# describe Product do
# RSpec.describe Product, type: :model do
# it do
# should serialize(:specifications).
# as(ProductSpecsSerializer)
@ -70,7 +70,7 @@ module Shoulda
# end
#
# # RSpec
# describe Product do
# RSpec.describe Product, type: :model do
# it do
# should serialize(:options).
# as_instance_of(ProductOptionsSerializer)

View File

@ -14,7 +14,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_uniqueness_of(:permalink) }
# end
#
@ -49,7 +49,7 @@ module Shoulda
#
# You may be tempted to test the model like this:
#
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_uniqueness_of(:title) }
# end
#
@ -78,7 +78,7 @@ module Shoulda
# end of the error message, the solution is to build a custom Post object
# ahead of time with `content` filled in:
#
# describe Post do
# RSpec.describe Post, type: :model do
# describe "validations" do
# subject { Post.new(content: "Here is the content") }
# it { should validate_uniqueness_of(:title) }
@ -90,7 +90,7 @@ module Shoulda
# `post` factory defined which automatically fills in `content`, you can
# say:
#
# describe Post do
# RSpec.describe Post, type: :model do
# describe "validations" do
# subject { FactoryGirl.build(:post) }
# it { should validate_uniqueness_of(:title) }
@ -106,7 +106,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_uniqueness_of(:title).on(:create) }
# end
#
@ -124,7 +124,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it do
# should validate_uniqueness_of(:title).
# with_message('Please choose another title')
@ -148,7 +148,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_uniqueness_of(:slug).scoped_to(:journal_id) }
# end
#
@ -169,7 +169,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_uniqueness_of(:key).case_insensitive }
# end
#
@ -201,7 +201,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it do
# should validate_uniqueness_of(:email).ignoring_case_sensitivity
# end
@ -221,7 +221,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_uniqueness_of(:author_id).allow_nil }
# end
#
@ -241,7 +241,7 @@ module Shoulda
# end
#
# # RSpec
# describe Post do
# RSpec.describe Post, type: :model do
# it { should validate_uniqueness_of(:author_id).allow_blank }
# end
#