Sha256: 675eb883ba0cb7520ce7e4e7144e0389e9946c62ab4cbf93b8f3ce7f974f77fd

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'test_helper'

describe Merit::RulesMatcher do

  describe 'rules actions are treated as a regexp' do
    it 'selects matching rules (suffix)' do
      matcher = Merit::RulesMatcher.new('comments', 'update')
      matcher.select_from({
        'comments#update' => 'comments#update',
        'comments#up'     => 'comments#up',
        'comments#up$'   => 'comments#up$',
        'comments#up.+$' => 'comments#up.+$',
      }).must_be :==, ['comments#update', 'comments#up.+$']

      matcher = Merit::RulesMatcher.new('comments', 'up')
      matcher.select_from({
        'comments#update' => 'comments#update',
        'comments#up'     => 'comments#up',
        'comments#up$'   => 'comments#up$',
        'comments#up.+$' => 'comments#up.+$',
      }).must_be :==, ['comments#up', 'comments#up$']
    end

    it 'selects matching rules (prefix)' do
      matcher = Merit::RulesMatcher.new('/posts/1/comments', 'create')
      matcher.select_from({
        'comments#create' => 'comments#create',
        '^comments#create' => '^comments#create',
        '^.*/comments#create' => '^.*/comments#create',
      }).must_be :==, ['^.*/comments#create']
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
merit-1.9.0 test/unit/rules_matcher_test.rb
merit-1.8.0 test/unit/rules_matcher_test.rb
merit-1.7.1 test/unit/rules_matcher_test.rb
merit-1.7.0 test/unit/rules_matcher_test.rb