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.



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

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.



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

def current_path
  @current_path
end

#failure_messageObject (readonly) Also known as: failure_message_for_should

Returns the value of attribute failure_message.



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

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.



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

def failure_message_when_negated
  @failure_message_when_negated
end

Instance Method Details

#descriptionObject



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

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

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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