Module: Rspec::Dunlop::AuthenticationSupport
- Included in:
- FeatureHelpers
- Defined in:
- lib/rspec/dunlop/authentication_support.rb
Instance Method Summary collapse
- #current_user ⇒ Object
- #i_am_logged_in_as(user) ⇒ Object
- #i_am_logged_in_as_admin ⇒ Object
- #i_am_logged_in_as_user(*user_args) ⇒ Object
- #i_am_logged_in_as_user_of_service_provider ⇒ Object
- #open_page ⇒ Object
- #screenshot ⇒ Object
- #submit_collection_form ⇒ Object
- #submit_form ⇒ Object
-
#visit(*args) ⇒ Object
Add support for: visit WorkflowInstance.last.
Instance Method Details
#current_user ⇒ Object
32 33 34 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 32 def current_user @user end |
#i_am_logged_in_as(user) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 36 def i_am_logged_in_as(user) visit new_user_session_path fill_in 'Email', with: user.email fill_in 'Password', with: user.password 'Log in' #expect(current_path).to eq root_path end |
#i_am_logged_in_as_admin ⇒ Object
27 28 29 30 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 27 def i_am_logged_in_as_admin @user = FactoryGirl.create(:admin) i_am_logged_in_as(@user) end |
#i_am_logged_in_as_user(*user_args) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 13 def i_am_logged_in_as_user(*user_args) if user_args.last.is_a?(Hash) user_args[-1][:role_names] = Array.wrap(user_args[-1][:role_names]) | ['read-class-WorkflowInstance'] if user_args[-1][:role_names].present? end @user = FactoryGirl.create(:user, *user_args) i_am_logged_in_as(@user) end |
#i_am_logged_in_as_user_of_service_provider ⇒ Object
21 22 23 24 25 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 21 def i_am_logged_in_as_user_of_service_provider @service_provider ||= FactoryGirl.create :service_provider, :all_scenarios @user = FactoryGirl.create(:user, service_provider: @service_provider) i_am_logged_in_as(@user) end |
#open_page ⇒ Object
48 49 50 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 48 def open_page save_and_open_page end |
#screenshot ⇒ Object
44 45 46 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 44 def screenshot screenshot_and_open_image end |
#submit_collection_form ⇒ Object
56 57 58 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 56 def submit_collection_form find('#new_collection input[type="submit"]').click end |
#submit_form ⇒ Object
52 53 54 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 52 def submit_form find('input[type="submit"]').click end |
#visit(*args) ⇒ Object
Add support for:
visit WorkflowInstance.last
5 6 7 8 9 10 11 |
# File 'lib/rspec/dunlop/authentication_support.rb', line 5 def visit(*args) case args[0] when ActiveRecord::Base, Array, Class args[0] = polymorphic_path(args[0]) end super *args end |