Aleksey Bakin
Aleksey Bakin

Reputation: 1536

RSpec: should have_selector failed, but title is present

I've google and read stackoverflow about 4 hours, but cannot understand, why test similar to rails tutorial fail.

Test is very simple:


# encoding: utf-8

require 'spec_helper'

describe "StaticPages" do
  subject { page }

  describe "Contacts page" do
    before { visit contacts_path }

    it { should have_selector(:title, text: "|") }
  end
end

So, I add save_and_open_page to see, what's wrong with my Contacts page, but it's looks good. Title tag is present and contain "|".

I cannot understand, what's wrong. I've:

Also I tryed to understand, how to improve rspec output to more infomative. At now I see:

Failure/Error: it { should have_selector(:title, text: "|") }
       expected id :title with text "|" to return something

Upvotes: 0

Views: 2708

Answers (1)

Rustam Gasanov
Rustam Gasanov

Reputation: 15781

As I know have_selector is a Capybara matcher and according to the tutorial as a first argument you can use an html element name in quotes or a xpath notation, but not a symbol.

Upvotes: 1

Related Questions