some updates

This commit is contained in:
John Bintz 2012-12-23 10:37:05 -05:00
parent 3ffc64cc48
commit 8b98a0b4c6
2 changed files with 12 additions and 4 deletions

View File

@ -58,6 +58,10 @@ def find_action(action)
find("[data-action='#{action}']")
end
def find_object_action(object, action)
find("[data-type='#{object}'][data-action='#{action}']")
end
module Capybara
class ElementFound < StandardError
def initialize(search)
@ -115,11 +119,15 @@ def within_any(search, &block)
search = "[data-type='#{search}']"
end
all(search).each_with_index do |node, index|
nodes = all(search)
raise Capybara::ElementNotFound if nodes.empty?
nodes.each_with_index do |node, index|
begin
within("#{search}:eq(#{index + 1})", &block)
return true
rescue RSpec::Expectations::ExpectationNotMetError
rescue RSpec::Expectations::ExpectationNotMetError, Capybara::ElementNotFound
end
end

View File

@ -36,7 +36,7 @@ module SemanticRailsViewHelpers
def link_to_model_action(model, action = :show, options = {})
target_action = action
label = options.delete(:label) || t(".#{action}")
label = options.delete(:label) || t(".#{model.class.name.underscore}.#{action}")
if action == :destroy
options = options.merge(:method => :delete, 'data-skip-pjax' => 'true')
@ -52,7 +52,7 @@ module SemanticRailsViewHelpers
route = model
route = route.to_route if route.respond_to?(:to_route)
link_to label, polymorphic_url(route, :action => action), options.merge(semantic_action_data(target_action))
link_to label, polymorphic_url(route, :action => action), options.merge(semantic_action_data(target_action).merge(semantic_model_data(model)))
end
def li_for(object, options = {}, &block)