From ebf5049039ed613d5e0664db1a3a006c164551ce Mon Sep 17 00:00:00 2001
From: James Lamont <958588+jylamont@users.noreply.github.com>
Date: Mon, 6 Jan 2025 17:01:49 -0500
Subject: [PATCH] chore: Replaced rubocop w/ StandardRb
---
.github/workflows/ci.yml | 4 +-
.rubocop.yml | 42 ------
.rubocop_todo.yml | 25 ----
.standard.yml | 3 +
Gemfile | 20 +--
bin/setup | 6 +
lib/generators/vero_generator.rb | 6 +-
lib/vero.rb | 62 ++++-----
lib/vero/api/base_api.rb | 12 +-
lib/vero/api/events/track_api.rb | 4 +-
lib/vero/api/users/delete_api.rb | 2 +-
lib/vero/api/users/edit_api.rb | 4 +-
lib/vero/api/users/edit_tags_api.rb | 8 +-
lib/vero/api/users/reidentify_api.rb | 4 +-
lib/vero/api/users/resubscribe_api.rb | 2 +-
lib/vero/api/users/track_api.rb | 4 +-
lib/vero/api/users/unsubscribe_api.rb | 2 +-
lib/vero/app.rb | 2 +-
lib/vero/config.rb | 14 +-
lib/vero/context.rb | 2 +-
lib/vero/context/api.rb | 12 +-
lib/vero/railtie.rb | 4 +-
lib/vero/sender.rb | 6 +-
lib/vero/senders/base.rb | 2 +-
lib/vero/senders/delayed_job.rb | 8 +-
lib/vero/senders/invalid.rb | 2 +-
lib/vero/senders/resque.rb | 4 +-
lib/vero/senders/sidekiq.rb | 4 +-
lib/vero/senders/sucker_punch.rb | 6 +-
lib/vero/trackable.rb | 4 +-
lib/vero/trackable/base.rb | 8 +-
lib/vero/version.rb | 2 +-
lib/vero/view_helpers/javascript.rb | 20 +--
spec/lib/api/base_api_spec.rb | 14 +-
spec/lib/api/events/track_api_spec.rb | 44 +++---
spec/lib/api/users/delete_api_spec.rb | 24 ++--
spec/lib/api/users/edit_api_spec.rb | 20 +--
spec/lib/api/users/edit_tags_api_spec.rb | 42 +++---
spec/lib/api/users/reidentify_spec.rb | 28 ++--
spec/lib/api/users/resubscribe_api_spec.rb | 20 +--
spec/lib/api/users/track_api_spec.rb | 38 +++---
spec/lib/api/users/unsubscribe_api_spec.rb | 20 +--
spec/lib/api_spec.rb | 46 +++----
spec/lib/app_spec.rb | 22 +--
spec/lib/config_spec.rb | 56 ++++----
spec/lib/context_spec.rb | 26 ++--
spec/lib/dsl_spec.rb | 16 +--
spec/lib/sender_spec.rb | 8 +-
spec/lib/senders/sidekiq_spec.rb | 14 +-
spec/lib/trackable_spec.rb | 144 ++++++++++----------
spec/lib/view_helpers_spec.rb | 27 ++--
spec/spec_helper.rb | 14 +-
spec/support/base_config_shared_examples.rb | 6 +-
spec/support/user_support.rb | 26 ++--
vero.gemspec | 32 ++---
55 files changed, 472 insertions(+), 525 deletions(-)
delete mode 100644 .rubocop.yml
delete mode 100644 .rubocop_todo.yml
create mode 100644 .standard.yml
create mode 100755 bin/setup
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 013c43e..d970b5a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,8 +19,8 @@ jobs:
ruby-version: 2.7.8
bundler-cache: true
- - name: RuboCop
- run: bundle exec rubocop
+ - name: Standard RB
+ run: bundle exec standardrb
test:
runs-on: ubuntu-latest
diff --git a/.rubocop.yml b/.rubocop.yml
deleted file mode 100644
index 37f6f28..0000000
--- a/.rubocop.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-inherit_from: .rubocop_todo.yml
-
-AllCops:
- TargetRubyVersion: 2.7
- NewCops: enable
- SuggestExtensions: false
-
-Layout/LineLength:
- Enabled: false
-
-Metrics/AbcSize:
- Enabled: false
-
-Metrics/BlockLength:
- Enabled: false
-
-Metrics/CyclomaticComplexity:
- Enabled: false
-
-Metrics/MethodLength:
- Enabled: false
-
-Metrics/PerceivedComplexity:
- Enabled: false
-
-Style/Documentation:
- Enabled: false
-
-Style/ExponentialNotation:
- Enabled: false
-
-Style/HashTransformKeys:
- Enabled: false
-
-Style/HashTransformValues:
- Enabled: true
-
-Style/OptionalBooleanParameter:
- Enabled: false
-
-Style/SlicingWithRange:
- Enabled: false
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
deleted file mode 100644
index a0c58d1..0000000
--- a/.rubocop_todo.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-# This configuration was generated by
-# `rubocop --auto-gen-config`
-# on 2020-09-17 12:32:40 UTC using RuboCop version 0.91.0.
-# The point is for the user to remove these configuration records
-# one by one as the offenses are removed from the code base.
-# Note that changes in the inspected code, or installation of new
-# versions of RuboCop, may require this file to be generated again.
-
-Layout/EmptyLinesAroundAttributeAccessor:
- Enabled: true
-
-Layout/SpaceAroundMethodCallOperator:
- Enabled: true
-
-Lint/DeprecatedOpenSSLConstant:
- Enabled: true
-
-Lint/RaiseException:
- Enabled: true
-
-Lint/StructNewOverride:
- Enabled: true
-
-Style/HashEachMethods:
- Enabled: true
\ No newline at end of file
diff --git a/.standard.yml b/.standard.yml
new file mode 100644
index 0000000..2054e90
--- /dev/null
+++ b/.standard.yml
@@ -0,0 +1,3 @@
+# For available configuration options, see:
+# https://github.com/standardrb/standard
+ruby_version: 2.7
diff --git a/Gemfile b/Gemfile
index fa113c9..c91660b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-source 'http://rubygems.org'
+source "http://rubygems.org"
gemspec
group :development do
- gem 'rubocop'
-
- gem 'delayed_job'
- gem 'delayed_job_active_record'
- gem 'rails'
- gem 'resque'
- gem 'sidekiq'
- gem 'sucker_punch'
+ gem "delayed_job"
+ gem "delayed_job_active_record"
+ gem "rails"
+ gem "resque"
+ gem "rubocop"
+ gem "sidekiq"
+ gem "sucker_punch"
+ gem "standard"
end
group :test do
- gem 'rspec'
+ gem "rspec"
end
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 0000000..cf4ad25
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -euo pipefail
+IFS=$'\n\t'
+set -vx
+
+bundle install
diff --git a/lib/generators/vero_generator.rb b/lib/generators/vero_generator.rb
index affe948..2cea960 100644
--- a/lib/generators/vero_generator.rb
+++ b/lib/generators/vero_generator.rb
@@ -6,10 +6,10 @@ class VeroGenerator < Rails::Generators::Base
class_option :api_secret
def create_initializer_file
- type = options[:heroku] || 'standard'
+ type = options[:heroku] || "standard"
- abort('You must provide an API KEY and API SECRET to proceed.') if options[:heroku].blank? && (options[:api_key].blank? || options[:api_secret].blank?)
- create_file 'config/initializers/vero.rb', send("#{type}_initializer_content")
+ abort("You must provide an API KEY and API SECRET to proceed.") if options[:heroku].blank? && (options[:api_key].blank? || options[:api_secret].blank?)
+ create_file "config/initializers/vero.rb", send("#{type}_initializer_content")
end
private
diff --git a/lib/vero.rb b/lib/vero.rb
index 230df85..9b8abb4 100644
--- a/lib/vero.rb
+++ b/lib/vero.rb
@@ -1,55 +1,55 @@
# frozen_string_literal: true
-require 'rest-client'
-require 'vero/utility/ext'
+require "rest-client"
+require "vero/utility/ext"
module Vero
- autoload :Config, 'vero/config'
- autoload :App, 'vero/app'
- autoload :Context, 'vero/context'
- autoload :APIContext, 'vero/context/api'
- autoload :Trackable, 'vero/trackable'
- autoload :DSL, 'vero/dsl'
- autoload :Sender, 'vero/sender'
- autoload :SuckerPunchWorker, 'vero/senders/sucker_punch'
- autoload :ResqueWorker, 'vero/senders/resque'
- autoload :SidekiqWorker, 'vero/senders/sidekiq'
+ autoload :Config, "vero/config"
+ autoload :App, "vero/app"
+ autoload :Context, "vero/context"
+ autoload :APIContext, "vero/context/api"
+ autoload :Trackable, "vero/trackable"
+ autoload :DSL, "vero/dsl"
+ autoload :Sender, "vero/sender"
+ autoload :SuckerPunchWorker, "vero/senders/sucker_punch"
+ autoload :ResqueWorker, "vero/senders/resque"
+ autoload :SidekiqWorker, "vero/senders/sidekiq"
module Api
module Workers
- autoload :BaseAPI, 'vero/api/base_api'
+ autoload :BaseAPI, "vero/api/base_api"
module Events
- autoload :TrackAPI, 'vero/api/events/track_api'
+ autoload :TrackAPI, "vero/api/events/track_api"
end
module Users
- autoload :TrackAPI, 'vero/api/users/track_api'
- autoload :EditAPI, 'vero/api/users/edit_api'
- autoload :EditTagsAPI, 'vero/api/users/edit_tags_api'
- autoload :UnsubscribeAPI, 'vero/api/users/unsubscribe_api'
- autoload :ResubscribeAPI, 'vero/api/users/resubscribe_api'
- autoload :ReidentifyAPI, 'vero/api/users/reidentify_api'
- autoload :DeleteAPI, 'vero/api/users/delete_api'
+ autoload :TrackAPI, "vero/api/users/track_api"
+ autoload :EditAPI, "vero/api/users/edit_api"
+ autoload :EditTagsAPI, "vero/api/users/edit_tags_api"
+ autoload :UnsubscribeAPI, "vero/api/users/unsubscribe_api"
+ autoload :ResubscribeAPI, "vero/api/users/resubscribe_api"
+ autoload :ReidentifyAPI, "vero/api/users/reidentify_api"
+ autoload :DeleteAPI, "vero/api/users/delete_api"
end
end
- autoload :Events, 'vero/api'
- autoload :Users, 'vero/api'
+ autoload :Events, "vero/api"
+ autoload :Users, "vero/api"
end
module Senders
- autoload :Base, 'vero/senders/base'
- autoload :DelayedJob, 'vero/senders/delayed_job'
- autoload :Resque, 'vero/senders/resque'
- autoload :Sidekiq, 'vero/senders/sidekiq'
- autoload :Invalid, 'vero/senders/invalid'
- autoload :SuckerPunch, 'vero/senders/sucker_punch'
+ autoload :Base, "vero/senders/base"
+ autoload :DelayedJob, "vero/senders/delayed_job"
+ autoload :Resque, "vero/senders/resque"
+ autoload :Sidekiq, "vero/senders/sidekiq"
+ autoload :Invalid, "vero/senders/invalid"
+ autoload :SuckerPunch, "vero/senders/sucker_punch"
end
module Utility
- autoload :Logger, 'vero/utility/logger'
+ autoload :Logger, "vero/utility/logger"
end
end
-require 'vero/railtie' if defined?(Rails)
+require "vero/railtie" if defined?(Rails)
diff --git a/lib/vero/api/base_api.rb b/lib/vero/api/base_api.rb
index d716b6d..e886e7c 100644
--- a/lib/vero/api/base_api.rb
+++ b/lib/vero/api/base_api.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'json'
-require 'rest-client'
+require "json"
+require "rest-client"
module Vero
module Api
@@ -42,16 +42,18 @@ def proxy.<<(message)
end
end
- def url; end
+ def url
+ end
def validate!
raise "#{self.class.name}#validate! should be overridden"
end
- def request; end
+ def request
+ end
def request_content_type
- { content_type: :json, accept: :json }
+ {content_type: :json, accept: :json}
end
def request_params_as_json
diff --git a/lib/vero/api/events/track_api.rb b/lib/vero/api/events/track_api.rb
index 9c54911..f6850b1 100644
--- a/lib/vero/api/events/track_api.rb
+++ b/lib/vero/api/events/track_api.rb
@@ -14,8 +14,8 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :event_name' if options[:event_name].to_s.blank?
- raise ArgumentError, ':data must be either nil or a Hash' unless options[:data].nil? || options[:data].is_a?(Hash)
+ raise ArgumentError, "Missing :event_name" if options[:event_name].to_s.blank?
+ raise ArgumentError, ":data must be either nil or a Hash" unless options[:data].nil? || options[:data].is_a?(Hash)
end
end
end
diff --git a/lib/vero/api/users/delete_api.rb b/lib/vero/api/users/delete_api.rb
index d13f106..e2ce59d 100644
--- a/lib/vero/api/users/delete_api.rb
+++ b/lib/vero/api/users/delete_api.rb
@@ -14,7 +14,7 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :id' if options[:id].to_s.blank?
+ raise ArgumentError, "Missing :id" if options[:id].to_s.blank?
end
end
end
diff --git a/lib/vero/api/users/edit_api.rb b/lib/vero/api/users/edit_api.rb
index c0426fe..3ee551f 100644
--- a/lib/vero/api/users/edit_api.rb
+++ b/lib/vero/api/users/edit_api.rb
@@ -14,8 +14,8 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :id or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
- raise ArgumentError, ':changes must be a Hash' unless options[:changes].is_a?(Hash)
+ raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
+ raise ArgumentError, ":changes must be a Hash" unless options[:changes].is_a?(Hash)
end
end
end
diff --git a/lib/vero/api/users/edit_tags_api.rb b/lib/vero/api/users/edit_tags_api.rb
index bce1994..3b10f60 100644
--- a/lib/vero/api/users/edit_tags_api.rb
+++ b/lib/vero/api/users/edit_tags_api.rb
@@ -14,10 +14,10 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :id or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
- raise ArgumentError, ':add must an Array if present' unless options[:add].nil? || options[:add].is_a?(Array)
- raise ArgumentError, ':remove must an Array if present' unless options[:remove].nil? || options[:remove].is_a?(Array)
- raise ArgumentError, 'Either :add or :remove must be present' if options[:remove].nil? && options[:add].nil?
+ raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
+ raise ArgumentError, ":add must an Array if present" unless options[:add].nil? || options[:add].is_a?(Array)
+ raise ArgumentError, ":remove must an Array if present" unless options[:remove].nil? || options[:remove].is_a?(Array)
+ raise ArgumentError, "Either :add or :remove must be present" if options[:remove].nil? && options[:add].nil?
end
end
end
diff --git a/lib/vero/api/users/reidentify_api.rb b/lib/vero/api/users/reidentify_api.rb
index cb22397..4893881 100644
--- a/lib/vero/api/users/reidentify_api.rb
+++ b/lib/vero/api/users/reidentify_api.rb
@@ -14,8 +14,8 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :id' if options[:id].to_s.blank?
- raise ArgumentError, 'Missing :new_id' if options[:new_id].to_s.blank?
+ raise ArgumentError, "Missing :id" if options[:id].to_s.blank?
+ raise ArgumentError, "Missing :new_id" if options[:new_id].to_s.blank?
end
end
end
diff --git a/lib/vero/api/users/resubscribe_api.rb b/lib/vero/api/users/resubscribe_api.rb
index 9ac6ba8..683a948 100644
--- a/lib/vero/api/users/resubscribe_api.rb
+++ b/lib/vero/api/users/resubscribe_api.rb
@@ -14,7 +14,7 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :id or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
+ raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
end
end
end
diff --git a/lib/vero/api/users/track_api.rb b/lib/vero/api/users/track_api.rb
index 41b1f10..6e0dee4 100644
--- a/lib/vero/api/users/track_api.rb
+++ b/lib/vero/api/users/track_api.rb
@@ -14,8 +14,8 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :id or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
- raise ArgumentError, ':data must be either nil or a Hash' unless options[:data].nil? || options[:data].is_a?(Hash)
+ raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
+ raise ArgumentError, ":data must be either nil or a Hash" unless options[:data].nil? || options[:data].is_a?(Hash)
end
end
end
diff --git a/lib/vero/api/users/unsubscribe_api.rb b/lib/vero/api/users/unsubscribe_api.rb
index 7ed6b3d..ec309ef 100644
--- a/lib/vero/api/users/unsubscribe_api.rb
+++ b/lib/vero/api/users/unsubscribe_api.rb
@@ -14,7 +14,7 @@ def request
end
def validate!
- raise ArgumentError, 'Missing :id or :email' if options[:id].to_s.blank? && options[:email].to_s.blank?
+ raise ArgumentError, "Missing :id or :email" if options[:id].to_s.blank? && options[:email].to_s.blank?
end
end
end
diff --git a/lib/vero/app.rb b/lib/vero/app.rb
index d315736..12dde8a 100644
--- a/lib/vero/app.rb
+++ b/lib/vero/app.rb
@@ -9,7 +9,7 @@ def self.default_context
end
def self.init(&block)
- default_context.configure(&block) if block_given?
+ default_context.configure(&block) if block
end
def self.reset!
diff --git a/lib/vero/config.rb b/lib/vero/config.rb
index f477548..80132e3 100644
--- a/lib/vero/config.rb
+++ b/lib/vero/config.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'base64'
+require "base64"
module Vero
class Config
@@ -16,7 +16,7 @@ def initialize
end
def config_params
- { tracking_api_key: tracking_api_key }
+ {tracking_api_key: tracking_api_key}
end
def request_params
@@ -28,9 +28,9 @@ def request_params
def domain
if @domain.blank?
- 'https://api.getvero.com'
+ "https://api.getvero.com"
else
- @domain =~ %r{https?://.+} ? @domain : "http://#{@domain}"
+ %r{https?://.+}.match?(@domain) ? @domain : "http://#{@domain}"
end
end
@@ -43,10 +43,10 @@ def disable_requests!
end
def reset!
- self.disabled = false
+ self.disabled = false
self.development_mode = false
- self.async = true
- self.logging = false
+ self.async = true
+ self.logging = false
self.tracking_api_key = nil
end
diff --git a/lib/vero/context.rb b/lib/vero/context.rb
index 3fa11af..e455d48 100644
--- a/lib/vero/context.rb
+++ b/lib/vero/context.rb
@@ -26,7 +26,7 @@ def initialize(object = {})
def configure(hash = {}, &block)
@config.update_attributes(hash) if hash.is_a?(Hash) && hash.any?
- block.call(@config) if block_given?
+ block&.call(@config)
end
def reset!
diff --git a/lib/vero/context/api.rb b/lib/vero/context/api.rb
index 144a6f5..07a3deb 100644
--- a/lib/vero/context/api.rb
+++ b/lib/vero/context/api.rb
@@ -3,37 +3,37 @@
module Vero
module APIContext
def track!(event_name, event_data, extras = {})
- options = { data: event_data, event_name: event_name, identity: subject.to_vero, extras: extras }
+ options = {data: event_data, event_name: event_name, identity: subject.to_vero, extras: extras}
Vero::Api::Events.track!(options, self)
end
def identify!
identity = subject.to_vero
- options = { id: identity[:id], email: identity[:email], data: identity }
+ options = {id: identity[:id], email: identity[:email], data: identity}
Vero::Api::Users.track!(options, self)
end
def update_user!
identity = subject.to_vero
- options = { id: identity[:id], email: identity[:email], changes: identity }
+ options = {id: identity[:id], email: identity[:email], changes: identity}
Vero::Api::Users.edit_user!(options, self)
end
def update_user_tags!(add = [], remove = [])
identity = subject.to_vero
- options = { id: identity[:id], email: identity[:email], add: Array(add), remove: Array(remove) }
+ options = {id: identity[:id], email: identity[:email], add: Array(add), remove: Array(remove)}
Vero::Api::Users.edit_user_tags!(options, self)
end
def unsubscribe!
identity = subject.to_vero
- options = { id: identity[:id], email: identity[:email] }
+ options = {id: identity[:id], email: identity[:email]}
Vero::Api::Users.unsubscribe!(options, self)
end
def reidentify!(previous_id)
identity = subject.to_vero
- options = { id: previous_id, new_id: identity[:id] }
+ options = {id: previous_id, new_id: identity[:id]}
Vero::Api::Users.reidentify!(options, self)
end
end
diff --git a/lib/vero/railtie.rb b/lib/vero/railtie.rb
index 123ee72..286b70b 100644
--- a/lib/vero/railtie.rb
+++ b/lib/vero/railtie.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'vero/view_helpers/javascript'
+require "vero/view_helpers/javascript"
module Vero
class Railtie < Rails::Railtie
- initializer 'vero.view_helpers' do
+ initializer "vero.view_helpers" do
ActionView::Base.include ViewHelpers::Javascript
end
end
diff --git a/lib/vero/sender.rb b/lib/vero/sender.rb
index d5fdfda..6321e13 100644
--- a/lib/vero/sender.rb
+++ b/lib/vero/sender.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'json'
+require "json"
module Vero
class SenderLookup
def [](key)
- klass_name = key.to_s.split('_').map(&:capitalize).join
+ klass_name = key.to_s.split("_").map(&:capitalize).join
if Vero::Senders.const_defined?(klass_name)
Vero::Senders.const_get(klass_name)
@@ -22,7 +22,7 @@ def self.senders
def self.send(api_class, sender_strategy, domain, options)
senders[sender_strategy].new.call(api_class, domain, options)
- rescue StandardError => e
+ rescue => e
options_s = JSON.dump(options)
Vero::App.log(new, "method: #{api_class.name}, options: #{options_s}, error: #{e.message}")
raise e
diff --git a/lib/vero/senders/base.rb b/lib/vero/senders/base.rb
index 9e3dc8e..dbd8b25 100644
--- a/lib/vero/senders/base.rb
+++ b/lib/vero/senders/base.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'json'
+require "json"
module Vero
module Senders
diff --git a/lib/vero/senders/delayed_job.rb b/lib/vero/senders/delayed_job.rb
index 96b6e50..ba67984 100644
--- a/lib/vero/senders/delayed_job.rb
+++ b/lib/vero/senders/delayed_job.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'json'
-require 'delayed_job'
+require "json"
+require "delayed_job"
module Vero
module Senders
@@ -11,8 +11,8 @@ def call(api_class, domain, options)
options_s = JSON.dump(options)
Vero::App.log(self, "method: #{api_class.name}, options: #{options_s}, response: delayed job queued")
response
- rescue StandardError => e
- raise 'To send ratings asynchronously, you must configure delayed_job. Run `rails generate delayed_job:active_record` then `rake db:migrate`.' if e.message == "Could not find table 'delayed_jobs'"
+ rescue => e
+ raise "To send ratings asynchronously, you must configure delayed_job. Run `rails generate delayed_job:active_record` then `rake db:migrate`." if e.message == "Could not find table 'delayed_jobs'"
raise e
end
diff --git a/lib/vero/senders/invalid.rb b/lib/vero/senders/invalid.rb
index a463160..373a53b 100644
--- a/lib/vero/senders/invalid.rb
+++ b/lib/vero/senders/invalid.rb
@@ -4,7 +4,7 @@ module Vero
module Senders
class Invalid
def call(_api_class, _domain, _options)
- raise 'Vero sender not supported by your version of Ruby. Please change `config.async` to a valid sender. See https://github.com/getvero/vero for more information.'
+ raise "Vero sender not supported by your version of Ruby. Please change `config.async` to a valid sender. See https://github.com/getvero/vero for more information."
end
end
end
diff --git a/lib/vero/senders/resque.rb b/lib/vero/senders/resque.rb
index 937f7ca..8421880 100644
--- a/lib/vero/senders/resque.rb
+++ b/lib/vero/senders/resque.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'json'
-require 'resque'
+require "json"
+require "resque"
module Vero
class ResqueWorker
diff --git a/lib/vero/senders/sidekiq.rb b/lib/vero/senders/sidekiq.rb
index d4ed76c..ac13933 100644
--- a/lib/vero/senders/sidekiq.rb
+++ b/lib/vero/senders/sidekiq.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'json'
-require 'sidekiq'
+require "json"
+require "sidekiq"
module Vero
class SidekiqWorker
diff --git a/lib/vero/senders/sucker_punch.rb b/lib/vero/senders/sucker_punch.rb
index 656ff00..22f89fd 100644
--- a/lib/vero/senders/sucker_punch.rb
+++ b/lib/vero/senders/sucker_punch.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'json'
-require 'sucker_punch'
+require "json"
+require "sucker_punch"
module Vero
class SuckerPunchWorker
@@ -14,7 +14,7 @@ def perform(api_class, domain, options)
begin
api_class.new(domain, new_options).perform
Vero::App.log(self, "method: #{api_class.name}, options: #{options.to_json}, response: job performed")
- rescue StandardError => e
+ rescue => e
Vero::App.log(self, "method: #{api_class.name}, options: #{options.to_json}, response: #{e.message}")
end
end
diff --git a/lib/vero/trackable.rb b/lib/vero/trackable.rb
index 5d2be05..6803fbf 100644
--- a/lib/vero/trackable.rb
+++ b/lib/vero/trackable.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'vero/trackable/base'
-require 'vero/trackable/interface'
+require "vero/trackable/base"
+require "vero/trackable/interface"
module Vero
module Trackable
diff --git a/lib/vero/trackable/base.rb b/lib/vero/trackable/base.rb
index 1485f13..4fc7bf5 100644
--- a/lib/vero/trackable/base.rb
+++ b/lib/vero/trackable/base.rb
@@ -11,10 +11,10 @@ def self.included(base)
module ClassMethods
def trackable(*args)
@vero_trackable_map = case @vero_trackable_map
- when Array then (@vero_trackable_map << args).flatten
- else
- args
- end
+ when Array then (@vero_trackable_map << args).flatten
+ else
+ args
+ end
end
def trackable_map
diff --git a/lib/vero/version.rb b/lib/vero/version.rb
index c9989a1..893ba04 100644
--- a/lib/vero/version.rb
+++ b/lib/vero/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Vero
- VERSION = '1.0.0'
+ VERSION = "1.0.0"
end
diff --git a/lib/vero/view_helpers/javascript.rb b/lib/vero/view_helpers/javascript.rb
index 9976a63..dc3e3ee 100644
--- a/lib/vero/view_helpers/javascript.rb
+++ b/lib/vero/view_helpers/javascript.rb
@@ -4,7 +4,7 @@ module Vero
module ViewHelpers
module Javascript
def vero_javascript_tag(method = :default, context = Vero::App.default_context)
- return '' unless context.configured?
+ return "" unless context.configured?
config = context.config
@@ -17,26 +17,28 @@ def vero_javascript_tag(method = :default, context = Vero::App.default_context)
private
def default_vero_javascript_tag(options = {})
- content_tag :script, { type: 'text/javascript' } do
- result = 'var _veroq = _veroq || [];' \
+ content_tag :script, {type: "text/javascript"} do
+ result = "var _veroq = _veroq || [];" \
'setTimeout(function(){if(typeof window.Semblance=="undefined"){console.log("Vero did not load in time.");for(var i=0;i<_veroq.length;i++){a=_veroq[i];if(a.length==3&&typeof a[2]=="function")a[2](null,false);}}},3000);' \
"_veroq.push(['init', {" +
- options_to_string(options) +
- '}]);' \
- "(function() {var ve = document.createElement('script'); ve.type = 'text/javascript'; ve.async = true; ve.src = '//getvero.com/assets/m.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ve, s);})();"
+ options_to_string(options) +
+ "}]);" \
+ "(function() {var ve = document.createElement('script'); ve.type = 'text/javascript'; ve.async = true; ve.src = '//getvero.com/assets/m.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ve, s);})();"
result.html_safe
end.html_safe
end
- def mixpanel_vero_javascript_tag(options = {}); end
+ def mixpanel_vero_javascript_tag(options = {})
+ end
- def kissmetrics_vero_javascript_tag(options = {}); end
+ def kissmetrics_vero_javascript_tag(options = {})
+ end
def options_to_string(options)
options = {} unless options.is_a?(Hash)
keys = options.keys.map(&:to_s)
- keys.sort.map { |k| "\"#{k}\": \"#{options[k.to_sym]}\"" }.join(', ')
+ keys.sort.map { |k| "\"#{k}\": \"#{options[k.to_sym]}\"" }.join(", ")
end
end
end
diff --git a/spec/lib/api/base_api_spec.rb b/spec/lib/api/base_api_spec.rb
index 2b54c7a..23b8dcb 100644
--- a/spec/lib/api/base_api_spec.rb
+++ b/spec/lib/api/base_api_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::BaseAPI do
- let(:subject) { Vero::Api::Workers::BaseAPI.new('http://www.getvero.com', {}) }
+ let(:subject) { Vero::Api::Workers::BaseAPI.new("http://www.getvero.com", {}) }
describe :options_with_symbolized_keys do
- it 'should create a new options Hash with symbol keys (much like Hash#symbolize_keys in rails)' do
+ it "should create a new options Hash with symbol keys (much like Hash#symbolize_keys in rails)" do
expect(subject.options).to eq({})
- subject.options = { abc: 123 }
- expect(subject.options).to eq({ abc: 123 })
+ subject.options = {abc: 123}
+ expect(subject.options).to eq({abc: 123})
- subject.options = { 'abc' => 123 }
- expect(subject.options).to eq({ abc: 123 })
+ subject.options = {"abc" => 123}
+ expect(subject.options).to eq({abc: 123})
end
end
end
diff --git a/spec/lib/api/events/track_api_spec.rb b/spec/lib/api/events/track_api_spec.rb
index 7be3166..c52a9a2 100644
--- a/spec/lib/api/events/track_api_spec.rb
+++ b/spec/lib/api/events/track_api_spec.rb
@@ -1,64 +1,64 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Events::TrackAPI do
- subject { Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' }) }
+ subject { Vero::Api::Workers::Events::TrackAPI.new("https://api.getvero.com", {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: "test_event"}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/events/track.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/events/track.json" }
end
- context 'request with properties' do
+ context "request with properties" do
describe :validate! do
- it 'should raise an error if event_name is a blank String' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: nil }
+ it "should raise an error if event_name is a blank String" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: nil}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: "test_event"}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should raise an error if data is not either nil or a Hash' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event', data: [] }
+ it "should raise an error if data is not either nil or a Hash" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: "test_event", data: []}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event', data: nil }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: "test_event", data: nil}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event', data: {} }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: "test_event", data: {}}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should not raise an error when the keys are Strings' do
- options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'event_name' => 'test_event', 'data' => {} }
+ it "should not raise an error when the keys are Strings" do
+ options = {"auth_token" => "abcd", "identity" => {"email" => "test@test.com"}, "event_name" => "test_event", "data" => {}}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should not raise an error when keys are Strings for initialization' do
- options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'event_name' => 'test_event', 'data' => {} }
- expect { Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', options).send(:validate!) }.to_not raise_error
+ it "should not raise an error when keys are Strings for initialization" do
+ options = {"auth_token" => "abcd", "identity" => {"email" => "test@test.com"}, "event_name" => "test_event", "data" => {}}
+ expect { Vero::Api::Workers::Events::TrackAPI.new("https://api.getvero.com", options).send(:validate!) }.to_not raise_error
end
end
describe :request do
- it 'should send a JSON request to the Vero API' do
- expect(RestClient).to receive(:post).with('https://api.getvero.com/api/v2/events/track.json', { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' }.to_json, { content_type: :json, accept: :json })
+ it "should send a JSON request to the Vero API" do
+ expect(RestClient).to receive(:post).with("https://api.getvero.com/api/v2/events/track.json", {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: "test_event"}.to_json, {content_type: :json, accept: :json})
allow(RestClient).to receive(:post).and_return(200)
subject.send(:request)
end
end
end
- describe 'integration test' do
- it 'should not raise any errors' do
- obj = Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' })
+ describe "integration test" do
+ it "should not raise any errors" do
+ obj = Vero::Api::Workers::Events::TrackAPI.new("https://api.getvero.com", {auth_token: "abcd", identity: {email: "test@test.com"}, event_name: "test_event"})
allow(RestClient).to receive(:post).and_return(200)
expect { obj.perform }.to_not raise_error
diff --git a/spec/lib/api/users/delete_api_spec.rb b/spec/lib/api/users/delete_api_spec.rb
index 5170996..c0a9d17 100644
--- a/spec/lib/api/users/delete_api_spec.rb
+++ b/spec/lib/api/users/delete_api_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Users::DeleteAPI do
- subject { Vero::Api::Workers::Users::DeleteAPI.new('https://api.getvero.com', { auth_token: 'abcd', id: '1234' }) }
+ subject { Vero::Api::Workers::Users::DeleteAPI.new("https://api.getvero.com", {auth_token: "abcd", id: "1234"}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/delete.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/delete.json" }
end
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/delete.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/delete.json" }
end
describe :validate! do
- it 'should not raise an error when the keys are Strings' do
- subject.options = { 'auth_token' => 'abcd', 'id' => '1234' }
+ it "should not raise an error when the keys are Strings" do
+ subject.options = {"auth_token" => "abcd", "id" => "1234"}
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should raise an error for missing keys' do
- subject.options = { 'auth_token' => 'abcd' }
+ it "should raise an error for missing keys" do
+ subject.options = {"auth_token" => "abcd"}
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
end
end
describe :request do
- it 'should send a request to the Vero API' do
- expect(RestClient).to receive(:post).with('https://api.getvero.com/api/v2/users/delete.json', { auth_token: 'abcd', id: '1234' }).and_return(200)
+ it "should send a request to the Vero API" do
+ expect(RestClient).to receive(:post).with("https://api.getvero.com/api/v2/users/delete.json", {auth_token: "abcd", id: "1234"}).and_return(200)
subject.send(:request)
end
end
diff --git a/spec/lib/api/users/edit_api_spec.rb b/spec/lib/api/users/edit_api_spec.rb
index 10419ce..088062b 100644
--- a/spec/lib/api/users/edit_api_spec.rb
+++ b/spec/lib/api/users/edit_api_spec.rb
@@ -1,32 +1,32 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Users::EditAPI do
- subject { Vero::Api::Workers::Users::EditAPI.new('https://api.getvero.com', { auth_token: 'abcd', email: 'test@test.com', changes: { email: 'test@test.com' } }) }
+ subject { Vero::Api::Workers::Users::EditAPI.new("https://api.getvero.com", {auth_token: "abcd", email: "test@test.com", changes: {email: "test@test.com"}}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/edit.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/edit.json" }
end
describe :validate! do
- it 'should not raise an error when the keys are Strings' do
- options = { 'auth_token' => 'abcd', 'email' => 'test@test.com', 'changes' => { 'email' => 'test@test.com' } }
+ it "should not raise an error when the keys are Strings" do
+ options = {"auth_token" => "abcd", "email" => "test@test.com", "changes" => {"email" => "test@test.com"}}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
end
describe :request do
- it 'should send a request to the Vero API' do
- expect(RestClient).to receive(:put).with('https://api.getvero.com/api/v2/users/edit.json', { auth_token: 'abcd', email: 'test@test.com', changes: { email: 'test@test.com' } }.to_json, { content_type: :json, accept: :json })
+ it "should send a request to the Vero API" do
+ expect(RestClient).to receive(:put).with("https://api.getvero.com/api/v2/users/edit.json", {auth_token: "abcd", email: "test@test.com", changes: {email: "test@test.com"}}.to_json, {content_type: :json, accept: :json})
allow(RestClient).to receive(:put).and_return(200)
subject.send(:request)
end
end
- describe 'integration test' do
- it 'should not raise any errors' do
+ describe "integration test" do
+ it "should not raise any errors" do
allow(RestClient).to receive(:put).and_return(200)
expect { subject.perform }.to_not raise_error
end
diff --git a/spec/lib/api/users/edit_tags_api_spec.rb b/spec/lib/api/users/edit_tags_api_spec.rb
index 8d327dd..7ecc756 100644
--- a/spec/lib/api/users/edit_tags_api_spec.rb
+++ b/spec/lib/api/users/edit_tags_api_spec.rb
@@ -1,70 +1,70 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Users::EditTagsAPI do
- subject { Vero::Api::Workers::Users::EditTagsAPI.new('https://api.getvero.com', { auth_token: 'abcd', email: 'test@test.com', add: ['test'] }) }
+ subject { Vero::Api::Workers::Users::EditTagsAPI.new("https://api.getvero.com", {auth_token: "abcd", email: "test@test.com", add: ["test"]}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/tags/edit.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/tags/edit.json" }
end
describe :validate! do
- it 'should raise an error if email is a blank String' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: nil, add: [] }
+ it "should raise an error if email is a blank String" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: nil, add: []}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', add: [] }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com", add: []}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should raise an error if add is not an Array or missing' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', add: 'foo' }
+ it "should raise an error if add is not an Array or missing" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com", add: "foo"}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
end
- it 'should raise an error if remove is not an Array or missing' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', remove: 'foo' }
+ it "should raise an error if remove is not an Array or missing" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com", remove: "foo"}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
end
- it 'should raise an error if botha add and remove are missing' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com' }
+ it "should raise an error if botha add and remove are missing" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com"}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
end
- it 'should not raise an error if the correct arguments are passed' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', remove: ['Hi'] }
+ it "should not raise an error if the correct arguments are passed" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com", remove: ["Hi"]}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should not raise an error when the keys are Strings' do
- options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'email' => 'test@test.com', 'remove' => ['Hi'] }
+ it "should not raise an error when the keys are Strings" do
+ options = {"auth_token" => "abcd", "identity" => {"email" => "test@test.com"}, "email" => "test@test.com", "remove" => ["Hi"]}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
end
describe :request do
- it 'should send a request to the Vero API' do
- expect(RestClient).to receive(:put).with('https://api.getvero.com/api/v2/users/tags/edit.json', { auth_token: 'abcd', email: 'test@test.com', add: ['test'] }.to_json, { content_type: :json, accept: :json })
+ it "should send a request to the Vero API" do
+ expect(RestClient).to receive(:put).with("https://api.getvero.com/api/v2/users/tags/edit.json", {auth_token: "abcd", email: "test@test.com", add: ["test"]}.to_json, {content_type: :json, accept: :json})
allow(RestClient).to receive(:put).and_return(200)
subject.send(:request)
end
end
- describe 'integration test' do
- it 'should not raise any errors' do
+ describe "integration test" do
+ it "should not raise any errors" do
allow(RestClient).to receive(:put).and_return(200)
expect { subject.perform }.to_not raise_error
end
diff --git a/spec/lib/api/users/reidentify_spec.rb b/spec/lib/api/users/reidentify_spec.rb
index 0625591..15481ae 100644
--- a/spec/lib/api/users/reidentify_spec.rb
+++ b/spec/lib/api/users/reidentify_spec.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Users::ReidentifyAPI do
- subject { Vero::Api::Workers::Users::ReidentifyAPI.new('https://api.getvero.com', { auth_token: 'abcd', id: 'test@test.com', new_id: 'test2@test.com' }) }
+ subject { Vero::Api::Workers::Users::ReidentifyAPI.new("https://api.getvero.com", {auth_token: "abcd", id: "test@test.com", new_id: "test2@test.com"}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/reidentify.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/reidentify.json" }
end
describe :validate! do
- it 'should not raise an error when the keys are Strings' do
- options = { 'auth_token' => 'abcd', 'id' => 'test@test.com', 'new_id' => 'test2@test.com' }
+ it "should not raise an error when the keys are Strings" do
+ options = {"auth_token" => "abcd", "id" => "test@test.com", "new_id" => "test2@test.com"}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should raise an error if id is missing' do
- subject.options = { auth_token: 'abcd', new_id: 'test2@test.com' }
+ it "should raise an error if id is missing" do
+ subject.options = {auth_token: "abcd", new_id: "test2@test.com"}
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
end
- it 'should raise an error if new_id is missing' do
- subject.options = { auth_token: 'abcd', id: 'test@test.com' }
+ it "should raise an error if new_id is missing" do
+ subject.options = {auth_token: "abcd", id: "test@test.com"}
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
end
end
describe :request do
- it 'should send a request to the Vero API' do
- expect(RestClient).to receive(:put).with('https://api.getvero.com/api/v2/users/reidentify.json', { auth_token: 'abcd', id: 'test@test.com', new_id: 'test2@test.com' }.to_json, { content_type: :json, accept: :json })
+ it "should send a request to the Vero API" do
+ expect(RestClient).to receive(:put).with("https://api.getvero.com/api/v2/users/reidentify.json", {auth_token: "abcd", id: "test@test.com", new_id: "test2@test.com"}.to_json, {content_type: :json, accept: :json})
allow(RestClient).to receive(:put).and_return(200)
subject.send(:request)
end
end
- describe 'integration test' do
- it 'should not raise any errors' do
+ describe "integration test" do
+ it "should not raise any errors" do
allow(RestClient).to receive(:put).and_return(200)
expect { subject.perform }.to_not raise_error
end
diff --git a/spec/lib/api/users/resubscribe_api_spec.rb b/spec/lib/api/users/resubscribe_api_spec.rb
index 6b77da0..a8a8a0a 100644
--- a/spec/lib/api/users/resubscribe_api_spec.rb
+++ b/spec/lib/api/users/resubscribe_api_spec.rb
@@ -1,31 +1,31 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Users::ResubscribeAPI do
- subject { Vero::Api::Workers::Users::ResubscribeAPI.new('https://api.getvero.com', { auth_token: 'abcd', id: '1234' }) }
+ subject { Vero::Api::Workers::Users::ResubscribeAPI.new("https://api.getvero.com", {auth_token: "abcd", id: "1234"}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/resubscribe.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/resubscribe.json" }
end
describe :validate! do
- it 'should not raise an error when the keys are Strings' do
- subject.options = { 'auth_token' => 'abcd', 'id' => '1234' }
+ it "should not raise an error when the keys are Strings" do
+ subject.options = {"auth_token" => "abcd", "id" => "1234"}
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should raise an error for missing keys' do
- subject.options = { 'auth_token' => 'abcd' }
+ it "should raise an error for missing keys" do
+ subject.options = {"auth_token" => "abcd"}
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
end
end
describe :request do
- it 'should send a request to the Vero API' do
+ it "should send a request to the Vero API" do
expect(RestClient).to(
receive(:post)
- .with('https://api.getvero.com/api/v2/users/resubscribe.json', { auth_token: 'abcd', id: '1234' })
+ .with("https://api.getvero.com/api/v2/users/resubscribe.json", {auth_token: "abcd", id: "1234"})
)
allow(RestClient).to receive(:post).and_return(200)
diff --git a/spec/lib/api/users/track_api_spec.rb b/spec/lib/api/users/track_api_spec.rb
index 81f49f8..8b8dc8a 100644
--- a/spec/lib/api/users/track_api_spec.rb
+++ b/spec/lib/api/users/track_api_spec.rb
@@ -1,64 +1,64 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Users::TrackAPI do
- subject { Vero::Api::Workers::Users::TrackAPI.new('https://api.getvero.com', { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com' }) }
+ subject { Vero::Api::Workers::Users::TrackAPI.new("https://api.getvero.com", {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com"}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/track.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/track.json" }
end
describe :validate! do
- it 'should raise an error if email and id are are blank String' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: nil, email: nil }
+ it "should raise an error if email and id are are blank String" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, id: nil, email: nil}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: nil, email: 'test@test.com' }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, id: nil, email: "test@test.com"}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: '', email: nil }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, id: "", email: nil}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: 'user123', email: nil }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, id: "user123", email: nil}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should raise an error if data is not either nil or a Hash' do
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', data: [] }
+ it "should raise an error if data is not either nil or a Hash" do
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com", data: []}
subject.options = options
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', data: nil }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com", data: nil}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
- options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', data: {} }
+ options = {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com", data: {}}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
- it 'should not raise an error when the keys are Strings' do
- options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'email' => 'test@test.com', 'data' => {} }
+ it "should not raise an error when the keys are Strings" do
+ options = {"auth_token" => "abcd", "identity" => {"email" => "test@test.com"}, "email" => "test@test.com", "data" => {}}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
end
describe :request do
- it 'should send a request to the Vero API' do
- expect(RestClient).to receive(:post).with('https://api.getvero.com/api/v2/users/track.json', { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com' }.to_json, { content_type: :json, accept: :json })
+ it "should send a request to the Vero API" do
+ expect(RestClient).to receive(:post).with("https://api.getvero.com/api/v2/users/track.json", {auth_token: "abcd", identity: {email: "test@test.com"}, email: "test@test.com"}.to_json, {content_type: :json, accept: :json})
allow(RestClient).to receive(:post).and_return(200)
subject.send(:request)
end
end
- describe 'integration test' do
- it 'should not raise any errors' do
+ describe "integration test" do
+ it "should not raise any errors" do
allow(RestClient).to receive(:post).and_return(200)
expect { subject.perform }.to_not raise_error
end
diff --git a/spec/lib/api/users/unsubscribe_api_spec.rb b/spec/lib/api/users/unsubscribe_api_spec.rb
index 86db882..749903d 100644
--- a/spec/lib/api/users/unsubscribe_api_spec.rb
+++ b/spec/lib/api/users/unsubscribe_api_spec.rb
@@ -1,32 +1,32 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Workers::Users::UnsubscribeAPI do
- subject { Vero::Api::Workers::Users::UnsubscribeAPI.new('https://api.getvero.com', { auth_token: 'abcd', email: 'test@test.com', changes: { email: 'test@test.com' } }) }
+ subject { Vero::Api::Workers::Users::UnsubscribeAPI.new("https://api.getvero.com", {auth_token: "abcd", email: "test@test.com", changes: {email: "test@test.com"}}) }
- it_behaves_like 'a Vero wrapper' do
- let(:end_point) { '/api/v2/users/unsubscribe.json' }
+ it_behaves_like "a Vero wrapper" do
+ let(:end_point) { "/api/v2/users/unsubscribe.json" }
end
describe :validate! do
- it 'should not raise an error when the keys are Strings' do
- options = { 'auth_token' => 'abcd', 'email' => 'test@test.com', 'changes' => { 'email' => 'test@test.com' } }
+ it "should not raise an error when the keys are Strings" do
+ options = {"auth_token" => "abcd", "email" => "test@test.com", "changes" => {"email" => "test@test.com"}}
subject.options = options
expect { subject.send(:validate!) }.to_not raise_error
end
end
describe :request do
- it 'should send a request to the Vero API' do
- expect(RestClient).to receive(:post).with('https://api.getvero.com/api/v2/users/unsubscribe.json', { auth_token: 'abcd', email: 'test@test.com', changes: { email: 'test@test.com' } })
+ it "should send a request to the Vero API" do
+ expect(RestClient).to receive(:post).with("https://api.getvero.com/api/v2/users/unsubscribe.json", {auth_token: "abcd", email: "test@test.com", changes: {email: "test@test.com"}})
allow(RestClient).to receive(:post).and_return(200)
subject.send(:request)
end
end
- describe 'integration test' do
- it 'should not raise any errors' do
+ describe "integration test" do
+ it "should not raise any errors" do
allow(RestClient).to receive(:post).and_return(200)
expect { subject.perform }.to_not raise_error
end
diff --git a/spec/lib/api_spec.rb b/spec/lib/api_spec.rb
index e1e230b..cf46c4e 100644
--- a/spec/lib/api_spec.rb
+++ b/spec/lib/api_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Api::Events do
let(:subject) { Vero::Api::Events }
describe :track! do
- it 'should call the TrackAPI object via the configured sender' do
- input = { event_name: 'test_event', identity: { email: 'james@getvero.com' }, data: { test: 'test' } }
- expected = input.merge(tracking_api_key: 'abc123', development_mode: true)
+ it "should call the TrackAPI object via the configured sender" do
+ input = {event_name: "test_event", identity: {email: "james@getvero.com"}, data: {test: "test"}}
+ expected = input.merge(tracking_api_key: "abc123", development_mode: true)
mock_context = Vero::Context.new
allow(mock_context.config).to receive(:configured?).and_return(true)
- allow(mock_context.config).to receive(:tracking_api_key).and_return('abc123')
+ allow(mock_context.config).to receive(:tracking_api_key).and_return("abc123")
allow(mock_context.config).to receive(:development_mode).and_return(true)
allow(Vero::App).to receive(:default_context).and_return(mock_context)
- expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Events::TrackAPI, true, 'https://api.getvero.com', expected)
+ expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Events::TrackAPI, true, "https://api.getvero.com", expected)
subject.track!(input)
end
@@ -27,67 +27,67 @@
describe Vero::Api::Users do
let(:subject) { Vero::Api::Users }
let(:mock_context) { Vero::Context.new }
- let(:expected) { input.merge(tracking_api_key: 'abc123', development_mode: true) }
+ let(:expected) { input.merge(tracking_api_key: "abc123", development_mode: true) }
before :each do
allow(mock_context.config).to receive(:configured?).and_return(true)
- allow(mock_context.config).to receive(:tracking_api_key).and_return('abc123')
+ allow(mock_context.config).to receive(:tracking_api_key).and_return("abc123")
allow(mock_context.config).to receive(:development_mode).and_return(true)
allow(Vero::App).to receive(:default_context).and_return(mock_context)
end
describe :track! do
- context 'should call the TrackAPI object via the configured sender' do
- let(:input) { { email: 'james@getvero.com', data: { age: 25 } } }
+ context "should call the TrackAPI object via the configured sender" do
+ let(:input) { {email: "james@getvero.com", data: {age: 25}} }
specify do
- expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::TrackAPI, true, 'https://api.getvero.com', expected)
+ expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::TrackAPI, true, "https://api.getvero.com", expected)
subject.track!(input)
end
end
end
describe :edit_user! do
- context 'should call the TrackAPI object via the configured sender' do
- let(:input) { { email: 'james@getvero.com', changes: { age: 25 } } }
+ context "should call the TrackAPI object via the configured sender" do
+ let(:input) { {email: "james@getvero.com", changes: {age: 25}} }
specify do
- expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::EditAPI, true, 'https://api.getvero.com', expected)
+ expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::EditAPI, true, "https://api.getvero.com", expected)
subject.edit_user!(input)
end
end
end
describe :edit_user_tags! do
- context 'should call the TrackAPI object via the configured sender' do
- let(:input) { { add: ['boom'], remove: ['tish'] } }
+ context "should call the TrackAPI object via the configured sender" do
+ let(:input) { {add: ["boom"], remove: ["tish"]} }
specify do
- expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::EditTagsAPI, true, 'https://api.getvero.com', expected)
+ expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::EditTagsAPI, true, "https://api.getvero.com", expected)
subject.edit_user_tags!(input)
end
end
end
describe :unsubscribe! do
- context 'should call the TrackAPI object via the configured sender' do
- let(:input) { { email: 'james@getvero' } }
+ context "should call the TrackAPI object via the configured sender" do
+ let(:input) { {email: "james@getvero"} }
specify do
- expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::UnsubscribeAPI, true, 'https://api.getvero.com', expected)
+ expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::UnsubscribeAPI, true, "https://api.getvero.com", expected)
subject.unsubscribe!(input)
end
end
end
describe :resubscribe! do
- context 'should call the TrackAPI object via the configured sender' do
- let(:input) { { email: 'james@getvero' } }
+ context "should call the TrackAPI object via the configured sender" do
+ let(:input) { {email: "james@getvero"} }
specify do
expect(Vero::Sender).to(
receive(:send)
- .with(Vero::Api::Workers::Users::ResubscribeAPI, true, 'https://api.getvero.com', expected)
+ .with(Vero::Api::Workers::Users::ResubscribeAPI, true, "https://api.getvero.com", expected)
)
subject.resubscribe!(input)
end
diff --git a/spec/lib/app_spec.rb b/spec/lib/app_spec.rb
index ce3b1bf..fec2490 100644
--- a/spec/lib/app_spec.rb
+++ b/spec/lib/app_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::App do
- describe 'self.default_context' do
- it 'inherits from Vero::Context' do
+ describe "self.default_context" do
+ it "inherits from Vero::Context" do
actual = Vero::App.default_context
expect(actual).to be_a(Vero::Context)
end
@@ -12,22 +12,22 @@
let(:context) { Vero::App.default_context }
describe :init do
- it 'should ignore configuring the config if no block is provided' do
+ it "should ignore configuring the config if no block is provided" do
Vero::App.init
expect(context.configured?).to be(false)
end
- it 'should pass configuration defined in the block to the config file' do
+ it "should pass configuration defined in the block to the config file" do
Vero::App.init
expect(context.config.tracking_api_key).to be_nil
Vero::App.init do |c|
- c.tracking_api_key = 'abcd1234'
+ c.tracking_api_key = "abcd1234"
end
- expect(context.config.tracking_api_key).to eq('abcd1234')
+ expect(context.config.tracking_api_key).to eq("abcd1234")
end
- it 'should init should be able to set async' do
+ it "should init should be able to set async" do
Vero::App.init do |c|
c.async = false
end
@@ -41,7 +41,7 @@
end
describe :disable_requests! do
- it 'should change config.disabled' do
+ it "should change config.disabled" do
Vero::App.init
expect(context.config.disabled).to be(false)
@@ -51,10 +51,10 @@
end
describe :log do
- it 'should have a log method' do
+ it "should have a log method" do
Vero::App.init
expect(Vero::App).to receive(:log)
- Vero::App.log(Object, 'test')
+ Vero::App.log(Object, "test")
end
end
end
diff --git a/spec/lib/config_spec.rb b/spec/lib/config_spec.rb
index da4a46f..9f03e35 100644
--- a/spec/lib/config_spec.rb
+++ b/spec/lib/config_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Config do
let(:config) { Vero::Config.new }
- it 'should be async by default' do
+ it "should be async by default" do
expect(config.async).to be(true)
end
describe :reset! do
- it 'should reset all attributes' do
- config.tracking_api_key = 'abcd1234'
+ it "should reset all attributes" do
+ config.tracking_api_key = "abcd1234"
config.reset!
expect(config.tracking_api_key).to be_nil
@@ -19,66 +19,66 @@
end
describe :tracking_api_key do
- it 'should return nil if tracking_api_key is not set' do
+ it "should return nil if tracking_api_key is not set" do
config.tracking_api_key = nil
expect(config.tracking_api_key).to be_nil
end
- it 'should return an expected tracking_api_key' do
- config.tracking_api_key = 'abcd1234'
- expect(config.tracking_api_key).to eq('abcd1234')
+ it "should return an expected tracking_api_key" do
+ config.tracking_api_key = "abcd1234"
+ expect(config.tracking_api_key).to eq("abcd1234")
end
end
describe :request_params do
- it 'should return a hash of tracking_api_key and development_mode if they are set' do
+ it "should return a hash of tracking_api_key and development_mode if they are set" do
config.tracking_api_key = nil
config.development_mode = nil
expect(config.request_params).to eq({})
- config.tracking_api_key = 'abcd1234'
- expect(config.request_params).to eq({ tracking_api_key: 'abcd1234' })
+ config.tracking_api_key = "abcd1234"
+ expect(config.request_params).to eq({tracking_api_key: "abcd1234"})
config.development_mode = true
- expect(config.request_params).to eq({ tracking_api_key: 'abcd1234', development_mode: true })
+ expect(config.request_params).to eq({tracking_api_key: "abcd1234", development_mode: true})
end
end
describe :domain do
- it 'should return https://api.getvero.com when not set' do
- expect(config.domain).to eq('https://api.getvero.com')
- config.domain = 'blah.com'
- expect(config.domain).not_to eq('https://api.getvero.com')
+ it "should return https://api.getvero.com when not set" do
+ expect(config.domain).to eq("https://api.getvero.com")
+ config.domain = "blah.com"
+ expect(config.domain).not_to eq("https://api.getvero.com")
end
- it 'should return the domain value' do
- config.domain = 'test.unbelieveable.com.au'
- expect(config.domain).to eq('http://test.unbelieveable.com.au')
+ it "should return the domain value" do
+ config.domain = "test.unbelieveable.com.au"
+ expect(config.domain).to eq("http://test.unbelieveable.com.au")
- config.domain = 'http://test.unbelieveable.com.au'
- expect(config.domain).to eq('http://test.unbelieveable.com.au')
+ config.domain = "http://test.unbelieveable.com.au"
+ expect(config.domain).to eq("http://test.unbelieveable.com.au")
end
end
describe :development_mode do
- it 'by default it should return false regardless of Rails environment' do
- stub_env('development') do
+ it "by default it should return false regardless of Rails environment" do
+ stub_env("development") do
config = Vero::Config.new
expect(config.development_mode).to be(false)
end
- stub_env('test') do
+ stub_env("test") do
config = Vero::Config.new
expect(config.development_mode).to be(false)
end
- stub_env('production') do
+ stub_env("production") do
config = Vero::Config.new
expect(config.development_mode).to be(false)
end
end
- it 'can be overritten with the config block' do
+ it "can be overritten with the config block" do
config.development_mode = true
expect(config.request_params[:development_mode]).to be(true)
@@ -88,8 +88,8 @@
end
describe :test_mode do
- it 'should not raise error even though not configured properly' do
- input = { event_name: 'test_event' }
+ it "should not raise error even though not configured properly" do
+ input = {event_name: "test_event"}
mock_context = Vero::Context.new
allow(mock_context.config).to receive(:configured?).and_return(false)
diff --git a/spec/lib/context_spec.rb b/spec/lib/context_spec.rb
index e9dfbe5..bb85289 100644
--- a/spec/lib/context_spec.rb
+++ b/spec/lib/context_spec.rb
@@ -1,41 +1,41 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Context do
let(:context) { Vero::Context.new }
describe :initialize do
- it 'accepts multiple parameter types' do
- context1 = Vero::Context.new({ tracking_api_key: 'didah' })
+ it "accepts multiple parameter types" do
+ context1 = Vero::Context.new({tracking_api_key: "didah"})
expect(context1).to be_a(Vero::Context)
- expect(context1.config.tracking_api_key).to eq('didah')
+ expect(context1.config.tracking_api_key).to eq("didah")
context2 = Vero::Context.new(context1)
expect(context2).to be_a(Vero::Context)
expect(context2).not_to be(context1)
- expect(context2.config.tracking_api_key).to eq('didah')
+ expect(context2.config.tracking_api_key).to eq("didah")
- context3 = Vero::Context.new VeroUser.new('tracking_api_key')
+ context3 = Vero::Context.new VeroUser.new("tracking_api_key")
expect(context3).to be_a(Vero::Context)
- expect(context3.config.tracking_api_key).to eq('tracking_api_key')
+ expect(context3.config.tracking_api_key).to eq("tracking_api_key")
end
end
describe :configure do
- it 'should ignore configuring the config if no block is provided' do
+ it "should ignore configuring the config if no block is provided" do
context.configure
expect(context.configured?).to be(false)
end
- it 'should pass configuration defined in the block to the config file' do
+ it "should pass configuration defined in the block to the config file" do
context.configure do |c|
- c.tracking_api_key = 'abcd1234'
+ c.tracking_api_key = "abcd1234"
end
- expect(context.config.tracking_api_key).to eq('abcd1234')
+ expect(context.config.tracking_api_key).to eq("abcd1234")
end
- it 'should init should be able to set async' do
+ it "should init should be able to set async" do
context.configure do |c|
c.async = false
end
@@ -49,7 +49,7 @@
end
describe :disable_requests! do
- it 'should change config.disabled' do
+ it "should change config.disabled" do
expect(context.config.disabled).to be(false)
context.disable_requests!
expect(context.config.disabled).to be(true)
diff --git a/spec/lib/dsl_spec.rb b/spec/lib/dsl_spec.rb
index 71906ef..5f56b9e 100644
--- a/spec/lib/dsl_spec.rb
+++ b/spec/lib/dsl_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::DSL do
subject(:dsl) { Class.new.extend(Vero::DSL) }
- describe '#vero' do
- it 'is a proxy to the API' do
+ describe "#vero" do
+ it "is a proxy to the API" do
expect(dsl.vero).to be_an_instance_of(Vero::DSL::Proxy)
end
end
@@ -15,18 +15,18 @@
describe Vero::DSL::Proxy do
subject(:proxy) { described_class.new }
- describe '#users' do
- it 'is a pointer to Vero::Api::Users' do
+ describe "#users" do
+ it "is a pointer to Vero::Api::Users" do
expect(proxy.users).to eql(Vero::Api::Users)
end
- it 'should respond to reidentify!' do
+ it "should respond to reidentify!" do
expect(proxy.users.respond_to?(:reidentify!)).to be(true)
end
end
- describe '#events' do
- it 'is a pointer to Vero::Api::Events' do
+ describe "#events" do
+ it "is a pointer to Vero::Api::Events" do
expect(proxy.events).to eql(Vero::Api::Events)
end
end
diff --git a/spec/lib/sender_spec.rb b/spec/lib/sender_spec.rb
index 152f23f..88ed26d 100644
--- a/spec/lib/sender_spec.rb
+++ b/spec/lib/sender_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Sender do
subject { Vero::Sender }
- describe '.senders' do
- it 'should automatically find senders that are not defined' do
+ describe ".senders" do
+ it "should automatically find senders that are not defined" do
expect(subject.senders[:delayed_job]).to eq(Vero::Senders::DelayedJob)
expect(subject.senders[:sucker_punch]).to eq(Vero::Senders::SuckerPunch)
expect(subject.senders[:resque]).to eq(Vero::Senders::Resque)
@@ -15,7 +15,7 @@
expect(subject.senders[:none]).to eq(Vero::Senders::Base)
end
- it 'should fallback to Vero::Senders::Base' do
+ it "should fallback to Vero::Senders::Base" do
expect(subject.senders[:unsupported_sender]).to eq(Vero::Senders::Base)
end
end
diff --git a/spec/lib/senders/sidekiq_spec.rb b/spec/lib/senders/sidekiq_spec.rb
index cdebddb..2a0568b 100644
--- a/spec/lib/senders/sidekiq_spec.rb
+++ b/spec/lib/senders/sidekiq_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Vero::Senders::Sidekiq do
subject { Vero::Senders::Sidekiq.new }
describe :call do
- it 'should perform_async a Vero::SidekiqWorker' do
+ it "should perform_async a Vero::SidekiqWorker" do
expect(Vero::SidekiqWorker).to(
receive(:perform_async)
- .with('Vero::Api::Workers::Events::TrackAPI', 'abc', { test: 'abc' })
+ .with("Vero::Api::Workers::Events::TrackAPI", "abc", {test: "abc"})
.once
)
- subject.call(Vero::Api::Workers::Events::TrackAPI, 'abc', { test: 'abc' })
+ subject.call(Vero::Api::Workers::Events::TrackAPI, "abc", {test: "abc"})
end
end
end
@@ -19,14 +19,14 @@
describe Vero::SidekiqWorker do
subject { Vero::SidekiqWorker.new }
describe :perform do
- it 'should call the api method' do
+ it "should call the api method" do
mock_api = double(Vero::Api::Workers::Events::TrackAPI)
expect(mock_api).to receive(:perform).once
allow(Vero::Api::Workers::Events::TrackAPI).to receive(:new).and_return(mock_api)
- expect(Vero::Api::Workers::Events::TrackAPI).to receive(:new).with('abc', { test: 'abc' }).once
+ expect(Vero::Api::Workers::Events::TrackAPI).to receive(:new).with("abc", {test: "abc"}).once
- subject.perform('Vero::Api::Workers::Events::TrackAPI', 'abc', { test: 'abc' })
+ subject.perform("Vero::Api::Workers::Events::TrackAPI", "abc", {test: "abc"})
end
end
end
diff --git a/spec/lib/trackable_spec.rb b/spec/lib/trackable_spec.rb
index 7ce2742..76f7300 100644
--- a/spec/lib/trackable_spec.rb
+++ b/spec/lib/trackable_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
def vero_context(user, logging = true, async = false, disabled = true)
context = Vero::Context.new(Vero::App.default_context)
@@ -15,32 +15,32 @@ def vero_context(user, logging = true, async = false, disabled = true)
describe Vero::Trackable do
before :each do
@request_params = {
- event_name: 'test_event',
- tracking_api_key: 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
- identity: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' },
- data: { test: 1 },
+ event_name: "test_event",
+ tracking_api_key: "YWJjZDEyMzQ6ZWZnaDU2Nzg=",
+ identity: {email: "durkster@gmail.com", age: 20, _user_type: "User"},
+ data: {test: 1},
development_mode: true
}
- @url = 'https://api.getvero.com/api/v1/track.json'
+ @url = "https://api.getvero.com/api/v1/track.json"
@user = User.new
- @content_type_params = { content_type: :json, accept: :json }
+ @content_type_params = {content_type: :json, accept: :json}
end
- context 'the gem has not been configured' do
+ context "the gem has not been configured" do
before { Vero::App.reset! }
- it 'should raise an error when API requests are made' do
+ it "should raise an error when API requests are made" do
expect { @user.track(@request_params[:event_name], @request_params[:data]) }.to raise_error(RuntimeError)
- allow(@user).to receive(:post_later).and_return('success')
+ allow(@user).to receive(:post_later).and_return("success")
expect { @user.identity! }.to raise_error(NoMethodError)
end
end
- context 'the gem has been configured' do
+ context "the gem has been configured" do
before do
Vero::App.init do |c|
- c.tracking_api_key = 'YWJjZDEyMzQ6ZWZnaDU2Nzg='
+ c.tracking_api_key = "YWJjZDEyMzQ6ZWZnaDU2Nzg="
c.async = false
end
end
@@ -48,21 +48,21 @@ def vero_context(user, logging = true, async = false, disabled = true)
describe :track! do
before do
@request_params = {
- event_name: 'test_event',
- identity: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' },
- data: { test: 1 },
+ event_name: "test_event",
+ identity: {email: "durkster@gmail.com", age: 20, _user_type: "User"},
+ data: {test: 1},
extras: {}
}
- @url = 'https://api.getvero.com/api/v1/track.json'
+ @url = "https://api.getvero.com/api/v1/track.json"
end
- it 'should not send a track request when the required parameters are invalid' do
+ it "should not send a track request when the required parameters are invalid" do
expect { @user.track!(nil) }.to raise_error(ArgumentError)
- expect { @user.track!('') }.to raise_error(ArgumentError)
- expect { @user.track!('test', '') }.to raise_error(ArgumentError)
+ expect { @user.track!("") }.to raise_error(ArgumentError)
+ expect { @user.track!("test", "") }.to raise_error(ArgumentError)
end
- it 'should send a `track!` request when async is set to false' do
+ it "should send a `track!` request when async is set to false" do
context = vero_context(@user)
allow(@user).to receive(:with_vero_context).and_return(context)
@@ -77,13 +77,13 @@ def vero_context(user, logging = true, async = false, disabled = true)
expect(@user.track!(@request_params[:event_name])).to eq(200)
end
- context 'when set to be async' do
+ context "when set to be async" do
before do
@context = vero_context(@user, true, true)
allow(@user).to receive(:with_vero_context).and_return(@context)
end
- it 'sends' do
+ it "sends" do
expect(@user.track!(@request_params[:event_name], @request_params[:data])).to be_nil
expect(@user.track!(@request_params[:event_name])).to be_nil
end
@@ -94,13 +94,13 @@ def vero_context(user, logging = true, async = false, disabled = true)
before do
@request_params = {
id: nil,
- email: 'durkster@gmail.com',
- data: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' }
+ email: "durkster@gmail.com",
+ data: {email: "durkster@gmail.com", age: 20, _user_type: "User"}
}
- @url = 'https://api.getvero.com/api/v2/users/track.json'
+ @url = "https://api.getvero.com/api/v2/users/track.json"
end
- it 'should send an `identify` request when async is set to false' do
+ it "should send an `identify` request when async is set to false" do
context = vero_context(@user)
allow(@user).to receive(:with_vero_context).and_return(context)
@@ -110,13 +110,13 @@ def vero_context(user, logging = true, async = false, disabled = true)
expect(@user.identify!).to eq(200)
end
- context 'when set to use async' do
+ context "when set to use async" do
before do
@context = vero_context(@user, false, true)
allow(@user).to receive(:with_vero_context).and_return(@context)
end
- it 'sends' do
+ it "sends" do
expect(@user.identify!).to be_nil
end
end
@@ -126,13 +126,13 @@ def vero_context(user, logging = true, async = false, disabled = true)
before do
@request_params = {
id: nil,
- email: 'durkster@gmail.com',
- changes: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' }
+ email: "durkster@gmail.com",
+ changes: {email: "durkster@gmail.com", age: 20, _user_type: "User"}
}
- @url = 'https://api.getvero.com/api/v2/users/edit.json'
+ @url = "https://api.getvero.com/api/v2/users/edit.json"
end
- it 'should send an `update_user` request when async is set to false' do
+ it "should send an `update_user` request when async is set to false" do
context = Vero::Context.new(Vero::App.default_context)
context.subject = @user
@@ -144,13 +144,13 @@ def vero_context(user, logging = true, async = false, disabled = true)
expect(@user.with_vero_context.update_user!).to eq(200)
end
- context 'when set to use async' do
+ context "when set to use async" do
before do
@context = vero_context(@user, false, true)
allow(@user).to receive(:with_vero_context).and_return(@context)
end
- it 'sends' do
+ it "sends" do
expect(@user.with_vero_context.update_user!).to be_nil
end
end
@@ -160,14 +160,14 @@ def vero_context(user, logging = true, async = false, disabled = true)
before do
@request_params = {
id: nil,
- email: 'durkster@gmail.com',
+ email: "durkster@gmail.com",
add: [],
remove: []
}
- @url = 'https://api.getvero.com/api/v2/users/tags/edit.json'
+ @url = "https://api.getvero.com/api/v2/users/tags/edit.json"
end
- it 'should send an `update_user_tags` request when async is set to false' do
+ it "should send an `update_user_tags` request when async is set to false" do
context = Vero::Context.new(Vero::App.default_context)
context.subject = @user
context.config.async = false
@@ -180,7 +180,7 @@ def vero_context(user, logging = true, async = false, disabled = true)
expect(@user.with_vero_context.update_user_tags!).to eq(200)
end
- it 'should send using another thread when async is set to true' do
+ it "should send using another thread when async is set to true" do
context = Vero::Context.new(Vero::App.default_context)
context.subject = @user
context.config.async = true
@@ -195,12 +195,12 @@ def vero_context(user, logging = true, async = false, disabled = true)
before do
@request_params = {
id: nil,
- email: 'durkster@gmail.com'
+ email: "durkster@gmail.com"
}
- @url = 'https://api.getvero.com/api/v2/users/unsubscribe.json'
+ @url = "https://api.getvero.com/api/v2/users/unsubscribe.json"
end
- it 'should send an `update_user` request when async is set to false' do
+ it "should send an `update_user` request when async is set to false" do
context = Vero::Context.new(Vero::App.default_context)
context.subject = @user
context.config.async = false
@@ -213,13 +213,13 @@ def vero_context(user, logging = true, async = false, disabled = true)
expect(@user.with_vero_context.unsubscribe!).to eq(200)
end
- context 'when using async' do
+ context "when using async" do
before do
@context = vero_context(@user, false, true)
allow(@user).to receive(:with_vero_context).and_return(@context)
end
- it 'sends' do
+ it "sends" do
expect(@user.with_vero_context.unsubscribe!).to be_nil
end
end
@@ -228,20 +228,20 @@ def vero_context(user, logging = true, async = false, disabled = true)
describe :trackable do
before { User.reset_trackable_map! }
- it 'should build an array of trackable params' do
+ it "should build an array of trackable params" do
User.trackable :email, :age
expect(User.trackable_map).to eq(%i[email age])
end
- it 'should append new trackable items to an existing trackable map' do
+ it "should append new trackable items to an existing trackable map" do
User.trackable :email, :age
User.trackable :hair_colour
expect(User.trackable_map).to eq(%i[email age hair_colour])
end
it "should append an extra's hash to the trackable map" do
- User.trackable :email, { extras: :properties }
- expect(User.trackable_map).to eq([:email, { extras: :properties }])
+ User.trackable :email, {extras: :properties}
+ expect(User.trackable_map).to eq([:email, {extras: :properties}])
end
end
@@ -251,67 +251,67 @@ def vero_context(user, logging = true, async = false, disabled = true)
User.trackable :email, :age
end
- it 'should return a hash of all values mapped by trackable' do
+ it "should return a hash of all values mapped by trackable" do
user = User.new
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'User' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", age: 20, _user_type: "User"})
user = UserWithoutEmail.new
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithoutEmail' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", age: 20, _user_type: "UserWithoutEmail"})
user = UserWithEmailAddress.new
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithEmailAddress' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", age: 20, _user_type: "UserWithEmailAddress"})
user = UserWithoutInterface.new
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithoutInterface' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", age: 20, _user_type: "UserWithoutInterface"})
user = UserWithNilAttributes.new
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithNilAttributes' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", _user_type: "UserWithNilAttributes"})
end
- it 'should take into account any defined extras' do
+ it "should take into account any defined extras" do
user = UserWithExtras.new
user.properties = nil
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithExtras' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", _user_type: "UserWithExtras"})
- user.properties = 'test'
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithExtras' })
+ user.properties = "test"
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", _user_type: "UserWithExtras"})
user.properties = {}
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithExtras' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", _user_type: "UserWithExtras"})
user.properties = {
age: 20,
- gender: 'female'
+ gender: "female"
}
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, gender: 'female', _user_type: 'UserWithExtras' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", age: 20, gender: "female", _user_type: "UserWithExtras"})
user = UserWithPrivateExtras.new
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 26, _user_type: 'UserWithPrivateExtras' })
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", age: 26, _user_type: "UserWithPrivateExtras"})
end
- it 'should allow extras to be provided instead :id or :email' do
+ it "should allow extras to be provided instead :id or :email" do
user = UserWithOnlyExtras.new
- user.properties = { email: user.email }
- expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithOnlyExtras' })
+ user.properties = {email: user.email}
+ expect(user.to_vero).to eq({email: "durkster@gmail.com", _user_type: "UserWithOnlyExtras"})
end
end
describe :with_vero_context do
- it 'should be able to change contexts' do
+ it "should be able to change contexts" do
user = User.new
- expect(user.with_default_vero_context.config.config_params).to eq({ tracking_api_key: 'YWJjZDEyMzQ6ZWZnaDU2Nzg=' })
- expect(user.with_vero_context({ tracking_api_key: 'boom' }).config.config_params).to eq({ tracking_api_key: 'boom' })
+ expect(user.with_default_vero_context.config.config_params).to eq({tracking_api_key: "YWJjZDEyMzQ6ZWZnaDU2Nzg="})
+ expect(user.with_vero_context({tracking_api_key: "boom"}).config.config_params).to eq({tracking_api_key: "boom"})
end
end
- it 'should work when Vero::Trackable::Interface is not included' do
+ it "should work when Vero::Trackable::Interface is not included" do
user = UserWithoutInterface.new
request_params = {
- event_name: 'test_event',
- tracking_api_key: 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
- identity: { email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithoutInterface' },
- data: { test: 1 },
+ event_name: "test_event",
+ tracking_api_key: "YWJjZDEyMzQ6ZWZnaDU2Nzg=",
+ identity: {email: "durkster@gmail.com", age: 20, _user_type: "UserWithoutInterface"},
+ data: {test: 1},
development_mode: true
}
diff --git a/spec/lib/view_helpers_spec.rb b/spec/lib/view_helpers_spec.rb
index cc48b12..d0a9f4b 100644
--- a/spec/lib/view_helpers_spec.rb
+++ b/spec/lib/view_helpers_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-require 'rails'
-require 'action_view'
-require 'active_support'
-require 'vero/view_helpers/javascript'
+require "rails"
+require "action_view"
+require "active_support"
+require "vero/view_helpers/javascript"
# rubocop:disable Style/MixinUsage
include Vero::ViewHelpers::Javascript
@@ -20,16 +20,16 @@
subject { Vero::ViewHelpers::Javascript }
describe :vero_javascript_tag do
- it 'should return an empty string if Vero::App is not properly configured' do
- expect(subject.vero_javascript_tag).to eq('')
+ it "should return an empty string if Vero::App is not properly configured" do
+ expect(subject.vero_javascript_tag).to eq("")
Vero::App.init
- expect(subject.vero_javascript_tag).to eq('')
+ expect(subject.vero_javascript_tag).to eq("")
end
- context 'Vero::App has been properly configured' do
+ context "Vero::App has been properly configured" do
before :each do
- @tracking_api_key = 'abcd1234'
+ @tracking_api_key = "abcd1234"
@api_dev_mode = false
Vero::App.init do |c|
@@ -38,9 +38,10 @@
end
end
- it 'should return a properly formatted javascript snippet' do
- result = ""
- expect(subject.vero_javascript_tag).to eq(result)
+ it "should return a properly formatted javascript snippet" do
+ expect(subject.vero_javascript_tag).to eq(<<~HTML.strip)
+
+ HTML
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2032ac7..8f7af65 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'rubygems'
-require 'bundler/setup'
-require 'vero'
-require 'json'
+require "rubygems"
+require "bundler/setup"
+require "vero"
+require "json"
-Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each { |f| require f }
+Dir[File.expand_path("support/**/*.rb", __dir__)].sort.each { |f| require f }
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
@@ -17,8 +17,8 @@
def stub_env(new_env, &block)
original_env = Rails.env
- Rails.instance_variable_set('@_env', ActiveSupport::StringInquirer.new(new_env))
+ Rails.instance_variable_set(:@_env, ActiveSupport::StringInquirer.new(new_env))
block.call
ensure
- Rails.instance_variable_set('@_env', ActiveSupport::StringInquirer.new(original_env))
+ Rails.instance_variable_set(:@_env, ActiveSupport::StringInquirer.new(original_env))
end
diff --git a/spec/support/base_config_shared_examples.rb b/spec/support/base_config_shared_examples.rb
index 2a9709e..df630cc 100644
--- a/spec/support/base_config_shared_examples.rb
+++ b/spec/support/base_config_shared_examples.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-RSpec.shared_examples 'a Vero wrapper' do
- it 'should inherit from Vero::Api::Workers::BaseCaller' do
+RSpec.shared_examples "a Vero wrapper" do
+ it "should inherit from Vero::Api::Workers::BaseCaller" do
expect(subject).to be_a(Vero::Api::Workers::BaseAPI)
end
- it 'should map to current version of Vero API' do
+ it "should map to current version of Vero API" do
expect(subject.send(:url)).to eq("https://api.getvero.com#{end_point}")
end
end
diff --git a/spec/support/user_support.rb b/spec/support/user_support.rb
index 337a4b9..72bb951 100644
--- a/spec/support/user_support.rb
+++ b/spec/support/user_support.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'vero'
+require "vero"
class User
include Vero::Trackable
trackable :email, :age
def email
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
def age
@@ -24,7 +24,7 @@ def email
end
def primary_contact
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
def age
@@ -37,7 +37,7 @@ class UserWithEmailAddress
trackable :email_address, :age
def email_address
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
def age
@@ -50,7 +50,7 @@ class UserWithoutInterface
trackable :email_address, :age
def email_address
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
def age
@@ -67,7 +67,7 @@ class UserWithNilAttributes
trackable :email_address, :age
def email_address
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
def age
@@ -77,37 +77,37 @@ def age
class UserWithExtras
include Vero::Trackable
- trackable :email, { extras: :properties }
+ trackable :email, {extras: :properties}
attr_accessor :properties
def email
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
end
class UserWithPrivateExtras
include Vero::Trackable
- trackable :email, { extras: :properties }
+ trackable :email, {extras: :properties}
def email
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
private
def properties
- { age: 26 }
+ {age: 26}
end
end
class UserWithOnlyExtras
include Vero::Trackable
- trackable({ extras: :properties })
+ trackable({extras: :properties})
attr_accessor :properties
def email
- 'durkster@gmail.com'
+ "durkster@gmail.com"
end
end
diff --git a/vero.gemspec b/vero.gemspec
index 69f1dc8..ef69d20 100644
--- a/vero.gemspec
+++ b/vero.gemspec
@@ -1,25 +1,25 @@
# frozen_string_literal: true
-$LOAD_PATH.push('lib')
-require 'vero/version'
+$LOAD_PATH.push("lib")
+require "vero/version"
Gem::Specification.new do |spec|
- spec.name = 'vero'
- spec.version = Vero::VERSION.dup
- spec.authors = ['James Lamont']
- spec.email = ['support@getvero.com']
+ spec.name = "vero"
+ spec.version = Vero::VERSION.dup
+ spec.authors = ["James Lamont"]
+ spec.email = ["support@getvero.com"]
- spec.summary = 'Ruby gem for Vero'
- spec.description = 'Ruby gem for Vero'
- spec.homepage = 'http://www.getvero.com/'
- spec.metadata['rubygems_mfa_required'] = 'true'
+ spec.summary = "Ruby gem for Vero"
+ spec.description = "Ruby gem for Vero"
+ spec.homepage = "http://www.getvero.com/"
+ spec.metadata["rubygems_mfa_required"] = "true"
- spec.files = Dir['**/*']
- spec.executables = Dir['bin/*'].map { |f| File.basename(f) }
- spec.require_paths = ['lib']
+ spec.files = Dir["**/*"]
+ spec.executables = Dir["bin/*"].map { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
- spec.required_ruby_version = '>= 2.7'
+ spec.required_ruby_version = ">= 2.7"
- spec.add_dependency 'json'
- spec.add_dependency 'rest-client'
+ spec.add_dependency "json"
+ spec.add_dependency "rest-client"
end