protocool 0.0.3 → 0.1.0

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.
@@ -13,8 +13,9 @@ module Protocool
13
13
  private
14
14
 
15
15
  def use_ssl?
16
- # *Possibly* add "test environment" as an exception as well.
17
- # But staging and production must really have SSL!
18
- !Rails.env.development?
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
@@ -1,8 +1,8 @@
1
1
  module Protocool
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 0
5
- TINY = 3
4
+ MINOR = 1
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
@@ -2,40 +2,84 @@ require 'spec_helper'
2
2
 
3
3
  describe Protocool do
4
4
 
5
- let(:dev_env) { mock(:environment, development?: true) }
6
- let(:another_env) { mock(:environment, development?: false) }
7
- let(:protocool) { Protocool }
5
+ let(:protocool) { Protocool }
8
6
 
9
- before do
10
- Rails.stub!(:env).and_return another_env
11
- end
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
- describe '.https' do
14
- it 'uses HTTPS by default' do
15
- protocool.https.should == 'https'
12
+ describe '.https' do
13
+ it 'uses TLS' do
14
+ protocool.https.should == 'https'
15
+ end
16
16
  end
17
- end
18
17
 
19
- describe '.protocol' do
20
- it 'is the HTTPS protocol' do
21
- protocool.protocol.should == 'https://'
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 'in development environment' do
26
- before { Rails.stub!(:env).and_return dev_env }
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
- describe '.https' do
29
- it 'uses HTTP' do
30
- protocool.https.should == 'http'
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
- describe '.protocol' do
35
- it 'is the HTTP protocol' do
36
- protocool.protocol.should == 'http://'
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.3
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-07 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec