Sha256: 975a5be16dd0805dcfecd35ad4bb13bd798bd0a05e2e9fed42ac1f9561e06ced

Contents?: true

Size: 1.23 KB

Versions: 19

Compression:

Stored size: 1.23 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')
      selected = matcher.select_from(
        'comments#update' => 'comments#update',
        'comments#up'     => 'comments#up',
        'comments#up$'   => 'comments#up$',
        'comments#up.+$' => 'comments#up.+$',
      )
      _(selected).must_be :==, ['comments#update', 'comments#up.+$']

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

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

end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
merit-4.0.3 test/unit/rules_matcher_test.rb
qalam_merit-4.5.12 test/unit/rules_matcher_test.rb
merit-4.0.2 test/unit/rules_matcher_test.rb
qalam_merit-4.5.11 test/unit/rules_matcher_test.rb
qalam_merit-4.5.10 test/unit/rules_matcher_test.rb
qalam_merit-4.5.09 test/unit/rules_matcher_test.rb
qalam_merit-4.5.08 test/unit/rules_matcher_test.rb
qalam_merit-4.5.07 test/unit/rules_matcher_test.rb
qalam_merit-4.5.06 test/unit/rules_matcher_test.rb
qalam_merit-4.5.05 test/unit/rules_matcher_test.rb
qalam_merit-4.5.04 test/unit/rules_matcher_test.rb
qalam_merit-4.5.03 test/unit/rules_matcher_test.rb
qalam_merit-4.5.02 test/unit/rules_matcher_test.rb
qalam_merit-4.5.01 test/unit/rules_matcher_test.rb
qalam_merit-4.5.00 test/unit/rules_matcher_test.rb
qalam_merit-4.0.4 test/unit/rules_matcher_test.rb
qalam_merit-4.0.35 test/unit/rules_matcher_test.rb
merit-4.0.1 test/unit/rules_matcher_test.rb
merit-4.0.0 test/unit/rules_matcher_test.rb