I made some progress on this.
If something is a class, like “page” in the Hartl tutorial (like on say spec/requests/static_pages_spec.rb)
you could just do
1 |
puts "Here is page.class: #{page.class}" |
which would give you
1 |
Here is page.class: Capybara::Session |
I don’t know why I didn’t think of that before.
In that file he also calls some voodoo methods. In before do he has:
1 |
sign_in FactoryGirl.create(:user) |
and
1 |
visit users_path |
sign_in and visit are methods. You can get these by doing this:
1 2 3 4 |
meth = self.method(:sign_in) puts "Here is method of sign_in: #{meth.owner}" meth2 = self.method(:visit) puts "Here is method of visit: #{meth2.owner}" |
or you could do that on one line each like this:
1 2 |
puts "Here is method of sign_in: #{self.method(:sign_in).owner} " puts "Here is method of visit: #{self.method(:visit).owner} " |
Which will give you:
1 2 |
Here is method of sign_in: Object Here is method of visit: Capybara::DSL |
Granted, getting “Object” is not too helpful. But it is some progress.
Someone on the Rails core team has a post about finding methods here.