Sha256: d7617198abc68ab09e1c27ad4ed6d35b164a6c93e50ee828bfaecaf6e903260a

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices::Core
  describe Check::Exceptable do
    let(:method) { Method.new 'BlogPost', 'approve', 'public', {} }

    context 'wildcard class and method' do
      let(:except_method) { '*#*' }

      it 'matches' do
        expect(Check::Exceptable.matches(method, except_method)).to eql true
      end
    end

    context 'wildcard class and matching explicit method' do
      let(:except_method) { '*#approve' }

      it 'matches' do
        expect(Check::Exceptable.matches(method, except_method)).to eql true
      end
    end

    context 'wildcard class and non-matching explicit method' do
      let(:except_method) { '*#disapprove' }

      it 'matches' do
        expect(Check::Exceptable.matches(method, except_method)).to eql false
      end
    end

    context 'matching class and wildcard method' do
      let(:except_method) { 'BlogPost#*' }

      it 'matches' do
        expect(Check::Exceptable.matches(method, except_method)).to eql true
      end
    end

    context 'non-matching class and wildcard method' do
      let(:except_method) { 'User#*' }

      it 'matches' do
        expect(Check::Exceptable.matches(method, except_method)).to eql false
      end
    end

    context 'matching class and matching method' do
      let(:except_method) { 'BlogPost#approve' }

      it 'matches' do
        expect(Check::Exceptable.matches(method, except_method)).to eql true
      end
    end

    context 'non-matching class and non-matching method' do
      let(:except_method) { 'User#disapprove' }

      it 'matches' do
        expect(Check::Exceptable.matches(method, except_method)).to eql false
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_best_practices-1.20.0 spec/rails_best_practices/core/except_methods_spec.rb
rails_best_practices-1.19.5 spec/rails_best_practices/core/except_methods_spec.rb
rails_best_practices-1.19.4 spec/rails_best_practices/core/except_methods_spec.rb
rails_best_practices-1.19.3 spec/rails_best_practices/core/except_methods_spec.rb
rails_best_practices-1.19.2 spec/rails_best_practices/core/except_methods_spec.rb