Skip to content

Commit

Permalink
Fixed a bug in finding the deciding on the type and setting the id of…
Browse files Browse the repository at this point in the history
… a find without an id
  • Loading branch information
Bert Hajee authored and Bert Hajee committed Jun 13, 2013
1 parent f81bcd1 commit 9926b9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/page_record/class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class PageRecord
def self.inherited(base)
base.class_eval do
@base_name = base.to_s.gsub('Page', '')
@type = @base_name.downcase
@type = @base_name.underscore
@host_class = @base_name.constantize
@attributes = @host_class.attribute_names.clone
@attributes.delete('id') # id is a special case attribute
Expand Down
1 change: 1 addition & 0 deletions lib/page_record/page_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def initialize(id="", selector="", filter="")
begin
context = self.class.context_for_selector(selector)
@record = context.find("[data-#{@type}-id#{id_text}]#{filter}")
@id = @record["data-#{@type}-id"] if @id.blank?
rescue Capybara::Ambiguous
raise MultipleRecords, "Found multiple #{@type} record with id #{@id} on page"
rescue Capybara::ElementNotFound
Expand Down

0 comments on commit 9926b9f

Please sign in to comment.