I'm giving a try to Apotonick's Trailblazer gem, which brings more structure on top of Rails, and I really like what I tried so far, while not having embraced all of it yet. And this is one strength of Trailblazer, you can dive into it progressively, bringing it step by step into your Rails projects. I bought the Trailblazer book, which I'm following now and that leads to my question.
I'm working on the sample app ( @see https://github.com/apotonick/gemgem-trbrb ) but I'm using rspec.
I wanted to test cells output in isolation. In the book, the testing framework is Test::Unit and some helper methods ship with cells for Test::Unit.
With rspec it's another story ... I tried rspec-cells but it seems not to work with current cells version (4.0), which is used in Trailblazer. So I tried to do some salmon coding, the goal being to have the smallest setup possible for retreiving the cell's output. This led to a module with a simple helper
Here is the code (also here : https://github.com/demental/gemgem-trbrb/blob/3ec9df1d5f45b880f834486da3c150d4b65ec627/spec/support/cells.rb )
module Cell
module Rspec
private
def concept(name, *args)
controller_stub = double(
url_options: {
host: '',
optional_port: 80,
protocol: 'http',
path_parameters: ''
}
)
Capybara.string(Cell::Concept.cell name, controller_stub, *args)
end
end
end
RSpec.configure do |config|
config.include Cell::Rspec, type: :cell
end
The reason why I needed to make a stubbed url_options method was for the pathHelpers methods to work in cell views, without having to setup a full controller (with a full request object).
I like it in a way that it makes a very minimalistic setup. But I'm wondering if it's not gone too dummy, as I just mimic a controller, but I am feel like I don't get rid of its dependency. What do you think ?