From c4387c9f43f7c0625e19a3f5d90377f012fdbb69 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 25 Jan 2013 08:43:49 -0500 Subject: [PATCH 1/2] refine some finders --- lib/semantic_rails_view_helpers/capybara.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/semantic_rails_view_helpers/capybara.rb b/lib/semantic_rails_view_helpers/capybara.rb index 2120cf4..3526179 100644 --- a/lib/semantic_rails_view_helpers/capybara.rb +++ b/lib/semantic_rails_view_helpers/capybara.rb @@ -106,11 +106,17 @@ def within_object(object, &block) end def object_matcher(object) - "[data-id='#{object.id}'][data-type='#{object.class}']" + if object.respond_to?(:id) + match = "[data-type='#{object.class}'][data-id='#{object.id}']" + elsif object.kind_of?(::Class) + match = "[data-type='#{object}']" + end + + match end def within_object_of_type(klass, &block) - within("[data-type='#{klass}']", &block) + within_object(klass, &block) end def within_any(search, &block) From 4dffc6c84f281e766f26ebad8c3ba5ae134cd831 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 8 Feb 2013 08:08:40 -0500 Subject: [PATCH 2/2] have dont_find methods check twice, once now, once after Capybara.default_wait_time --- lib/semantic_rails_view_helpers/capybara.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/semantic_rails_view_helpers/capybara.rb b/lib/semantic_rails_view_helpers/capybara.rb index 3526179..93fbad3 100644 --- a/lib/semantic_rails_view_helpers/capybara.rb +++ b/lib/semantic_rails_view_helpers/capybara.rb @@ -77,6 +77,10 @@ end def dont_find_wrap(search) yield + sleep Capybara.default_wait_time + + yield + raise Capybara::ElementFound.new(search) rescue Capybara::ElementNotFound true