gosquared-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe PropertyConfig do
4
+
5
+ subject(:props) { described_class.new() }
6
+
7
+ describe "sort_property_fields" do
8
+ it 'sorts properties and extracts custom props' do
9
+ hash = {id:'1', email:'japple@seedfunding.com', name: 'Johnny Appleseed',
10
+ first_name: 'Johnny', last_name: 'Appleseed',
11
+ username: "Johnny Appleseed",
12
+ phone: '+4412345678',
13
+ created_at: '03/11/1982',
14
+ plan_tier: 'Professional',
15
+ monthly_mrr: 2 }
16
+ props.sort_property_fields(hash)
17
+ expect(props.gosquared_custom_properties).to eq("custom: { \n plan_tier: 'Professional',\n monthly_mrr: '2',\n }")
18
+ end
19
+
20
+ it 'sorts properties and extracts standard props' do
21
+ hash = {id:'1', email:'japple@seedfunding.com', name: 'Johnny Appleseed',
22
+ first_name: 'Johnny', last_name: 'Appleseed',
23
+ username: "Johnny Appleseed",
24
+ phone: '+4412345678',
25
+ created_at: '03/11/1982',
26
+ plan_tier: 'Professional',
27
+ monthly_mrr: 2 }
28
+ props.sort_property_fields(hash)
29
+ expect(props.gosquared_standard_properties).to eq(" { \n id: '1',\n email: 'japple@seedfunding.com',\n name: 'Johnny Appleseed',\n first_name: 'Johnny',\n last_name: 'Appleseed',\n username: 'Johnny Appleseed',\n phone: '+4412345678',\n created_at: '03/11/1982',\n ")
30
+ end
31
+ end
32
+
33
+
34
+ end
@@ -0,0 +1,117 @@
1
+ require File.expand_path("lib/gosquared-rails.rb")
2
+ require File.expand_path("lib/configuration.rb")
3
+ require File.expand_path("lib/tracker_inject/property_config.rb")
4
+ require 'bundler'
5
+
6
+ Bundler.require :default, :development
7
+
8
+ Combustion.initialize! :action_controller,
9
+ :action_view,
10
+ :active_support
11
+
12
+
13
+ require 'rspec/rails'
14
+ require File.expand_path("lib/tracker_inject/injector.rb")
15
+ # This file was generated by the `rspec --init` command. Conventionally, all
16
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
17
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
18
+ # this file to always be loaded, without a need to explicitly require it in any
19
+ # files.
20
+ #
21
+ # Given that it is always loaded, you are encouraged to keep this file as
22
+ # light-weight as possible. Requiring heavyweight dependencies from this file
23
+ # will add to the boot time of your test suite on EVERY test run, even for an
24
+ # individual file that may not need all of that loaded. Instead, consider making
25
+ # a separate helper file that requires the additional dependencies and performs
26
+ # the additional setup, and require it from the spec files that actually need
27
+ # it.
28
+ #
29
+ # The `.rspec` file also contains a few flags that are not defaults but that
30
+ # users commonly want.
31
+ #
32
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
33
+ RSpec.configure do |config|
34
+ # rspec-expectations config goes here. You can use an alternate
35
+ # assertion/expectation library such as wrong or the stdlib/minitest
36
+ # assertions if you prefer.
37
+ config.expect_with :rspec do |expectations|
38
+ # This option will default to `true` in RSpec 4. It makes the `description`
39
+ # and `failure_message` of custom matchers include text for helper methods
40
+ # defined using `chain`, e.g.:
41
+ # be_bigger_than(2).and_smaller_than(4).description
42
+ # # => "be bigger than 2 and smaller than 4"
43
+ # ...rather than:
44
+ # # => "be bigger than 2"
45
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
46
+ end
47
+
48
+ # rspec-mocks config goes here. You can use an alternate test double
49
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
50
+ config.mock_with :rspec do |mocks|
51
+ # Prevents you from mocking or stubbing a method that does not exist on
52
+ # a real object. This is generally recommended, and will default to
53
+ # `true` in RSpec 4.
54
+ mocks.verify_partial_doubles = true
55
+ end
56
+
57
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
58
+ # have no way to turn it off -- the option exists only for backwards
59
+ # compatibility in RSpec 3). It causes shared context metadata to be
60
+ # inherited by the metadata hash of host groups and examples, rather than
61
+ # triggering implicit auto-inclusion in groups with matching metadata.
62
+ config.shared_context_metadata_behavior = :apply_to_host_groups
63
+
64
+ # The settings below are suggested to provide a good initial experience
65
+ # with RSpec, but feel free to customize to your heart's content.
66
+ =begin
67
+ # This allows you to limit a spec run to individual examples or groups
68
+ # you care about by tagging them with `:focus` metadata. When nothing
69
+ # is tagged with `:focus`, all examples get run. RSpec also provides
70
+ # aliases for `it`, `describe`, and `context` that include `:focus`
71
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
72
+ config.filter_run_when_matching :focus
73
+
74
+ # Allows RSpec to persist some state between runs in order to support
75
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
76
+ # you configure your source control system to ignore this file.
77
+ config.example_status_persistence_file_path = "spec/examples.txt"
78
+
79
+ # Limits the available syntax to the non-monkey patched syntax that is
80
+ # recommended. For more details, see:
81
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
82
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
83
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
84
+ config.disable_monkey_patching!
85
+
86
+ # This setting enables warnings. It's recommended, but in some cases may
87
+ # be too noisy due to issues in dependencies.
88
+ config.warnings = true
89
+
90
+ # Many RSpec users commonly either run the entire suite or an individual
91
+ # file, and it's useful to allow more verbose output when running an
92
+ # individual spec file.
93
+ if config.files_to_run.one?
94
+ # Use the documentation formatter for detailed output,
95
+ # unless a formatter has already been configured
96
+ # (e.g. via a command-line flag).
97
+ config.default_formatter = 'doc'
98
+ end
99
+
100
+ # Print the 10 slowest examples and example groups at the
101
+ # end of the spec run, to help surface which specs are running
102
+ # particularly slow.
103
+ config.profile_examples = 10
104
+
105
+ # Run specs in random order to surface order dependencies. If you find an
106
+ # order dependency and want to debug it, you can fix the order by providing
107
+ # the seed, which is printed after each run.
108
+ # --seed 1234
109
+ config.order = :random
110
+
111
+ # Seed global randomization in this process using the `--seed` CLI option.
112
+ # Setting this allows you to use `--seed` to deterministically reproduce
113
+ # test failures related to randomization by passing the same `--seed` value
114
+ # as the one that triggered the failure.
115
+ Kernel.srand config.seed
116
+ =end
117
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require 'helpers/anonymous_controller_helper_spec.rb'
3
+
4
+ describe ApplicationController, :type => :controller do
5
+ controller do
6
+ def index
7
+ render :html => true
8
+ end
9
+
10
+ def new
11
+ render :json => true
12
+ end
13
+
14
+ end
15
+
16
+ it "Adds the GoSquared tracking code if response HTML" do
17
+ expect(controller).to receive(:add_gosquared_script)
18
+ get :index
19
+ end
20
+
21
+ it "Does not add the GoSquared tracking code if response is not HTML" do
22
+ expect(controller).not_to receive(:add_gosquared_script)
23
+ get :new
24
+ end
25
+
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gosquared-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Russell Vaughan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ GoSquared is your all-in-one software platform for marketing, sales, and support.
15
+ This Ruby gem is for quickly installing GoSquared Chat, Analytics and People CRM in your Rails App .
16
+ email:
17
+ - russellvaughan@gosquared.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".rspec"
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - lib/configuration.rb
27
+ - lib/gosquared-rails.rb
28
+ - lib/rails/generators/gosquared_rails/config/config_generator.rb
29
+ - lib/rails/generators/gosquared_rails/config/templates/gosquared_rails.rb.erb
30
+ - lib/tracker_inject/injector.rb
31
+ - lib/tracker_inject/property_config.rb
32
+ - lib/tracker_inject/railtie.rb
33
+ - spec/configuration_spec.rb
34
+ - spec/gosquared_generator_spec.rb
35
+ - spec/gosquared_spec.rb
36
+ - spec/helpers/anonymous_controller_helper_spec.rb
37
+ - spec/internal/app/config/initializers/gosquared_rails.rb
38
+ - spec/internal/app/generators/config_generator.rb
39
+ - spec/internal/app/generators/templates/gosquared_rails.rb.erb
40
+ - spec/internal/app/models/user.rb
41
+ - spec/internal/log/test.log
42
+ - spec/property_config_spec.rb
43
+ - spec/spec_helper.rb
44
+ - spec/tracker_intject_spec.rb
45
+ homepage: https://github.com/gosquared/gosquared-rails
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.6.6
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Gem for injecting and configuring the GoSquared JavaScript tracking code
69
+ and Identify method
70
+ test_files:
71
+ - spec/configuration_spec.rb
72
+ - spec/gosquared_generator_spec.rb
73
+ - spec/gosquared_spec.rb
74
+ - spec/helpers/anonymous_controller_helper_spec.rb
75
+ - spec/internal/app/config/initializers/gosquared_rails.rb
76
+ - spec/internal/app/generators/config_generator.rb
77
+ - spec/internal/app/generators/templates/gosquared_rails.rb.erb
78
+ - spec/internal/app/models/user.rb
79
+ - spec/internal/log/test.log
80
+ - spec/property_config_spec.rb
81
+ - spec/spec_helper.rb
82
+ - spec/tracker_intject_spec.rb