File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 1
1
require 'pact/shared/active_support_support'
2
2
require 'json/add/regexp'
3
+ require 'pact/errors'
3
4
4
5
module Pact
5
6
class Term
@@ -25,9 +26,9 @@ def self.unpack_regexps source
25
26
def initialize ( attributes = { } )
26
27
@generate = attributes [ :generate ]
27
28
@matcher = attributes [ :matcher ]
28
- raise "Please specify a matcher for the Term" unless @matcher != nil
29
- raise "Please specify a value to generate for the Term" unless @generate != nil
30
- raise "Value to generate \" #{ @generate } \" does not match regular expression #{ @matcher . inspect } " unless @generate =~ @matcher
29
+ raise Pact :: Error . new ( "Please specify a matcher for the Term" ) unless @matcher != nil
30
+ raise Pact :: Error . new ( "Please specify a value to generate for the Term" ) unless @generate != nil
31
+ raise Pact :: Error . new ( "Value to generate \" #{ @generate } \" does not match regular expression #{ @matcher . inspect } " ) unless @generate =~ @matcher
31
32
end
32
33
33
34
def to_hash
Original file line number Diff line number Diff line change @@ -17,20 +17,20 @@ module Pact
17
17
context "when the matcher does not match the generated value" do
18
18
let ( :generate ) { 'banana' }
19
19
it 'raises an exception' do
20
- expect { subject } . to raise_error /does not match/
20
+ expect { subject } . to raise_error Pact :: Error , /does not match/
21
21
end
22
22
end
23
23
end
24
24
context 'when a matcher is not specified' do
25
25
let ( :matcher ) { nil }
26
26
it 'raises an exception' do
27
- expect { subject } . to raise_error /Please specify a matcher/
27
+ expect { subject } . to raise_error Pact :: Error , /Please specify a matcher/
28
28
end
29
29
end
30
30
context 'when a generate is not specified' do
31
31
let ( :generate ) { nil }
32
32
it 'raises an exception' do
33
- expect { subject } . to raise_error /Please specify a value/
33
+ expect { subject } . to raise_error Pact :: Error , /Please specify a value/
34
34
end
35
35
end
36
36
end
You can’t perform that action at this time.
0 commit comments