woopra_rails 1.1.10 → 1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/woopra_rails/api.rb +6 -19
- data/lib/woopra_rails/engine.rb +5 -2
- data/lib/woopra_rails/error.rb +18 -1
- data/lib/woopra_rails/response.rb +14 -12
- data/lib/woopra_rails/version.rb +1 -1
- data/lib/woopra_rails.rb +17 -13
- data/spec/TestApp/.rspec +1 -0
- data/spec/TestApp/Gemfile +2 -2
- data/spec/TestApp/Guardfile +24 -0
- data/spec/TestApp/app/controllers/application_controller.rb +0 -1
- data/spec/TestApp/fixtures/cassettes/failed.yml +69 -0
- data/spec/TestApp/fixtures/cassettes/success-bad-email.yml +38 -0
- data/spec/TestApp/fixtures/cassettes/success-good-arguments.yml +38 -0
- data/spec/TestApp/fixtures/cassettes/success.yml +69 -0
- data/spec/TestApp/spec/lib/api_spec.rb +55 -0
- data/spec/TestApp/spec/spec_helper.rb +42 -0
- data/spec/TestApp/spec/support/vcr.rb +8 -0
- data/spec/TestApp/spec/support/vcr_macros.rb +7 -0
- data/spec/TestApp/spec/woopra_rails_spec.rb +33 -0
- metadata +24 -6
- data/spec/lib/woopra_rails_spec.rb +0 -11
- data/spec/spec_helper.rb +0 -11
data/lib/woopra_rails/api.rb
CHANGED
@@ -1,20 +1,7 @@
|
|
1
1
|
module WoopraRails
|
2
2
|
class << self
|
3
|
-
def identify(name
|
4
|
-
|
5
|
-
URI::encode name
|
6
|
-
rescue
|
7
|
-
""
|
8
|
-
end
|
9
|
-
|
10
|
-
email = begin
|
11
|
-
URI::encode email
|
12
|
-
rescue
|
13
|
-
""
|
14
|
-
end
|
15
|
-
|
16
|
-
action = "&ce_name=identified&cv_name=#{name}&cv_email=#{email}"
|
17
|
-
::Rails.logger.debug("User info: #{name.inspect}, #{email.inspect}")
|
3
|
+
def identify(name, email, ip)
|
4
|
+
action = "&ip=#{URI::encode ip}&ce_name=identified&cv_name=#{URI::encode name}&cv_email=#{URI::encode email}"
|
18
5
|
issue_request(action)
|
19
6
|
end
|
20
7
|
|
@@ -41,6 +28,7 @@ module WoopraRails
|
|
41
28
|
""
|
42
29
|
end
|
43
30
|
action = "&cv_name=#{name}&cv_email=#{email}&ce_name=#{event_name}"
|
31
|
+
action += "&ip=#{URI::encode args.delete(:ip)}"
|
44
32
|
|
45
33
|
args.each do |k,v|
|
46
34
|
action += "&ce_#{k}=#{URI::encode v.to_s}"
|
@@ -50,11 +38,10 @@ module WoopraRails
|
|
50
38
|
end
|
51
39
|
|
52
40
|
def issue_request(action=nil)
|
53
|
-
action = action.nil? ?
|
41
|
+
action = action.nil? ? base_params : base_params + action
|
54
42
|
uri = URI.parse(action)
|
55
|
-
resp =
|
56
|
-
|
57
|
-
raise WoopraError
|
43
|
+
resp = dryrun ? nil : Net::HTTP.get(uri)
|
44
|
+
WoopraRails::Response.new.parse(resp)
|
58
45
|
end
|
59
46
|
end
|
60
47
|
end
|
data/lib/woopra_rails/engine.rb
CHANGED
@@ -2,8 +2,11 @@ module WoopraRails
|
|
2
2
|
module Rails
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
initializer "woopra_rails.load_config" do |app|
|
5
|
-
|
6
|
-
|
5
|
+
if File.exists? "#{app.root}/config/woopra.yml"
|
6
|
+
WoopraRails.config = YAML.load_file(app.root.join("config","woopra.yml"))[::Rails.env]
|
7
|
+
else
|
8
|
+
raise WoopraError, "Missing woopra.yml in Rails root config directory."
|
9
|
+
end
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
data/lib/woopra_rails/error.rb
CHANGED
@@ -1,2 +1,19 @@
|
|
1
1
|
class WoopraError < StandardError
|
2
|
-
|
2
|
+
class << self
|
3
|
+
def json_exception?(e)
|
4
|
+
e.class == JSON::ParserError
|
5
|
+
end
|
6
|
+
|
7
|
+
def account_exception?(json)
|
8
|
+
["host", "not registered!"].all?{|w| json.downcase.include? w }
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_error(e, json)
|
12
|
+
if json_exception?(e) && account_exception?(json)
|
13
|
+
raise WoopraError, "Your account is incorrect. Woopra responded that '#{WoopraRails.account}'' was not registered."
|
14
|
+
elsif json_exception?(e)
|
15
|
+
::Rails.logger.debug("JSON::ParserError in WoopraRails. Not raising, but you should check.")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,16 +1,18 @@
|
|
1
|
-
module WoopraRails
|
2
|
-
class
|
1
|
+
module WoopraRails
|
2
|
+
class Response
|
3
3
|
attr_accessor :success
|
4
|
-
def new(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
self.send("
|
12
|
-
end
|
13
|
-
|
4
|
+
def new()
|
5
|
+
success = false
|
6
|
+
end
|
7
|
+
|
8
|
+
def parse(json=nil)
|
9
|
+
begin
|
10
|
+
JSON.parse(json).each do |k,v|
|
11
|
+
self.send("#{k}=".to_sym, v)
|
12
|
+
end
|
13
|
+
rescue Exception => e
|
14
|
+
WoopraError.get_error(e, json)
|
15
|
+
send("success=", false)
|
14
16
|
end
|
15
17
|
self
|
16
18
|
end
|
data/lib/woopra_rails/version.rb
CHANGED
data/lib/woopra_rails.rb
CHANGED
@@ -12,32 +12,36 @@ require 'fileutils'
|
|
12
12
|
].each{ |f| require "woopra_rails/#{f}" }
|
13
13
|
|
14
14
|
module WoopraRails
|
15
|
-
@
|
16
|
-
@dryrun = false
|
17
|
-
@config = {}
|
18
|
-
@env = "development"
|
19
|
-
@base_params = ""
|
15
|
+
@config = {}
|
20
16
|
|
21
17
|
class << self
|
22
18
|
def config=(config)
|
23
19
|
@config = config
|
24
20
|
end
|
25
21
|
|
26
|
-
def
|
27
|
-
|
28
|
-
@env = ::Rails.env if defined? Rails
|
29
|
-
@base_params = "#{@endpoint}?host=#{account}&response=json&timeout=300000"
|
30
|
-
rescue Exception => e
|
31
|
-
puts("Error on init: #{e.message}")
|
32
|
-
end
|
22
|
+
def config
|
23
|
+
@config
|
33
24
|
end
|
34
25
|
|
35
26
|
def dryrun
|
36
|
-
|
27
|
+
@config["dryrun"]
|
37
28
|
end
|
38
29
|
|
39
30
|
def account
|
40
31
|
@config["account"]
|
41
32
|
end
|
33
|
+
|
34
|
+
def env
|
35
|
+
return ::Rails.env if defined? Rails
|
36
|
+
""
|
37
|
+
end
|
38
|
+
|
39
|
+
def endpoint
|
40
|
+
'http://www.woopra.com/track/ce/'
|
41
|
+
end
|
42
|
+
|
43
|
+
def base_params
|
44
|
+
"#{endpoint}?host=#{account}&response=json&timeout=300000"
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
data/spec/TestApp/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/TestApp/Gemfile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'rails', '3.2.12'
|
4
|
-
gem 'woopra_rails', path: "../../", require: 'woopra_rails'
|
5
4
|
gem 'sqlite3'
|
6
5
|
gem 'jquery-rails'
|
7
6
|
|
@@ -25,7 +24,8 @@ group :test do
|
|
25
24
|
gem 'simplecov', :require => false, :group => :test
|
26
25
|
end
|
27
26
|
|
28
|
-
group :test, :
|
27
|
+
group :test, :development do
|
28
|
+
gem 'woopra_rails', path: "../../", require: 'woopra_rails'
|
29
29
|
gem 'rspec-rails', '~> 2.13.0'
|
30
30
|
gem 'factory_girl_rails'
|
31
31
|
gem 'debugger'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.woopra.com/track/ce/?ce_name=identified&cv_email=me@wooprauser&cv_name=woopra%20user&host=topgun.dp.generalassemb.ly.test&response=json&timeout=300000
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Length:
|
20
|
+
- '58'
|
21
|
+
Connection:
|
22
|
+
- close
|
23
|
+
Server:
|
24
|
+
- Jetty(8.1.8.v20121106)
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '/*
|
28
|
+
|
29
|
+
Host topgun.dp.generalassemb.ly.test not registered!
|
30
|
+
|
31
|
+
*/'
|
32
|
+
http_version:
|
33
|
+
recorded_at: Tue, 07 May 2013 21:26:57 GMT
|
34
|
+
- request:
|
35
|
+
method: get
|
36
|
+
uri: http://www.woopra.com/track/ce/?ce_name=identified&cv_email=me@wooprauser&cv_name=woopra%20user&host=topgun.dp.generalassemb.ly&response=json&timeout=300000
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ''
|
40
|
+
headers:
|
41
|
+
Accept:
|
42
|
+
- ! '*/*'
|
43
|
+
User-Agent:
|
44
|
+
- Ruby
|
45
|
+
response:
|
46
|
+
status:
|
47
|
+
code: 200
|
48
|
+
message: OK
|
49
|
+
headers:
|
50
|
+
Expires:
|
51
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
52
|
+
Content-Type:
|
53
|
+
- text/javascript; charset=utf-8
|
54
|
+
Server:
|
55
|
+
- woopra-d-7.1b
|
56
|
+
Pragma:
|
57
|
+
- no-cache
|
58
|
+
Cache-Control:
|
59
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
60
|
+
Content-Length:
|
61
|
+
- '13'
|
62
|
+
Connection:
|
63
|
+
- close
|
64
|
+
body:
|
65
|
+
encoding: US-ASCII
|
66
|
+
string: ! '{"success":1}'
|
67
|
+
http_version:
|
68
|
+
recorded_at: Tue, 07 May 2013 21:58:50 GMT
|
69
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.woopra.com/track/ce/?ce_name=identified&cv_email=me@wooprauser&cv_name=woopra%20user&host=topgun.dp.generalassemb.ly&response=json&timeout=300000
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Expires:
|
20
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
21
|
+
Content-Type:
|
22
|
+
- text/javascript; charset=utf-8
|
23
|
+
Server:
|
24
|
+
- woopra-d-7.1b
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Cache-Control:
|
28
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
29
|
+
Content-Length:
|
30
|
+
- '13'
|
31
|
+
Connection:
|
32
|
+
- close
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: ! '{"success":1}'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 07 May 2013 22:01:47 GMT
|
38
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.woopra.com/track/ce/?ce_name=identified&cv_email=me@wooprauser.com&cv_name=woopra%20user&host=topgun.dp.generalassemb.ly&response=json&timeout=300000
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Expires:
|
20
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
21
|
+
Content-Type:
|
22
|
+
- text/javascript; charset=utf-8
|
23
|
+
Server:
|
24
|
+
- woopra-d-7.1b
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Cache-Control:
|
28
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
29
|
+
Content-Length:
|
30
|
+
- '13'
|
31
|
+
Connection:
|
32
|
+
- close
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: ! '{"success":1}'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 07 May 2013 22:01:47 GMT
|
38
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,69 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.woopra.com/track/ce/?ce_name=identified&cv_email=me@wooprauser.com&cv_name=woopra%20user&host=topgun.dp.generalassemb.ly.test&response=json&timeout=300000
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Length:
|
20
|
+
- '58'
|
21
|
+
Connection:
|
22
|
+
- close
|
23
|
+
Server:
|
24
|
+
- Jetty(8.1.8.v20121106)
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '/*
|
28
|
+
|
29
|
+
Host topgun.dp.generalassemb.ly.test not registered!
|
30
|
+
|
31
|
+
*/'
|
32
|
+
http_version:
|
33
|
+
recorded_at: Tue, 07 May 2013 21:25:24 GMT
|
34
|
+
- request:
|
35
|
+
method: get
|
36
|
+
uri: http://www.woopra.com/track/ce/?ce_name=identified&cv_email=me@wooprauser.com&cv_name=woopra%20user&host=topgun.dp.generalassemb.ly&response=json&timeout=300000
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ''
|
40
|
+
headers:
|
41
|
+
Accept:
|
42
|
+
- ! '*/*'
|
43
|
+
User-Agent:
|
44
|
+
- Ruby
|
45
|
+
response:
|
46
|
+
status:
|
47
|
+
code: 200
|
48
|
+
message: OK
|
49
|
+
headers:
|
50
|
+
Expires:
|
51
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
52
|
+
Content-Type:
|
53
|
+
- text/javascript; charset=utf-8
|
54
|
+
Server:
|
55
|
+
- woopra-d-7.1b
|
56
|
+
Pragma:
|
57
|
+
- no-cache
|
58
|
+
Cache-Control:
|
59
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
60
|
+
Content-Length:
|
61
|
+
- '13'
|
62
|
+
Connection:
|
63
|
+
- close
|
64
|
+
body:
|
65
|
+
encoding: US-ASCII
|
66
|
+
string: ! '{"success":1}'
|
67
|
+
http_version:
|
68
|
+
recorded_at: Tue, 07 May 2013 21:58:50 GMT
|
69
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WoopraRails do
|
4
|
+
context "expected current api methods" do
|
5
|
+
it "should have respond to 'identify'" do
|
6
|
+
WoopraRails.respond_to?(:identify).should be_true
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should respond to 'log_pageview'" do
|
10
|
+
WoopraRails.respond_to?(:log_pageview).should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should respond to 'record'" do
|
14
|
+
WoopraRails.respond_to?(:record).should be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "#identify" do
|
19
|
+
it "should raise an argument error when nothing is passed" do
|
20
|
+
expect {
|
21
|
+
WoopraRails.identify
|
22
|
+
}.to raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise an argument error with a message when not passing a name" do
|
26
|
+
expect {
|
27
|
+
WoopraRails.identify
|
28
|
+
}.to raise_error(ArgumentError, "You must identify with a name")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should raise an argument error with a message when not passing an email" do
|
32
|
+
expect {
|
33
|
+
WoopraRails.identify("woopra user")
|
34
|
+
}.to raise_error(ArgumentError, "You must identify with an email")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return a WoopraRails::Response object" do
|
38
|
+
vcr "success" do
|
39
|
+
WoopraRails.identify("woopra user", "me@wooprauser.com").class.should == WoopraRails::Response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return a successful response with valid arguments" do
|
44
|
+
vcr "success-good-arguments" do
|
45
|
+
WoopraRails.identify("woopra user", "me@wooprauser.com").success?.should be_true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return a successful response and not check validity of email" do
|
50
|
+
vcr "success-bad-email" do
|
51
|
+
WoopraRails.identify("woopra user", "me@wooprauser").success?.should be_true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
require 'vcr'
|
8
|
+
|
9
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
10
|
+
# in spec/support/ and its subdirectories.
|
11
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
# ## Mock Framework
|
15
|
+
#
|
16
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
17
|
+
#
|
18
|
+
# config.mock_with :mocha
|
19
|
+
# config.mock_with :flexmock
|
20
|
+
# config.mock_with :rr
|
21
|
+
|
22
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
23
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
24
|
+
|
25
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
26
|
+
# examples within a transaction, remove the following line or assign false
|
27
|
+
# instead of true.
|
28
|
+
config.use_transactional_fixtures = true
|
29
|
+
|
30
|
+
# If true, the base class of anonymous controllers will be inferred
|
31
|
+
# automatically. This will be the default behavior in future versions of
|
32
|
+
# rspec-rails.
|
33
|
+
config.infer_base_class_for_anonymous_controllers = false
|
34
|
+
|
35
|
+
# Run specs in random order to surface order dependencies. If you find an
|
36
|
+
# order dependency and want to debug it, you can fix the order by providing
|
37
|
+
# the seed, which is printed after each run.
|
38
|
+
# --seed 1234
|
39
|
+
config.order = "random"
|
40
|
+
end
|
41
|
+
|
42
|
+
CONFIG_YML = YAML::load_file(File.join(File.dirname(File.expand_path(__FILE__)), '../config/woopra.yml'))
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WoopraRails do
|
4
|
+
it "should define module instance var for @config" do
|
5
|
+
WoopraRails.instance_variables.include?(:@config).should be_true
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a valid environment" do
|
9
|
+
WoopraRails.env.should == Rails.env
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have an endpoint" do
|
13
|
+
WoopraRails.endpoint.should == "http://www.woopra.com/track/ce/"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have dryrun set to the value in the config file" do
|
17
|
+
WoopraRails.dryrun.should == CONFIG_YML[::Rails.env.to_s]["dryrun"]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have account set to the value in the config file" do
|
21
|
+
WoopraRails.account.should == CONFIG_YML[::Rails.env.to_s]["account"]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should respond with a valid URI for base params" do
|
25
|
+
WoopraRails.base_params.should == URI.encode(WoopraRails.base_params)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should include always necesary params in base params" do
|
29
|
+
["host","response","timeout"].each do |p|
|
30
|
+
WoopraRails.base_params.include?(p).should be_true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: woopra_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -63,7 +63,9 @@ files:
|
|
63
63
|
- lib/woopra_rails/response.rb
|
64
64
|
- lib/woopra_rails/version.rb
|
65
65
|
- spec/TestApp/.gitignore
|
66
|
+
- spec/TestApp/.rspec
|
66
67
|
- spec/TestApp/Gemfile
|
68
|
+
- spec/TestApp/Guardfile
|
67
69
|
- spec/TestApp/README.rdoc
|
68
70
|
- spec/TestApp/Rakefile
|
69
71
|
- spec/TestApp/app/assets/images/rails.png
|
@@ -93,6 +95,10 @@ files:
|
|
93
95
|
- spec/TestApp/config/routes.rb
|
94
96
|
- spec/TestApp/config/woopra.yml.example
|
95
97
|
- spec/TestApp/db/seeds.rb
|
98
|
+
- spec/TestApp/fixtures/cassettes/failed.yml
|
99
|
+
- spec/TestApp/fixtures/cassettes/success-bad-email.yml
|
100
|
+
- spec/TestApp/fixtures/cassettes/success-good-arguments.yml
|
101
|
+
- spec/TestApp/fixtures/cassettes/success.yml
|
96
102
|
- spec/TestApp/lib/assets/.gitkeep
|
97
103
|
- spec/TestApp/lib/tasks/.gitkeep
|
98
104
|
- spec/TestApp/log/.gitkeep
|
@@ -102,6 +108,11 @@ files:
|
|
102
108
|
- spec/TestApp/public/favicon.ico
|
103
109
|
- spec/TestApp/public/robots.txt
|
104
110
|
- spec/TestApp/script/rails
|
111
|
+
- spec/TestApp/spec/lib/api_spec.rb
|
112
|
+
- spec/TestApp/spec/spec_helper.rb
|
113
|
+
- spec/TestApp/spec/support/vcr.rb
|
114
|
+
- spec/TestApp/spec/support/vcr_macros.rb
|
115
|
+
- spec/TestApp/spec/woopra_rails_spec.rb
|
105
116
|
- spec/TestApp/test/fixtures/.gitkeep
|
106
117
|
- spec/TestApp/test/functional/.gitkeep
|
107
118
|
- spec/TestApp/test/integration/.gitkeep
|
@@ -111,8 +122,6 @@ files:
|
|
111
122
|
- spec/TestApp/vendor/assets/javascripts/.gitkeep
|
112
123
|
- spec/TestApp/vendor/assets/stylesheets/.gitkeep
|
113
124
|
- spec/TestApp/vendor/plugins/.gitkeep
|
114
|
-
- spec/lib/woopra_rails_spec.rb
|
115
|
-
- spec/spec_helper.rb
|
116
125
|
- woopra_rails.gemspec
|
117
126
|
homepage: http://github.com/khopkins218/woopra_rails
|
118
127
|
licenses:
|
@@ -141,7 +150,9 @@ specification_version: 3
|
|
141
150
|
summary: Server side integration of Woopra HTTP API for Ruby on Rails applications
|
142
151
|
test_files:
|
143
152
|
- spec/TestApp/.gitignore
|
153
|
+
- spec/TestApp/.rspec
|
144
154
|
- spec/TestApp/Gemfile
|
155
|
+
- spec/TestApp/Guardfile
|
145
156
|
- spec/TestApp/README.rdoc
|
146
157
|
- spec/TestApp/Rakefile
|
147
158
|
- spec/TestApp/app/assets/images/rails.png
|
@@ -171,6 +182,10 @@ test_files:
|
|
171
182
|
- spec/TestApp/config/routes.rb
|
172
183
|
- spec/TestApp/config/woopra.yml.example
|
173
184
|
- spec/TestApp/db/seeds.rb
|
185
|
+
- spec/TestApp/fixtures/cassettes/failed.yml
|
186
|
+
- spec/TestApp/fixtures/cassettes/success-bad-email.yml
|
187
|
+
- spec/TestApp/fixtures/cassettes/success-good-arguments.yml
|
188
|
+
- spec/TestApp/fixtures/cassettes/success.yml
|
174
189
|
- spec/TestApp/lib/assets/.gitkeep
|
175
190
|
- spec/TestApp/lib/tasks/.gitkeep
|
176
191
|
- spec/TestApp/log/.gitkeep
|
@@ -180,6 +195,11 @@ test_files:
|
|
180
195
|
- spec/TestApp/public/favicon.ico
|
181
196
|
- spec/TestApp/public/robots.txt
|
182
197
|
- spec/TestApp/script/rails
|
198
|
+
- spec/TestApp/spec/lib/api_spec.rb
|
199
|
+
- spec/TestApp/spec/spec_helper.rb
|
200
|
+
- spec/TestApp/spec/support/vcr.rb
|
201
|
+
- spec/TestApp/spec/support/vcr_macros.rb
|
202
|
+
- spec/TestApp/spec/woopra_rails_spec.rb
|
183
203
|
- spec/TestApp/test/fixtures/.gitkeep
|
184
204
|
- spec/TestApp/test/functional/.gitkeep
|
185
205
|
- spec/TestApp/test/integration/.gitkeep
|
@@ -189,5 +209,3 @@ test_files:
|
|
189
209
|
- spec/TestApp/vendor/assets/javascripts/.gitkeep
|
190
210
|
- spec/TestApp/vendor/assets/stylesheets/.gitkeep
|
191
211
|
- spec/TestApp/vendor/plugins/.gitkeep
|
192
|
-
- spec/lib/woopra_rails_spec.rb
|
193
|
-
- spec/spec_helper.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe WoopraRails do
|
4
|
-
context "post init" do
|
5
|
-
it "should define module instance vars" do
|
6
|
-
[:@endpoint, :@dryrun, :@config, :@env, :@base_params].each do |v|
|
7
|
-
WoopraRails.instance_variables.include?(v).should be_true
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
data/spec/spec_helper.rb
DELETED