class Object
Public Instance Methods
<(%= @name.split("/").last.singularize %> @<%= @name.split("/").last.singularize %> = <%= @name.camelize.singularize %>.find(params[:id]) end def <%= @name.split("/").last.singularize %>_params params.require(:<%= @name.split("/").last.singularize %>).permit())
click to toggle source
before_action :<%= @name.split(“/”).last.singularize %>, only: []
# File lib/myrails/templates/rails/app/controllers/controller.rb, line 5 def <%= @name.split("/").last.singularize %> @<%= @name.split("/").last.singularize %> = <%= @name.camelize.singularize %>.find(params[:id]) end def <%= @name.split("/").last.singularize %>_params params.require(:<%= @name.split("/").last.singularize %>).permit() end
clear_inbox()
click to toggle source
# File lib/myrails/templates/spec/support/configs/mailer.rb, line 5 def clear_inbox ActionMailer::Base.deliveries.clear end
delete_files()
click to toggle source
# File lib/myrails/templates/spec/files.rb, line 1 def delete_files `rm -rf \#{Rails.root}/tmp/uploads` end
edit_link()
click to toggle source
Return edit path
# File lib/myrails/templates/rails/app/presenters/presenter.rb, line 14 def edit_link link_to :Edit, edit_<%= @name%>_path(<%= @name %>) end
inbox()
click to toggle source
# File lib/myrails/templates/spec/support/configs/mailer.rb, line 1 def inbox ActionMailer::Base.deliveries end
include_behavior()
click to toggle source
Presenter tests requre this metho in order to fuction.
# File lib/myrails/templates/spec/support/configs/decorator_presenter.rb, line 2 def include_behavior include ActionView::TestCase::Behavior end
name()
click to toggle source
Return concatenated full name
# File lib/myrails/templates/rails/app/presenters/presenter.rb, line 9 def name <%= @name %>.attribute + " " + <%= @name %>.attribute end
set_session(user=create(:user))
click to toggle source
# Reference: github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara
To use authentication bypass use the following for loging in:
user = FactoryBot.create(:user) login_as(user, :scope => :user)
if within a test you need to sign_out a user use: sign_out(:user)
# File lib/myrails/templates/spec/support/configs/devise.rb, line 32 def set_session(user=create(:user)) login_as(user, :scope => :user) end
sign_in_with(user)
click to toggle source
# File lib/myrails/templates/spec/support/configs/devise.rb, line 36 def sign_in_with(user) click_link 'Sign In' fill_in 'user_email', with: user.email fill_in 'user_password', with: 'somepassword' click_button 'Log in' end