lib/rspeckled/plugins/authentication.rb in rspeckled-0.0.16 vs lib/rspeckled/plugins/authentication.rb in rspeckled-0.0.17

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true RSpec.configure do |config| config.around(:each, :mock_auth => lambda { |v| !!v }) do |example| options = example.metadata[:mock_auth] authentication_type = if options.is_a?(Hash) && options[:type] @@ -16,13 +17,13 @@ else options end underscored_class_name = klass. - name[/(?:.*::)?(\w+)\z/, 1]. - gsub(/([a-z])([A-Z])/, '\1_\2'). - downcase + name[/(?:.*::)?(\w+)\z/, 1]. + gsub(/([a-z])([A-Z])/, '\1_\2'). + downcase current_class_method = if options.is_a?(Hash) && options[:method] options[:method] || :current_user else :"current_#{underscored_class_name}" @@ -97,10 +98,10 @@ example.example_group_instance.class.let(current_class_method) { authentication_result } example.run else - fail 'You must specify a valid type for the :mock_auth metadata' + fail ArgumentError, 'You must specify a valid type for the :mock_auth metadata' end instance.delete unless options.is_a?(Hash) && options[:strategy] == :instance end