Top Level Namespace
Defined Under Namespace
Modules: Application, ApplicationHelper, Database, Engine, Install, JavascriptHelper, Layout, MailerHelper, Myrails, RSpec, Rails Classes: ApplicationDecorator, BasePresenter, DevMailInterceptor, UiController
Instance Method Summary collapse
- #clear_inbox ⇒ Object
- #delete_files ⇒ Object
- #inbox ⇒ Object
-
#include_behavior ⇒ Object
Presenter tests requre this metho in order to fuction.
- #set_session(user = create(:user)) ⇒ Object
- #sign_in_with(user) ⇒ Object
Instance Method Details
#clear_inbox ⇒ Object
5 6 7 |
# File 'lib/myrails/templates/spec/support/configs/mailer.rb', line 5 def clear_inbox ActionMailer::Base.deliveries.clear end |
#delete_files ⇒ Object
1 2 3 |
# File 'lib/myrails/templates/spec/files.rb', line 1 def delete_files `rm -rf \#{Rails.root}/tmp/uploads` end |
#inbox ⇒ Object
1 2 3 |
# File 'lib/myrails/templates/spec/support/configs/mailer.rb', line 1 def inbox ActionMailer::Base.deliveries end |
#include_behavior ⇒ Object
Presenter tests requre this metho in order to fuction.
2 3 4 |
# File 'lib/myrails/templates/spec/support/configs/decorator_presenter.rb', line 2 def include_behavior include ActionView::TestCase::Behavior end |
#set_session(user = create(:user)) ⇒ Object
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)
32 33 34 |
# 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) ⇒ Object
36 37 38 39 40 41 |
# 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' 'Log in' end |