Chris Gilbert

Joined

30 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Rails Components From Scratch Discussion

Great. That was a really useful video, thanks Chris!

Posted in Rails Components From Scratch Discussion

I guess you could write a view spec and do this:

render Button.new(to: "some-path")
expect(rendered).to include("href=\"some-path\"")

Posted in Rails Components From Scratch Discussion

This is great! I wonder how easy it would be to get unit tests setup to do this kind of thing:

button = Components::Button.new(text: "Click me")
result = button.render_in(view_context)
expect(result).to include("Click me")

Using RSpec, I could imagine creating "component" type tests where the view_context is available in them. I don't actually know how to make it available but i'd love to know how.