
Zeff
Sustainable Web Development with Ruby on Rails:
Title: Sustainable Web Development with Ruby on Rails: Regex incorrect (testing Helpers section)
This code fails:
“# test/helpers/application_helper_test.rb
class ApplicationHelperTest < ActionView::TestCase
test “styled_widget_id” do
rendered_component = styled_widget_id(“1.23”)
→
→ regexp = %r{
→ <span # match a span tag
→ [^>]* # ignore anything that isn’t >
→ > # match the > to close the opening tag
→ .* # anything at all in here (e.g. other tags)
→ 1.23 # the widget ID we expect, escaping the dot
→ .* # anything after it (e.g. other tags)
→ # closing span tag
→ }x
assert_match regexp, rendered_component
assert rendered_component.html_safe?
end
end
The line:
→ [^>]* # ignore anything that isn’t >
should be:
→ .* # ignore anything that isn’t >
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /react-native
- /v
- /wasm
- /django
- /security
- /nodejs
- /centos
- /rails
- /haskell
- /fable
- /gleam
- /swift
- /js
- /deno
- /tailwind
- /assemblyscript
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /c-plus-plus
- /preact
- /flutter
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /keyboards
- /html
- /emacs
- /nim
- /vuejs
- /nerves
- /elm