summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/runner/filters/regexp_spec.rb
blob: 1d1d3554f677fd31f04b82b837bc621c8896f84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require File.dirname(__FILE__) + '/../../spec_helper'
require 'mspec/runner/mspec'
require 'mspec/runner/filters/regexp'

RSpec.describe MatchFilter, "#===" do
  before :each do
    @filter = RegexpFilter.new nil, 'a(b|c)', 'b[^ab]', 'cc?'
  end

  it "returns true if the argument matches any of the #initialize strings" do
    expect(@filter.===('ab')).to eq(true)
    expect(@filter.===('bc suffix')).to eq(true)
    expect(@filter.===('prefix cc')).to eq(true)
  end

  it "returns false if the argument matches none of the #initialize strings" do
    expect(@filter.===('aa')).to eq(false)
    expect(@filter.===('ba')).to eq(false)
    expect(@filter.===('prefix d suffix')).to eq(false)
  end
end

RSpec.describe RegexpFilter, "#to_regexp" do
  before :each do
    @filter = RegexpFilter.new nil
  end

  it "converts its arguments to Regexp instances" do
    expect(@filter.send(:to_regexp, 'a(b|c)', 'b[^ab]', 'cc?')).to eq([/a(b|c)/, /b[^ab]/, /cc?/])
  end
end