protocool 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/protocool.rb +4 -3
- data/lib/protocool/version.rb +2 -2
- data/spec/lib/protocool_spec.rb +66 -22
- metadata +2 -2
data/lib/protocool.rb
CHANGED
@@ -13,8 +13,9 @@ module Protocool
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def use_ssl?
|
16
|
-
#
|
17
|
-
|
18
|
-
|
16
|
+
# Let the Rails config decide
|
17
|
+
return true if Rails.application.config.force_ssl
|
18
|
+
# Otherwise use default
|
19
|
+
!Rails.env.development? && !Rails.env.test?
|
19
20
|
end
|
20
21
|
end
|
data/lib/protocool/version.rb
CHANGED
data/spec/lib/protocool_spec.rb
CHANGED
@@ -2,40 +2,84 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Protocool do
|
4
4
|
|
5
|
-
let(:
|
6
|
-
let(:another_env) { mock(:environment, development?: false) }
|
7
|
-
let(:protocool) { Protocool }
|
5
|
+
let(:protocool) { Protocool }
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
context 'if force_ssl is set' do
|
8
|
+
before do
|
9
|
+
Rails.stub_chain(:application, :config, :force_ssl).and_return true
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
describe '.https' do
|
13
|
+
it 'uses TLS' do
|
14
|
+
protocool.https.should == 'https'
|
15
|
+
end
|
16
16
|
end
|
17
|
-
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
describe '.protocol' do
|
19
|
+
it 'uses TLS' do
|
20
|
+
protocool.protocol.should == 'https://'
|
21
|
+
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
context '
|
26
|
-
before
|
25
|
+
context 'if force_ssl is not set' do
|
26
|
+
before do
|
27
|
+
Rails.stub_chain(:application, :config, :force_ssl).and_return false
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
context 'in development mode' do
|
31
|
+
before do
|
32
|
+
Rails.stub!(:env).and_return mock(:environment, development?: true)
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.https' do
|
36
|
+
it 'does not use TLS' do
|
37
|
+
protocool.https.should == 'http'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '.protocol' do
|
42
|
+
it 'does not use TLS' do
|
43
|
+
protocool.protocol.should == 'http://'
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
33
47
|
|
34
|
-
|
35
|
-
|
36
|
-
|
48
|
+
context 'in test mode' do
|
49
|
+
before do
|
50
|
+
Rails.stub!(:env).and_return mock(:environment, development?: false, test?: true)
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.https' do
|
54
|
+
it 'does not use TLS' do
|
55
|
+
protocool.https.should == 'http'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '.protocol' do
|
60
|
+
it 'does not use TLS' do
|
61
|
+
protocool.protocol.should == 'http://'
|
62
|
+
end
|
37
63
|
end
|
38
64
|
end
|
39
|
-
end
|
40
65
|
|
66
|
+
context 'in non-dev and non-test mode' do
|
67
|
+
before do
|
68
|
+
Rails.stub!(:env).and_return mock(:environment, development?: false, test?: false)
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '.https' do
|
72
|
+
it 'uses TLS' do
|
73
|
+
protocool.https.should == 'https'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '.protocol' do
|
78
|
+
it 'uses TLS' do
|
79
|
+
protocool.protocol.should == 'https://'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
41
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|