Last active
December 16, 2015 15:19
-
-
Save alfius/5454603 to your computer and use it in GitHub Desktop.
How to create an RSpec matcher that allows testing whether a page is indexable by search engines or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#spec/features/home_spec.rb | |
require 'spec_helper' | |
describe 'Home page' do | |
it 'should be searchable' do | |
visit '/' | |
page.should be_searchable | |
end | |
end | |
#spec/support/searchability.rb | |
RSpec::Matchers::define :be_searchable do | |
match do |page| | |
!page.has_selector?('meta[name="robots"][content="noindex,nofollow"]', :visible => false) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment