Class: Capybara::RSpecMatchers::HaveCurrentPath

Inherits:
Matcher
  • Object
show all
Defined in:
lib/capybara/rspec/matchers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#wrap

Constructor Details

#initialize(*args) ⇒ HaveCurrentPath

Returns a new instance of HaveCurrentPath.



131
132
133
134
135
136
# File 'lib/capybara/rspec/matchers.rb', line 131

def initialize(*args)
  @args = args

  # are set just for backwards compatability
  @current_path = args.first
end

Instance Attribute Details

#current_pathObject (readonly)

Returns the value of attribute current_path.



127
128
129
# File 'lib/capybara/rspec/matchers.rb', line 127

def current_path
  @current_path
end

#failure_messageObject (readonly) Also known as: failure_message_for_should

Returns the value of attribute failure_message.



129
130
131
# File 'lib/capybara/rspec/matchers.rb', line 129

def failure_message
  @failure_message
end

#failure_message_when_negatedObject (readonly) Also known as: failure_message_for_should_not

Returns the value of attribute failure_message_when_negated.



129
130
131
# File 'lib/capybara/rspec/matchers.rb', line 129

def failure_message_when_negated
  @failure_message_when_negated
end

Instance Method Details

#descriptionObject



152
153
154
# File 'lib/capybara/rspec/matchers.rb', line 152

def description
  "have current path #{current_path.inspect}"
end

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


145
146
147
148
149
150
# File 'lib/capybara/rspec/matchers.rb', line 145

def does_not_match?(actual)
  wrap(actual).assert_no_current_path(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message_when_negated = e.message
  return false
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


138
139
140
141
142
143
# File 'lib/capybara/rspec/matchers.rb', line 138

def matches?(actual)
  wrap(actual).assert_current_path(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message = e.message
  return false
end