Reputation: 5329
How can a regex be stubed? e.g.
# somewhere deep in the code
reg = Regexp.new("foo bar")
res = reg.match string
# somewhere in rspec
reg = Regexp.new("foo bar")
reg.stub(:match).with(string).and_return "rspec_res" #doesn't work
Upvotes: 0
Views: 489
Reputation: 10738
I think this should work:
reg = stub :match => "rspec_res"
Regex.stub(:new) { reg }
Upvotes: 1