more cool stuff
This commit is contained in:
parent
40b24799af
commit
e05a88d340
|
@ -67,5 +67,34 @@ def dont_find_object(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_object(object)
|
def find_object(object)
|
||||||
find("[data-id='#{object.id}']")
|
find(object_matcher(object))
|
||||||
|
end
|
||||||
|
|
||||||
|
def within_object(object, &block)
|
||||||
|
within(object_matcher(object), &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def object_matcher(object)
|
||||||
|
"[data-id='#{object.id}'][data-type='#{object.class}']"
|
||||||
|
end
|
||||||
|
|
||||||
|
def within_object_of_type(klass, &block)
|
||||||
|
within("[data-type='#{klass}']", &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def within_any(search, &block)
|
||||||
|
case search
|
||||||
|
when Class
|
||||||
|
search = "[data-type='#{search}']"
|
||||||
|
end
|
||||||
|
|
||||||
|
all(search).each_with_index do |node, index|
|
||||||
|
begin
|
||||||
|
within("#{search}:eq(#{index + 1})", &block)
|
||||||
|
return true
|
||||||
|
rescue RSpec::Expectations::ExpectationNotMetError
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,15 @@ module SemanticRailsViewHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
def li_for(object, options = {}, &block)
|
def li_for(object, options = {}, &block)
|
||||||
content_tag(:li, capture(&block), options.merge('data-id' => object.id))
|
type = begin
|
||||||
|
if object.respond_to?(:model)
|
||||||
|
object.model.class
|
||||||
|
else
|
||||||
|
object.class
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
content_tag(:li, capture(&block), options.merge('data-type' => type, 'data-id' => object.id))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue