Skip to content

Conversation

@tbprojects
Copy link
Contributor

see, not_see and click can also work with objects, that respond to overwritten to_s method. Example: You have list of users and you want navigate to someone's profile

Model:

class User < ActiveRecord::Base
  def to_s
    full_name
  end

  def full_name
    "#{first_name} #{last_name}"
  end
end

HTML:

<ul>
  <li><a href="/profile/mc"/>Michal Czyz</a></li>
  <li><a href="/profile/tb"/>Tomasz Bak</a></li>
</ul>

Spec:

user = User.create(first_name: 'Michal', last_name: 'Czyz')
...
see user
click user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant