Showing posts with label RSpec. Show all posts
Showing posts with label RSpec. Show all posts

Tuesday, 27 June 2023

RSpec and comments in HTML

I needed to get at the html comment embedded in a page (don't ask why, it was part of the task I was given)

HTML comments were in the form:

<!-- Message: this is an embedded comment -->

Using the usual RSpec 

expect(page).to have_text('Message') doesn't work, as html comments are non-visible.

A way of getting around this is to use

expect(page.native.inner_html).to include('<!-- Message: this is an embedded comment -->')

does work.


This is a note for the next time I hit the problem.


Thursday, 19 January 2017

RSpec failing after a new Rails Composer project



RSpec issues

Add
require 'rails_helper.rb'
into the spec files to allow the tests to run as expected.

spec/features/visitors/sign_up_spec.rb

The minimum password length is set to be 6 characters, but the 'expected fail' password was set to 'please', causing the test to fail.

Changed password to 'short' and test passes.

spec/features/users/sign_in_spec.rb

The tests were looking for an authentication_key of 'email'. Changed to 'Email' to match the results from Devise.