module Itsf::Backend::SpecHelpers

Public Instance Methods

backend_path() click to toggle source
# File lib/itsf/backend/spec_helpers.rb, line 8
def backend_path
  "#{itsf_backend_path}/"
end
create_resource_instance_for_controller(controller_class) click to toggle source
# File lib/itsf/backend/spec_helpers.rb, line 24
def create_resource_instance_for_controller(controller_class)
  create(controller_class.resource_class.name.underscore.tr('/', '_'))
end
engine_path(engine_class) click to toggle source
# File lib/itsf/backend/spec_helpers.rb, line 12
def engine_path(engine_class)
  send("#{engine_class.engine_name}_path")
end
ensure_backend_engine_homepage(engine_class) click to toggle source
# File lib/itsf/backend/spec_helpers.rb, line 4
def ensure_backend_engine_homepage(engine_class)
  expect(current_path).to eq(engine_path(engine_class))
end
ensure_current_action(_engine_class, controller_class, action_name, instance = nil) click to toggle source
# File lib/itsf/backend/spec_helpers.rb, line 28
def ensure_current_action(_engine_class, controller_class, action_name, instance = nil)
  case action_name
  when :index
    expect(page).to have_content(controller_class.resource_class.model_name.human(count: :other))
  when :new
    expect(page).to have_content(I18n.t('itsf.backend.base.new.title', resource_name: controller_class.resource_class.model_name.human))
  when :show
    expect(page).to have_content(instance.try_all(*Itsf::Backend::Configuration.resource_title_methods))
  when :edit
    expect(page).to have_content(I18n.t('itsf.backend.base.edit.title', resource_name: instance.class.model_name.human))
  when :destroy
    expect(page).to have_content(instance.class.model_name.human(count: :other))
  end

  # Can't use this because of bug: undefined method `segment_keys' for nil:NilClass
  # expect(current_path).to eq(engine_class.routes.url_for(controller: controller_class.controller_name, action: action_name))
end