ministryofjustice / govuk_elements_form_builder

Form builder helper methods to develop GOV.UK elements styled applications in Ruby on Rails
https://govuk-elements-rails-guide.herokuapp.com/
MIT License
6 stars 14 forks source link

Make specs less brittle by replacing HTML comparison with matchers #108

Closed peteryates closed 5 years ago

peteryates commented 5 years ago

When we forked this library in December 2018 the first step on the way to making it Design System compliant (#105) was to make the specs easier to work with, namely by removing the chunks of HTML and replacing them with RSpec HTML Matchers. This will provide extra flexibility when underlying versions change and the output format/indentation changes slightly, plus it makes the library easier to work with in general.

This PR includes just our fixing of the specs and omits all of the Design System migration stuff added later.

Note, I'm struggling to get Ruby 2.3.1 running on my machine so can't test locally 😞 I don't know whether a version bump would be welcome here - if the tests all pass I think that would make a logical next step. If some fail then we can work out how to solve it then!

zheileman commented 5 years ago

Happy for this PR to be merged. It will definitely improve the overall legibility of the tests. There is some kind of missing current_scope in the specs but might be some missing code.

Ideally we would maintain the same Ruby version, because I know at least of a project still stuck in Ruby 2.3.x and might not be possible to get them to update. I can give it a try locally later today.

I've added you as a collaborator so hopefully that let you merge approved PRs, like the README one. Let me know if you still can't.

peteryates commented 5 years ago

Yeah, I'll get to the bottom of this and fix it. I cherry-picked just the tidying up commits and clearly need one of the prior adjustments too.

peteryates commented 5 years ago

Ok, so the trick to getting Ruby 2.3.1 installed on a modern macOS environment is

RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline` --with-libyaml-dir=`brew --prefix libyaml`" rbenv install 2.3.1