1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Fix retrieval of session_options for RSpec matcher descriptions

This commit is contained in:
Thomas Walpole 2017-06-27 10:14:50 -07:00
parent 75436b4e4a
commit 442c8d2977
2 changed files with 53 additions and 1 deletions

View file

@ -45,7 +45,13 @@ module Capybara
def session_options
@context_el ||= nil
@context_el ? @context_el.session_options : Capybara.session_options
if @context_el.respond_to? :session_options
@context_el.session_options
elsif @context_el.respond_to? :current_scope
@context_el.current_scope.session_options
else
Capybara.session_options
end
end
end

View file

@ -0,0 +1,46 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Capybara RSpec Matchers', :type => :feature, focus_: true do
context "after called on session" do
it "HaveSelector should allow getting a description of the matcher" do
visit('/with_html')
matcher = have_selector(:css, 'h2.head', minimum: 3)
expect(page).to matcher
expect { matcher.description }.not_to raise_error
end
it "HaveText should allow getting a description" do
visit('/with_html')
matcher = have_text("Lorem")
expect(page).to matcher
expect { matcher.description }.not_to raise_error
end
end
context "after called on element" do
it "HaveSelector should allow getting a description" do
visit('/with_html')
el = find(:css, '#first')
matcher = have_selector(:css, 'a#foo')
expect(el).to matcher
expect { matcher.description }.not_to raise_error
end
it "MatchSelector should allow getting a description" do
visit('/with_html')
el = find(:css, '#first')
matcher = match_selector(:css, '#first')
expect(el).to matcher
expect { matcher.description }.not_to raise_error
end
it "HaveText should allow getting a description" do
visit('/with_html')
el = find(:css, '#first')
matcher = have_text("Lorem")
expect(el).to matcher
expect { matcher.description }.not_to raise_error
end
end
end