Printing a variable to console in Haml for Rspec debugging
Just landed on a Rails 3 app that uses haml. I am running Rspec tests and trying to print the value of a variable to the console. In erb or any .rb file, you simply do:
p my_variable.inspect or even string interpolation:
p "this is my variable # {my_variable}" So when I run my Rspec tests I get a nice console printout evaluating my variables. So how do you do this in Haml?
+3
source to share
2 answers
this is as annoying as the "p" variables are for me and then searches for their results. Use better https://github.com/rweng/pry-rails and then just take a look at
- binding.pry
and then in the console you can debug variables and other things :)
+5
source to share