зеркало из https://github.com/github/ruby.git
Update to ruby/mspec@072849e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a2c7d0cea9
Коммит
aeeaadaad0
|
@ -1,26 +0,0 @@
|
|||
pkg
|
||||
*.rbc
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
*.sw?
|
||||
|
||||
.rbx
|
||||
|
||||
# ctags dir
|
||||
/tags
|
||||
|
||||
*.gem
|
||||
.bundle
|
||||
.config
|
||||
.yardoc
|
||||
InstalledFiles
|
||||
_yardoc
|
||||
coverage
|
||||
doc/
|
||||
lib/bundler/man
|
||||
rdoc
|
||||
spec/reports
|
||||
test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
|
@ -1,4 +1,3 @@
|
|||
require 'bundler/gem_tasks'
|
||||
require 'bundler/setup'
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
require 'mspec/runner/filters/match'
|
||||
class RegexpFilter
|
||||
def initialize(what, *regexps)
|
||||
@what = what
|
||||
@regexps = to_regexp(*regexps)
|
||||
end
|
||||
|
||||
class RegexpFilter < MatchFilter
|
||||
def to_regexp(*strings)
|
||||
strings.map { |str| Regexp.new str }
|
||||
def ===(string)
|
||||
@regexps.any? { |regexp| regexp === string }
|
||||
end
|
||||
|
||||
def register
|
||||
MSpec.register @what, self
|
||||
end
|
||||
|
||||
def unregister
|
||||
MSpec.unregister @what, self
|
||||
end
|
||||
|
||||
def to_regexp(*regexps)
|
||||
regexps.map { |str| Regexp.new str }
|
||||
end
|
||||
private :to_regexp
|
||||
end
|
||||
|
|
|
@ -2,12 +2,30 @@ 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.to_regexp('a(b|c)', 'b[^ab]', 'cc?').should == [/a(b|c)/, /b[^ab]/, /cc?/]
|
||||
@filter.send(:to_regexp, 'a(b|c)', 'b[^ab]', 'cc?').should == [/a(b|c)/, /b[^ab]/, /cc?/]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,7 @@ rm -rf spec/mspec
|
|||
git clone --depth 1 https://github.com/ruby/mspec.git spec/mspec
|
||||
commit=$(git -C spec/mspec log -n 1 --format='%h')
|
||||
rm -rf spec/mspec/.git
|
||||
rm -f spec/mspec/.travis.yml
|
||||
git add spec/mspec
|
||||
git commit -m "Update to ruby/mspec@${commit}"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче