Fix test suite to properly tag example groups

When running unit tests we need to ensure that we are simulating how
other people will use the matchers as best we can. This means, for
instance, tagging any example groups that test controller matchers as
controller example groups.
This commit is contained in:
Elliot Winkler 2014-12-24 16:37:04 -05:00
parent 5aed533412
commit d86fe2d1c0
33 changed files with 35 additions and 38 deletions

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::CallbackMatcher do
describe Shoulda::Matchers::ActionController::CallbackMatcher, type: :controller do
shared_examples 'CallbackMatcher' do |kind, callback_type|
let(:kind) { kind }
let(:callback_type) { callback_type }

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::FilterParamMatcher do
describe Shoulda::Matchers::ActionController::FilterParamMatcher, type: :controller do
it 'accepts filtering a filtered parameter' do
filter(:secret)

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RedirectToMatcher do
describe Shoulda::Matchers::ActionController::RedirectToMatcher, type: :controller do
context 'a controller that redirects' do
it 'accepts redirecting to that url' do
expect(controller_redirecting_to('/some/url')).to redirect_to('/some/url')

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RenderTemplateMatcher do
describe Shoulda::Matchers::ActionController::RenderTemplateMatcher, type: :controller do
include ActionController::TemplateAssertions
context 'a controller that renders a template' do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher do
describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher, type: :controller do
include ActionController::TemplateAssertions
context 'a controller that renders with a layout' do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RescueFromMatcher do
describe Shoulda::Matchers::ActionController::RescueFromMatcher, type: :controller do
context 'a controller that rescues from RuntimeError' do
it 'asserts controller is setup with rescue_from' do
expect(controller_with_rescue_from).to rescue_from RuntimeError

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RespondWithMatcher do
describe Shoulda::Matchers::ActionController::RespondWithMatcher, type: :controller do
statuses = { success: 200, redirect: 301, missing: 404, error: 500,
not_implemented: 501 }

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RouteParams do
describe Shoulda::Matchers::ActionController::RouteParams, type: :controller do
describe "#normalize" do
context "when the route parameters is a hash" do
it "stringifies the values in the hash" do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController do
describe Shoulda::Matchers::ActionController, type: :controller do
describe '#set_the_flash' do
it 'is deprecated in favor of #set_flash' do
expect { set_the_flash }.to deprecate(:set_the_flash, :set_flash)

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController, '#set_session' do
describe Shoulda::Matchers::ActionController, '#set_session', type: :controller do
context 'passing an argument to the initializer' do
it 'is deprecated in favor of using #[]' do
expectation = proc { set_session(:foo) }

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController do
describe Shoulda::Matchers::ActionController, type: :controller do
describe '#permit' do
it 'matches when the sent parameter is allowed' do
controller_for_resource_with_strong_parameters(action: :create) do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::AllowMassAssignmentOfMatcher do
describe Shoulda::Matchers::ActiveModel::AllowMassAssignmentOfMatcher, type: :model do
context '#description' do
context 'without a role' do
it 'includes the attribute name' do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::AllowValueMatcher do
describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do
context "#description" do
it 'describes itself with multiple values' do
matcher = allow_value('foo', 'bar').for(:baz)

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher do
describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher, type: :model do
context 'an attribute with a format validation' do
it 'does not match if the value is allowed' do
expect(validating_format(with: /abc/)).not_to matcher('abcde').for(:attr)

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ExceptionMessageFinder do
describe Shoulda::Matchers::ActiveModel::ExceptionMessageFinder, type: :model do
if active_model_3_2?
context '#allow_description' do
it 'describes its attribute' do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::HaveSecurePasswordMatcher do
describe Shoulda::Matchers::ActiveModel::HaveSecurePasswordMatcher, type: :model do
if active_model_3_1?
it 'matches when the subject configures has_secure_password with default options' do
working_model = define_model(:example, password_digest: :string) { has_secure_password }

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateAbsenceOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidateAbsenceOfMatcher, type: :model do
if active_model_4_0?
def self.available_column_types
[

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateAcceptanceOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidateAcceptanceOfMatcher, type: :model do
context 'a model with an acceptance validation' do
it 'accepts when the attributes match' do
expect(validating_acceptance).to matcher

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateConfirmationOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidateConfirmationOfMatcher, type: :model do
include UnitTests::ConfirmationMatcherHelpers
context '#description' do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel do
describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#ensure_exclusion_of' do
it 'is aliased to #validate_exclusion_of' do
allow(matchers).to receive(:validate_exclusion_of)
@ -17,7 +17,7 @@ describe Shoulda::Matchers::ActiveModel do
end
end
describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher, type: :model do
context 'an attribute which must be excluded from a range' do
it 'accepts ensuring the correct range' do
expect(validating_exclusion(in: 2..5)).

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel do
describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#ensure_inclusion_of' do
it 'is aliased to #validate_inclusion_of' do
allow(matchers).to receive(:validate_inclusion_of)
@ -17,7 +17,7 @@ describe Shoulda::Matchers::ActiveModel do
end
end
describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :model do
shared_context 'for a generic attribute' do
def self.testing_values_of_option(option_name, &block)
[nil, true, false].each do |option_value|

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel do
describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#ensure_length_of' do
it 'is aliased to #validate_length_of' do
allow(matchers).to receive(:validate_length_of)
@ -17,7 +17,7 @@ describe Shoulda::Matchers::ActiveModel do
end
end
describe Shoulda::Matchers::ActiveModel::ValidateLengthOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidateLengthOfMatcher, type: :model do
context 'an attribute with a non-zero minimum length validation' do
it 'accepts ensuring the correct minimum length' do
expect(validating_length(minimum: 4)).

View File

@ -1,7 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher, type: :model do
context 'with a model with a numericality validation' do
it 'accepts' do
expect(validating_numericality).to matcher

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher do
describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher, type: :model do
context 'a model with a presence validation' do
it 'accepts' do
expect(validating_presence).to matcher

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher do
describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :model do
context 'a model without a a uniqueness validation' do
it 'rejects' do
model = define_model(:example, attr: :string) { attr_accessible :attr } .new

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher do
describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher, type: :model do
it 'accepts an existing declaration' do
expect(accepting_children).to accept_nested_attributes_for(:children)
end

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
context 'belong_to' do
it 'accepts a good association with the default foreign key' do
expect(belonging_to_parent).to belong_to(:parent)

View File

@ -1,6 +1,6 @@
require "unit_spec_helper"
describe Shoulda::Matchers::ActiveRecord::DefineEnumForMatcher do
describe Shoulda::Matchers::ActiveRecord::DefineEnumForMatcher, type: :model do
if active_record_supports_enum?
describe "with only the attribute name specified" do
it "accepts a record where the attribute is defined as an enum" do

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveDbColumnMatcher do
describe Shoulda::Matchers::ActiveRecord::HaveDbColumnMatcher, type: :model do
it 'accepts an existing database column' do
expect(model(nickname: :string)).to have_db_column(:nickname)
end

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveDbIndexMatcher do
describe Shoulda::Matchers::ActiveRecord::HaveDbIndexMatcher, type: :model do
context 'have_db_index' do
it 'accepts an existing index' do
expect(with_index_on(:age)).to have_db_index(:age)

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveReadonlyAttributeMatcher do
describe Shoulda::Matchers::ActiveRecord::HaveReadonlyAttributeMatcher, type: :model do
context 'a read-only attribute' do
it 'accepts' do
expect(with_readonly_attr).to have_readonly_attribute(:attr)

View File

@ -1,6 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::SerializeMatcher do
describe Shoulda::Matchers::ActiveRecord::SerializeMatcher, type: :model do
it 'accepts when the attribute is serialized' do
expect(with_serialized_attr).to serialize(:attr)
end

View File

@ -45,8 +45,6 @@ RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end
config.include Shoulda::Matchers::ActionController, type: :controller
UnitTests::ActiveModelHelpers.configure_example_group(config)
UnitTests::ActiveModelVersions.configure_example_group(config)
UnitTests::ActiveResourceBuilder.configure_example_group(config)