Class: Spec::Matchers::SpecExtensions::HaveVariable
Instance Method Summary
collapse
#ensured_as, #grab_entry, #is_valid_resource?
Constructor Details
#initialize(varname, expected, extra = "") ⇒ HaveVariable
Returns a new instance of HaveVariable.
5
6
7
8
9
|
# File 'lib/poolparty/spec/matchers/have_variable.rb', line 5
def initialize(varname, expected,="")
@varname = varname
@expected = expected
=
end
|
Instance Method Details
#failure_message ⇒ Object
17
18
19
|
# File 'lib/poolparty/spec/matchers/have_variable.rb', line 17
def failure_message
"expected #{@target.inspect} to have variable #{@expected}"
end
|
#is_present? ⇒ Boolean
14
15
16
|
# File 'lib/poolparty/spec/matchers/have_variable.rb', line 14
def is_present?
@target.match(/\$#{@varname}(\W+)=(\W+)#{@expected}/)[0]
end
|
#matches?(target) ⇒ Boolean
10
11
12
13
|
# File 'lib/poolparty/spec/matchers/have_variable.rb', line 10
def matches?(target)
@target = target
is_present?
end
|
#negative_failure_message ⇒ Object
20
21
22
|
# File 'lib/poolparty/spec/matchers/have_variable.rb', line 20
def negative_failure_message
"expected #{@target.inspect} not to have variable #{@expected}"
end
|
23
24
25
|
# File 'lib/poolparty/spec/matchers/have_variable.rb', line 23
def type
"variable"
end
|