redirector 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad42ef21589444516bcf0d1b6d381d2c1db2e560
4
- data.tar.gz: 127e4f057f0d017d22dde3aaab39cf5fd574870b
3
+ metadata.gz: 63dab49a33d2664b3722c5240d71328cd50ec1ba
4
+ data.tar.gz: 7baceb65e027c70c8db19a9b62d8e598a3c27e32
5
5
  SHA512:
6
- metadata.gz: 3b48d0cb2e7fe015b01d3e4fd8932ad56c72c5e91bd759f5baa4aa956476f1b92caecd595f19fe8dbe1575e5c76c30ac926a8f41a5b2507a004ba72d42fcfbf8
7
- data.tar.gz: d0ce4195ebbd8ffaa7859fa52518094d82a0858e523f8a8115a6015d79382e9b40c80adfe5f60aba5cd679bf74e696e461db2866d0fdf07249dbcd57b2e0fd40
6
+ metadata.gz: 209ce7d1b98f706a3e44dd6262c732545b36b8e62fdde2e5261a0292b36105f71ee8d5fbc7f43d66ce7c8c1cac2a582ad82b7c97a26172492d1866531f2fdffe
7
+ data.tar.gz: 26d3ca13b233ea6e2882c6e2aaf5750cc1402d31cd74343cabe6dffb3d5a10e2a428340a46edf51eae594876038951f42beb2978fdad4353d6da0fca91e1e91f
@@ -1,4 +1,4 @@
1
- class CreateRedirectRules < ActiveRecord::Migration
1
+ class CreateRedirectRules < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :redirect_rules do |t|
4
4
  t.string :source, :null => false
@@ -13,4 +13,4 @@ class CreateRedirectRules < ActiveRecord::Migration
13
13
  add_index :redirect_rules, :source_is_regex
14
14
  add_index :redirect_rules, :source_is_case_sensitive
15
15
  end
16
- end
16
+ end
@@ -1,4 +1,4 @@
1
- class CreateRequestEnvironmentRules < ActiveRecord::Migration
1
+ class CreateRequestEnvironmentRules < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :request_environment_rules do |t|
4
4
  t.integer :redirect_rule_id, :null => false
@@ -10,4 +10,4 @@ class CreateRequestEnvironmentRules < ActiveRecord::Migration
10
10
  end
11
11
  add_index :request_environment_rules, :redirect_rule_id
12
12
  end
13
- end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Redirector
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -22,11 +22,11 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_development_dependency "mysql2"
24
24
  s.add_development_dependency "pg"
25
- s.add_development_dependency 'rspec-rails', '~> 2.14.2'
25
+ s.add_development_dependency 'rspec-rails', '~> 3.7'
26
26
  s.add_development_dependency 'shoulda-matchers'
27
27
  s.add_development_dependency 'capybara', '~> 2.2'
28
28
  s.add_development_dependency 'database_cleaner'
29
- s.add_development_dependency 'factory_girl_rails', '~> 4.4'
29
+ s.add_development_dependency 'factory_bot_rails', '~> 4.4'
30
30
  s.add_development_dependency 'appraisal'
31
31
  s.add_development_dependency 'rake'
32
32
  s.add_development_dependency 'coveralls'
@@ -50,10 +50,10 @@ module Dummy
50
50
  # config.active_record.whitelist_attributes = true
51
51
 
52
52
  # Enable the asset pipeline
53
- config.assets.enabled = true
53
+ # config.assets.enabled = true
54
54
 
55
55
  # Version of your assets, change this if you want to expire all your assets
56
- config.assets.version = '1.0'
56
+ # config.assets.version = '1.0'
57
57
  end
58
58
  end
59
59
 
@@ -1,12 +1,12 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
1
+ # Read about factories at https://github.com/thoughtbot/factory_bot
2
2
 
3
- FactoryGirl.define do
3
+ FactoryBot.define do
4
4
  factory :redirect_rule do
5
5
  active true
6
6
  source_is_regex false
7
7
  source '/catchy_thingy'
8
8
  destination 'http://www.example.com/products/1'
9
-
9
+
10
10
  factory :redirect_rule_regex do
11
11
  source_is_regex true
12
12
  source '[A-Za-z0-9_]+shiny\/([A-Za-z0-9_]+)'
@@ -1,11 +1,11 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
1
+ # Read about factories at https://github.com/thoughtbot/factory_bot
2
2
 
3
- FactoryGirl.define do
3
+ FactoryBot.define do
4
4
  factory :request_environment_rule do
5
5
  redirect_rule
6
6
  environment_key_name "SERVER_NAME"
7
7
  environment_value "example.com"
8
-
8
+
9
9
  factory :request_environment_rule_regex do
10
10
  environment_key_name "QUERY_STRING"
11
11
  environment_value "something=value"
@@ -9,24 +9,24 @@ describe 'Redirector middleware', :type => :feature do
9
9
 
10
10
  it 'correctly redirects the visitor for an exact match rule' do
11
11
  visit '/my_custom_url'
12
- current_path.should == '/news/5'
12
+ expect(current_path).to eq('/news/5')
13
13
  end
14
14
 
15
15
  it 'correctly redirects the visitor for a regex match rule' do
16
16
  visit '/my_custom_url/20'
17
- current_path.should == '/news/20'
17
+ expect(current_path).to eq('/news/20')
18
18
  end
19
19
 
20
20
  it 'should not do the query string match if the Redirector.include_query_in_source is false' do
21
21
  visit '/my_old_url?categoryID=12345'
22
- current_path.should == '/my_old_url'
22
+ expect(current_path).to eq('/my_old_url')
23
23
  end
24
24
 
25
25
  it 'should do the query string match if the Redirector.include_query_in_source is true' do
26
26
  original_option = Redirector.include_query_in_source
27
27
  Redirector.include_query_in_source = true
28
28
  visit '/my_old_url?categoryID=12345'
29
- current_path.should == '/news'
29
+ expect(current_path).to eq('/news')
30
30
  Redirector.include_query_in_source = original_option
31
31
  end
32
32
 
@@ -35,8 +35,8 @@ describe 'Redirector middleware', :type => :feature do
35
35
  Redirector.preserve_query = true
36
36
  visit '/my_custom_url/20?categoryID=43257'
37
37
  uri = URI.parse(current_url)
38
- uri.query.should == 'categoryID=43257'
39
- current_path.should == '/news/20'
38
+ expect(uri.query).to eq('categoryID=43257')
39
+ expect(current_path).to eq('/news/20')
40
40
  Redirector.preserve_query = original_option
41
41
  end
42
42
 
@@ -44,7 +44,7 @@ describe 'Redirector middleware', :type => :feature do
44
44
  original_option = Redirector.silence_sql_logs
45
45
  Redirector.silence_sql_logs = true
46
46
  visit '/my_custom_url/20'
47
- current_path.should == '/news/20'
47
+ expect(current_path).to eq('/news/20')
48
48
  Redirector.preserve_query = original_option
49
49
  end
50
50
 
@@ -52,12 +52,12 @@ describe 'Redirector middleware', :type => :feature do
52
52
  Capybara.app_host = 'http://example.com'
53
53
 
54
54
  visit '/my_custom_url'
55
- current_url.should == 'http://example.com/news/5'
55
+ expect(current_url).to eq('http://example.com/news/5')
56
56
 
57
57
  Capybara.app_host = 'http://example.com:3000'
58
58
 
59
59
  visit '/my_custom_url'
60
- current_url.should == 'http://example.com:3000/news/5'
60
+ expect(current_url).to eq('http://example.com:3000/news/5')
61
61
  end
62
62
 
63
63
  it 'foregoes search if ignored path pattern is detected' do
@@ -65,19 +65,22 @@ describe 'Redirector middleware', :type => :feature do
65
65
  Redirector.ignored_patterns = [/^\/my_custom_url\/.+/]
66
66
 
67
67
  visit '/my_custom_url/20'
68
- current_path.should == '/my_custom_url/20'
68
+ expect(current_path).to eq('/my_custom_url/20')
69
69
 
70
70
  Redirector.ignored_patterns = original_option
71
71
  end
72
72
 
73
73
  unless Rails.version =~ /\A4\.2\.\d\z/
74
74
  it 'handles invalid URIs properly' do
75
- bad_rule = create(:redirect_rule_regex, :destination => 'http://www.example.com$1', :source => '^/custom(.*)$')
75
+ bad_rule = create(:redirect_rule_regex,
76
+ :destination => 'http://www.example.com/invalid)e2',
77
+ :source => '^/custom(.*)$',
78
+ )
76
79
 
77
80
  begin
78
- visit '/custom)e2'
81
+ visit '/custome2'
79
82
  rescue Redirector::RuleError => e
80
- e.message.should == "RedirectRule #{bad_rule.id} generated the bad destination: http://www.example.com)e2"
83
+ expect(e.message).to eq("RedirectRule #{bad_rule.id} generated the bad destination: http://www.example.com)e2")
81
84
  end
82
85
  end
83
86
  end
@@ -4,61 +4,66 @@ describe RedirectRule do
4
4
  subject { create(:redirect_rule) }
5
5
  let!(:rule) { subject }
6
6
 
7
- it { should have_many(:request_environment_rules) }
7
+ it { is_expected.to have_many(:request_environment_rules) }
8
8
 
9
- it { should accept_nested_attributes_for(:request_environment_rules) }
9
+ it { is_expected.to accept_nested_attributes_for(:request_environment_rules) }
10
10
 
11
- it { should validate_presence_of(:source) }
12
- it { should validate_presence_of(:destination) }
11
+ it { is_expected.to validate_presence_of(:source) }
12
+ it { is_expected.to validate_presence_of(:destination) }
13
13
 
14
- it { should allow_value('0').for(:active) }
15
- it { should allow_value('1').for(:active) }
16
- it { should allow_value(true).for(:active) }
17
- it { should allow_value(false).for(:active) }
14
+ it { is_expected.to allow_value('0').for(:active) }
15
+ it { is_expected.to allow_value('1').for(:active) }
16
+ it { is_expected.to allow_value(true).for(:active) }
17
+ it { is_expected.to allow_value(false).for(:active) }
18
18
 
19
- it { should allow_value('0').for(:source_is_regex) }
20
- it { should allow_value('1').for(:source_is_regex) }
21
- it { should allow_value(true).for(:source_is_regex) }
22
- it { should allow_value(false).for(:source_is_regex) }
19
+ it { is_expected.to allow_value('0').for(:source_is_regex) }
20
+ it { is_expected.to allow_value('1').for(:source_is_regex) }
21
+ it { is_expected.to allow_value(true).for(:source_is_regex) }
22
+ it { is_expected.to allow_value(false).for(:source_is_regex) }
23
23
 
24
- it { should allow_value('0').for(:source_is_case_sensitive) }
25
- it { should allow_value('1').for(:source_is_case_sensitive) }
26
- it { should allow_value(true).for(:source_is_case_sensitive) }
27
- it { should allow_value(false).for(:source_is_case_sensitive) }
24
+ it { is_expected.to allow_value('0').for(:source_is_case_sensitive) }
25
+ it { is_expected.to allow_value('1').for(:source_is_case_sensitive) }
26
+ it { is_expected.to allow_value(true).for(:source_is_case_sensitive) }
27
+ it { is_expected.to allow_value(false).for(:source_is_case_sensitive) }
28
28
 
29
29
  it 'should not allow an invalid regex' do
30
- new_rule = RedirectRule.new(:source => '[', :source_is_regex => true,
31
- :destination => 'http://www.example.com', :active => true)
32
- new_rule.errors_on(:source).should == ['is an invalid regular expression']
30
+ new_rule = RedirectRule.new(
31
+ :source => '[',
32
+ :source_is_regex => true,
33
+ :destination => 'http://www.example.com',
34
+ :active => true
35
+ )
36
+ new_rule.validate
37
+ expect(new_rule.errors[:source]).to eq(['is an invalid regular expression'])
33
38
  end
34
39
 
35
40
  describe 'strip_source_whitespace before_save callback' do
36
41
  it 'strips leading and trailing whitespace when saved' do
37
- subject = FactoryGirl.build(:redirect_rule, :source => ' /needs-stripping ')
42
+ subject = FactoryBot.build(:redirect_rule, :source => ' /needs-stripping ')
38
43
 
39
44
  subject.save
40
- subject.reload.source.should == '/needs-stripping'
45
+ expect(subject.reload.source).to eq('/needs-stripping')
41
46
  end
42
47
  end
43
48
 
44
49
  describe '.match_for' do
45
50
  it 'returns nil if there is no matching rule' do
46
- RedirectRule.match_for('/someplace', {}).should be_nil
51
+ expect(RedirectRule.match_for('/someplace', {})).to be_nil
47
52
  end
48
53
 
49
54
  it 'returns the rule if there is a matching rule' do
50
- RedirectRule.match_for('/catchy_thingy', {}).should == subject
55
+ expect(RedirectRule.match_for('/catchy_thingy', {})).to eq(subject)
51
56
  end
52
57
 
53
58
  context 'for a case sensitive match' do
54
59
  let!(:case_sensitive_rule) { create(:redirect_rule, :source_is_case_sensitive => true, :source => '/Case-Does-Matter') }
55
60
 
56
61
  it 'returns the rule if it matches the case' do
57
- RedirectRule.match_for('/Case-Does-Matter', {}).should == case_sensitive_rule
62
+ expect(RedirectRule.match_for('/Case-Does-Matter', {})).to eq(case_sensitive_rule)
58
63
  end
59
64
 
60
65
  it 'returns nil if it does not match the case' do
61
- RedirectRule.match_for('/case-does-matter', {}).should be_nil
66
+ expect(RedirectRule.match_for('/case-does-matter', {})).to be_nil
62
67
  end
63
68
  end
64
69
 
@@ -66,11 +71,11 @@ describe RedirectRule do
66
71
  let!(:case_insensitive_rule) { create(:redirect_rule, :source_is_case_sensitive => false, :source => '/Case-Does-Not-Matter') }
67
72
 
68
73
  it 'returns the rule if it matches the case' do
69
- RedirectRule.match_for('/Case-Does-Not-Matter', {}).should == case_insensitive_rule
74
+ expect(RedirectRule.match_for('/Case-Does-Not-Matter', {})).to eq(case_insensitive_rule)
70
75
  end
71
76
 
72
77
  it 'returns the rule if it does not match the case' do
73
- RedirectRule.match_for('/case-does-not-matter', {}).should == case_insensitive_rule
78
+ expect(RedirectRule.match_for('/case-does-not-matter', {})).to eq(case_insensitive_rule)
74
79
  end
75
80
  end
76
81
 
@@ -78,11 +83,11 @@ describe RedirectRule do
78
83
  let!(:regex_rule){ create(:redirect_rule_regex, :source_is_case_sensitive => true) }
79
84
 
80
85
  it 'returns the rule if it matches the case' do
81
- RedirectRule.match_for('/new_shiny/from_company', {}).should == regex_rule
86
+ expect(RedirectRule.match_for('/new_shiny/from_company', {})).to eq(regex_rule)
82
87
  end
83
88
 
84
89
  it 'returns nil if it does not match the case' do
85
- RedirectRule.match_for('/new_SHINY/from_company', {}).should be_nil
90
+ expect(RedirectRule.match_for('/new_SHINY/from_company', {})).to be_nil
86
91
  end
87
92
  end
88
93
 
@@ -90,11 +95,11 @@ describe RedirectRule do
90
95
  let!(:regex_rule){ create(:redirect_rule_regex) }
91
96
 
92
97
  it 'returns the rule if it matches the case' do
93
- RedirectRule.match_for('/new_shiny/from_company', {}).should == regex_rule
98
+ expect(RedirectRule.match_for('/new_shiny/from_company', {})).to eq(regex_rule)
94
99
  end
95
100
 
96
101
  it 'returns the rule if it does not match the case' do
97
- RedirectRule.match_for('/new_SHINY/from_company', {}).should == regex_rule
102
+ expect(RedirectRule.match_for('/new_SHINY/from_company', {})).to eq(regex_rule)
98
103
  end
99
104
  end
100
105
 
@@ -104,11 +109,11 @@ describe RedirectRule do
104
109
  end
105
110
 
106
111
  it 'should find the rule if it matches' do
107
- RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com'}).should == subject
112
+ expect(RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com'})).to eq(subject)
108
113
  end
109
114
 
110
115
  it 'should not find the rule if there is no match' do
111
- RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.ca'}).should be_nil
116
+ expect(RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.ca'})).to be_nil
112
117
  end
113
118
  end
114
119
 
@@ -119,13 +124,13 @@ describe RedirectRule do
119
124
  end
120
125
 
121
126
  it 'should find the rule if it matches' do
122
- RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
123
- 'QUERY_STRING' => 's=bogus&something=value'}).should == subject
127
+ expect(RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
128
+ 'QUERY_STRING' => 's=bogus&something=value'})).to eq(subject)
124
129
  end
125
130
 
126
131
  it 'should not find the rule if there is no match' do
127
- RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
128
- "QUERY_STRING" => 's=bogus&something=wrong'}).should be_nil
132
+ expect(RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
133
+ "QUERY_STRING" => 's=bogus&something=wrong'})).to be_nil
129
134
  end
130
135
  end
131
136
 
@@ -140,18 +145,18 @@ describe RedirectRule do
140
145
  end
141
146
 
142
147
  it 'should find the rule if it matches' do
143
- RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
144
- 'QUERY_STRING' => 's=bogus&something=value'}).should == subject
148
+ expect(RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
149
+ 'QUERY_STRING' => 's=bogus&something=value'})).to eq(subject)
145
150
  end
146
151
 
147
152
  it 'should find the other rule if it matches' do
148
- RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
149
- 'QUERY_STRING' => 's=bogus&another=value'}).should == rule2
153
+ expect(RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
154
+ 'QUERY_STRING' => 's=bogus&another=value'})).to eq(rule2)
150
155
  end
151
156
 
152
157
  it 'should not find the rule if there is no match' do
153
- RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
154
- "QUERY_STRING" => 's=bogus&something=wrong'}).should be_nil
158
+ expect(RedirectRule.match_for('/catchy_thingy', {'SERVER_NAME' => 'example.com',
159
+ "QUERY_STRING" => 's=bogus&something=wrong'})).to be_nil
155
160
  end
156
161
  end
157
162
 
@@ -159,7 +164,7 @@ describe RedirectRule do
159
164
  let!(:regex_rule){ create(:redirect_rule_regex, :source => '[A-Za-z0-9]_thingy') }
160
165
 
161
166
  it 'should return the exact match' do
162
- RedirectRule.match_for('/catchy_thingy', {}).should == subject
167
+ expect(RedirectRule.match_for('/catchy_thingy', {})).to eq(subject)
163
168
  end
164
169
  end
165
170
  end
@@ -168,15 +173,15 @@ describe RedirectRule do
168
173
  let!(:regex_rule) { create(:redirect_rule_regex) }
169
174
 
170
175
  it 'should find a regex match' do
171
- RedirectRule.destination_for('/new_shiny/from_company', {}).should == 'http://www.example.com/news/from_company'
176
+ expect(RedirectRule.destination_for('/new_shiny/from_company', {})).to eq('http://www.example.com/news/from_company')
172
177
  end
173
178
 
174
179
  it 'should find a string match' do
175
- RedirectRule.destination_for('/catchy_thingy', {}).should == 'http://www.example.com/products/1'
180
+ expect(RedirectRule.destination_for('/catchy_thingy', {})).to eq('http://www.example.com/products/1')
176
181
  end
177
182
 
178
183
  it 'should return nil if there is no matching rule' do
179
- RedirectRule.destination_for('/someplace', {}).should be_nil
184
+ expect(RedirectRule.destination_for('/someplace', {})).to be_nil
180
185
  end
181
186
  end
182
187
 
@@ -184,11 +189,11 @@ describe RedirectRule do
184
189
  let(:regex_rule) { create(:redirect_rule_regex) }
185
190
 
186
191
  it 'returns the destination for a non regex rule' do
187
- subject.evaluated_destination_for('/catchy_thingy').should == 'http://www.example.com/products/1'
192
+ expect(subject.evaluated_destination_for('/catchy_thingy')).to eq('http://www.example.com/products/1')
188
193
  end
189
194
 
190
195
  it 'returns the evaluated destination for a regex rule' do
191
- regex_rule.evaluated_destination_for('/new_shiny/from_company').should == 'http://www.example.com/news/from_company'
196
+ expect(regex_rule.evaluated_destination_for('/new_shiny/from_company')).to eq('http://www.example.com/news/from_company')
192
197
  end
193
198
  end
194
199
  end
@@ -3,43 +3,44 @@ require 'spec_helper'
3
3
  describe RequestEnvironmentRule do
4
4
  subject { create(:request_environment_rule) }
5
5
 
6
- it { should belong_to(:redirect_rule) }
6
+ it { is_expected.to belong_to(:redirect_rule) }
7
7
 
8
- it { should validate_presence_of(:redirect_rule) }
9
- it { should validate_presence_of(:environment_key_name) }
10
- it { should validate_presence_of(:environment_value) }
8
+ it { is_expected.to validate_presence_of(:redirect_rule) }
9
+ it { is_expected.to validate_presence_of(:environment_key_name) }
10
+ it { is_expected.to validate_presence_of(:environment_value) }
11
11
 
12
- it { should allow_value('0').for(:environment_value_is_regex) }
13
- it { should allow_value('1').for(:environment_value_is_regex) }
14
- it { should allow_value(true).for(:environment_value_is_regex) }
15
- it { should allow_value(false).for(:environment_value_is_regex) }
12
+ it { is_expected.to allow_value('0').for(:environment_value_is_regex) }
13
+ it { is_expected.to allow_value('1').for(:environment_value_is_regex) }
14
+ it { is_expected.to allow_value(true).for(:environment_value_is_regex) }
15
+ it { is_expected.to allow_value(false).for(:environment_value_is_regex) }
16
16
 
17
- it { should allow_value('0').for(:environment_value_is_case_sensitive) }
18
- it { should allow_value('1').for(:environment_value_is_case_sensitive) }
19
- it { should allow_value(true).for(:environment_value_is_case_sensitive) }
20
- it { should allow_value(false).for(:environment_value_is_case_sensitive) }
17
+ it { is_expected.to allow_value('0').for(:environment_value_is_case_sensitive) }
18
+ it { is_expected.to allow_value('1').for(:environment_value_is_case_sensitive) }
19
+ it { is_expected.to allow_value(true).for(:environment_value_is_case_sensitive) }
20
+ it { is_expected.to allow_value(false).for(:environment_value_is_case_sensitive) }
21
21
 
22
22
  it 'should not allow an invalid regex' do
23
23
  rule = build(:request_environment_rule_regex, :environment_value => '[')
24
- rule.errors_on(:environment_value).should == ['is an invalid regular expression']
24
+ rule.validate
25
+ expect(rule.errors[:environment_value]).to eq(['is an invalid regular expression'])
25
26
  end
26
27
 
27
28
  it "should know if it's matched for a non-regex value" do
28
- subject.matches?({'SERVER_NAME' => 'example.com'}).should be_true
29
- subject.matches?({'HTTP_HOST' => 'www.example.com'}).should be_false
30
- subject.matches?({'SERVER_NAME' => 'example.ca'}).should be_false
29
+ expect(subject.matches?({'SERVER_NAME' => 'example.com'})).to be_truthy
30
+ expect(subject.matches?({'HTTP_HOST' => 'www.example.com'})).to be_falsey
31
+ expect(subject.matches?({'SERVER_NAME' => 'example.ca'})).to be_falsey
31
32
  end
32
33
 
33
34
  context 'with a case sensitive regex value' do
34
35
  subject { create(:request_environment_rule_regex) }
35
36
 
36
37
  it "should know if it's matched" do
37
- subject.matches?({'QUERY_STRING' => 'something=value'}).should be_true
38
- subject.matches?({'QUERY_STRING' => 'q=search&something=value'}).should be_true
39
- subject.matches?({'QUERY_STRING' => 'q=search&something=VALUE'}).should be_false
40
- subject.matches?({'QUERY_STRING' => 'q=search&something=bogus'}).should be_false
41
- subject.matches?({'QUERY_STRING' => 'q=search'}).should be_false
42
- subject.matches?({'SERVER_NAME' => 'example.ca'}).should be_false
38
+ expect(subject.matches?({'QUERY_STRING' => 'something=value'})).to be_truthy
39
+ expect(subject.matches?({'QUERY_STRING' => 'q=search&something=value'})).to be_truthy
40
+ expect(subject.matches?({'QUERY_STRING' => 'q=search&something=VALUE'})).to be_falsey
41
+ expect(subject.matches?({'QUERY_STRING' => 'q=search&something=bogus'})).to be_falsey
42
+ expect(subject.matches?({'QUERY_STRING' => 'q=search'})).to be_falsey
43
+ expect(subject.matches?({'SERVER_NAME' => 'example.ca'})).to be_falsey
43
44
  end
44
45
  end
45
46
 
@@ -47,12 +48,12 @@ describe RequestEnvironmentRule do
47
48
  subject { create(:request_environment_rule_regex, :environment_value_is_case_sensitive => false) }
48
49
 
49
50
  it "should know if it's matched" do
50
- subject.matches?({'QUERY_STRING' => 'something=value'}).should be_true
51
- subject.matches?({'QUERY_STRING' => 'q=search&something=value'}).should be_true
52
- subject.matches?({'QUERY_STRING' => 'q=search&something=VALUE'}).should be_true
53
- subject.matches?({'QUERY_STRING' => 'q=search&something=bogus'}).should be_false
54
- subject.matches?({'QUERY_STRING' => 'q=search'}).should be_false
55
- subject.matches?({'SERVER_NAME' => 'example.ca'}).should be_false
51
+ expect(subject.matches?({'QUERY_STRING' => 'something=value'})).to be_truthy
52
+ expect(subject.matches?({'QUERY_STRING' => 'q=search&something=value'})).to be_truthy
53
+ expect(subject.matches?({'QUERY_STRING' => 'q=search&something=VALUE'})).to be_truthy
54
+ expect(subject.matches?({'QUERY_STRING' => 'q=search&something=bogus'})).to be_falsey
55
+ expect(subject.matches?({'QUERY_STRING' => 'q=search'})).to be_falsey
56
+ expect(subject.matches?({'SERVER_NAME' => 'example.ca'})).to be_falsey
56
57
  end
57
58
  end
58
59
  end
@@ -6,19 +6,19 @@ Coveralls.wear! 'rails'
6
6
 
7
7
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
8
8
  require 'rspec/rails'
9
- require 'rspec/autorun'
10
9
  require 'shoulda-matchers'
11
10
  require 'capybara/rails'
12
11
  require 'capybara/rspec'
13
12
  require 'database_cleaner'
14
- require 'factory_girl_rails'
13
+ require 'factory_bot_rails'
14
+ require 'pry'
15
15
 
16
16
  Rails.backtrace_cleaner.remove_silencers!
17
17
 
18
18
  DatabaseCleaner.strategy = :truncation
19
19
 
20
20
  RSpec.configure do |config|
21
- config.include FactoryGirl::Syntax::Methods
21
+ config.include FactoryBot::Syntax::Methods
22
22
 
23
23
  config.mock_with :rspec
24
24
  config.use_transactional_fixtures = true
@@ -29,4 +29,22 @@ RSpec.configure do |config|
29
29
  Capybara.reset_sessions! # Forget the (simulated) browser state
30
30
  Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
31
31
  end
32
+
33
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
34
+ # from the file location. You can explicitly opt-in to the feature using this
35
+ # config option.
36
+ # To explicitly tag specs without using automatic inference, set the `:type`
37
+ # metadata manually:
38
+ #
39
+ # describe ThingsController, :type => :controller do
40
+ # # Equivalent to being in spec/controllers
41
+ # end
42
+ config.infer_spec_type_from_file_location!
43
+ end
44
+
45
+ Shoulda::Matchers.configure do |config|
46
+ config.integrate do |with|
47
+ with.test_framework :rspec
48
+ with.library :rails
49
+ end
32
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Landau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-13 00:00:00.000000000 Z
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.14.2
61
+ version: '3.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.14.2
68
+ version: '3.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shoulda-matchers
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: factory_girl_rails
112
+ name: factory_bot_rails
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"