1
0
Fork 0
This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/lib/partynest/rspec_account_role_helpers.rb

42 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Partynest
module RSpecAccountRoleHelpers
2018-12-13 04:31:27 +00:00
def create_account_type(account_type)
return if account_type.nil?
2018-12-13 04:31:27 +00:00
create "#{account_type}_account"
end
module ClassMethods
2018-12-13 04:34:14 +00:00
def account_type_name(account_type)
return 'no account' if account_type.nil?
"#{account_type} account"
end
2018-12-13 04:31:27 +00:00
def for_account_types(*account_types, &block)
account_types.each do |account_type|
2018-12-13 04:34:14 +00:00
context "when #{account_type_name account_type} is authenticated" do
2018-12-13 04:31:27 +00:00
let(:current_account) { create_account_type account_type }
let(:account) { current_account }
2018-12-13 04:31:27 +00:00
instance_eval(&block)
end
end
end
2018-12-13 04:18:44 +00:00
2018-12-13 04:31:27 +00:00
def xfor_account_types(*account_types, &block)
account_types.each do |account_type|
2018-12-13 04:34:14 +00:00
xcontext "when #{account_type_name account_type} is authenticated" do
2018-12-13 04:31:27 +00:00
let(:current_account) { create_account_type account_type }
let(:account) { current_account }
2018-12-13 04:18:44 +00:00
2018-12-13 04:31:27 +00:00
instance_eval(&block)
end
2018-12-13 04:18:44 +00:00
end
end
end
end
end