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.


Saturday 11 April 2020

An MCU Movie Musing

Chronological order of the Marvel Comic Universe

These are notes to make it easier for me to binge-watch the MCU during this time of lockdown in the UK.

I have seen them all in the cinema, but currently abusing my Disney+ subscription.


  • Captain America: The First Avenger (2011)
  • Captain Marvel (2019)
  • Iron Man (2008)
  • Iron Man 2 (2010)
  • The Incredible Hulk (2008)
  • Thor (2011)
  • The Avengers (2012)
  • Iron Man 3 (2013)
  • Thor: The Dark World (2013)
  • Captain America: The Winter Soldier (2014)
  • Guardians of the Galaxy (2014)
  • Guardians of the Galaxy Vol. 2 (2017)
  • Avengers: Age of Ultron (2014)
  • Ant-Man (2015)
  • Captain America: Civil War (2016)
  • Spider-Man: Homecoming (2017)
  • Doctor Strange (2016)
  • Black Panther (2018)
  • Thor: Ragnarok (2017)
  • Ant-Man and The Wasp (2018)
  • Black Widow (2020)
  • Avengers: Infinity War (2018)
  • Avengers: Endgame (2019)
  • Spiderman: Far From Home (2019)

Thursday 5 December 2019

Golang and private gitlab repos and 410 Gone

I've been following a microservices with golang tutorial recently, and needed to refer to one project from another.

After getting numerous errors with `go get` and much searching for answers, I stumbled across this solution.

In Gitlab add a personal access token.

In your ~/.netrc file add:

machine gitlab.com
  login {{personal_access_token_name}}
  password {{personal_access_token}}


Replacing the prompts with the actual values.

In your .bashrc add

export GOPRIVATE="gitlab.com/{{path_to_project}}"


This is working for me, a similar approach may well work with bitbucket or codebasehq.

Sunday 3 March 2019

OSX and image not found readline.bundle

Something changed recently in my osx configuration, I'm not sure what, but it broke readline on the macbook.

The key part of the error message  was:

Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
  Referenced from: /Users/stokern/.rbenv/versions/2.5.3/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle
  Reason: image not found - /Users/stokern/.rbenv/versions/2.5.3/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle


The fix was to add the ruby readline gem:

group :development, :test do
  ...
  gem 'rb-readline'
end

This is the second time this has caught me out, so I thought I'd document it.

You're welcome

Saturday 17 November 2018

OS X Unable to build mysql2 gem


The problem:
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
The solution:
gem install mysql2 -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\"

Note that these are mainly notes to myself, but if you find them helpful then you're welcome.

Monday 22 October 2018

rails-sass is deprecated

I've been seeing this for a while, and have finally got round to finding a solution.

In the project `Gemfile`, remove the reference to `sass-rails` and replace with `sassc`.

Sigh. It took more than two minutes to find the fix, so logging it here

Saturday 7 July 2018

NameError: uninitialized constant RailsERD

This has been an occasional annoyance when setting up new Rails projects with the rails-erd gem.

The documentation for the gem is to add

gem 'rails-erd', :require=>false

into the Gemfile, and then run rails g erd:install to add the hook to run when a rails db:migrate is carried out.

I found that this creates /lib/tasks/auto_generate_diagram.rake containing

if Rails.env.development?
  RailsERD.load_tasks
end


One solution is to remove the :require=>false from the Gemfile, but apparently this may have an impact on efficiency rails erd issue 282.

I tried a slightly different approach, and changed /lib/tasks/auto_generate_diagram.rake to require the gem.

if Rails.env.development?
  require 'rails-erd'
  RailsERD.load_tasks
end