summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/runner/filters/regexp_spec.rb
blob: 8e9b0ec7e899b065f244fe4811e1ce82a38ba0dc (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'

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
    @filter.===('ab').should == true
    @filter.===('bc suffix').should == true
    @filter.===('prefix cc').should == true
  end

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

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

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