rewritten 0.15.2 → 0.16.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.
@@ -1,43 +1,40 @@
1
1
  require 'test_helper'
2
2
 
3
3
  describe Rewritten do
4
-
5
- before{
4
+ before do
6
5
  Rewritten.add_translation('/from', '/to')
6
+ Rewritten.add_translation('/from?w=1', '/to/w')
7
7
  Rewritten.add_translation('/from2', '/to')
8
8
  Rewritten.add_translation('/from3', '/to2')
9
9
 
10
- #with flags
10
+ # with flags
11
11
  Rewritten.add_translation('/with/flags [L12]', '/to3')
12
- }
12
+ end
13
13
 
14
14
  describe 'Rewritten.get_current_translation for to-target' do
15
-
16
- it "must give current_translation" do
15
+ it 'must give current_translation' do
17
16
  Rewritten.get_current_translation('/to').must_equal '/from2'
18
17
  Rewritten.get_current_translation('/to2').must_equal '/from3'
19
18
  Rewritten.get_current_translation('/to3').must_equal '/with/flags'
20
19
  Rewritten.get_current_translation('/n/a').must_equal '/n/a'
21
20
  end
22
21
 
23
- it "must find the translation if parameters are added" do
22
+ it 'must find the translation if parameters are added' do
24
23
  Rewritten.add_translation('/from_without_params', '/to_without_params')
25
24
  Rewritten.get_current_translation('/to_without_params?some=param').must_equal '/from_without_params?some=param'
26
25
  end
27
26
 
28
- it "must not add parameters twice if no translation is found" do
27
+ it 'must not add parameters twice if no translation is found' do
29
28
  Rewritten.get_current_translation('/no/translation?some=param').must_equal '/no/translation?some=param'
30
29
  end
31
30
 
32
- it "must translate if protocol and host are given" do
31
+ it 'must translate if protocol and host are given' do
33
32
  Rewritten.add_translation('/from_without_params', '/to_without_params')
34
33
  Rewritten.get_current_translation('http://localhost:3000/to_without_params').must_equal 'http://localhost:3000/from_without_params'
35
34
  end
36
-
37
35
  end
38
36
 
39
37
  describe 'get_infinitive (always from conjugated for -> for)' do
40
-
41
38
  it 'must work with nil' do
42
39
  Rewritten.infinitive(nil).must_equal ''
43
40
  end
@@ -55,53 +52,45 @@ describe Rewritten do
55
52
  end
56
53
 
57
54
  describe 'context translate partial' do
58
- before{ Rewritten.translate_partial = true }
59
- after{ Rewritten.translate_partial = false }
55
+ before { Rewritten.translate_partial = true }
56
+ after { Rewritten.translate_partial = false }
60
57
 
61
58
  it 'must remove trail if translpartial is enabled' do
62
59
  Rewritten.infinitive('/from/with/trail?and=param').must_equal '/from2'
63
60
  end
64
61
  end
65
-
66
62
  end
67
63
 
68
- describe "basic interface" do
69
-
70
- it "must translate froms" do
64
+ describe 'basic interface' do
65
+ it 'must translate froms' do
71
66
  Rewritten.translate('/from').must_equal '/to'
72
67
  Rewritten.translate('/from2').must_equal '/to'
73
68
  Rewritten.translate('/from3').must_equal '/to2'
74
69
  Rewritten.translate('/with/flags').must_equal '/to3'
70
+ Rewritten.translate('/from?w=1').must_equal '/to/w'
75
71
  end
76
72
 
77
- it "must return the complete line with flags" do
73
+ it 'must return the complete line with flags' do
78
74
  Rewritten.full_line('/from').must_equal '/from'
79
75
  Rewritten.full_line('/with/flags').must_equal '/with/flags [L12]'
80
76
  end
81
77
 
82
- it "must give all tos" do
83
- Rewritten.all_tos.sort.must_equal ["/to", "/to2", "/to3"]
78
+ it 'must give all tos' do
79
+ Rewritten.all_tos.sort.must_equal ['/to', '/to/w', '/to2', '/to3']
84
80
  end
85
-
86
81
  end
87
82
 
88
-
89
- describe "flag management" do
90
-
91
- it "must return a flag string" do
92
- Rewritten.get_flag_string('/with/flags').must_equal "L12"
93
- Rewritten.get_flag_string('/n/a').must_equal ""
83
+ describe 'flag management' do
84
+ it 'must return a flag string' do
85
+ Rewritten.get_flag_string('/with/flags').must_equal 'L12'
86
+ Rewritten.get_flag_string('/n/a').must_equal ''
94
87
  end
95
88
 
96
- it "must query flags" do
97
- Rewritten.has_flag?('/with/flags', 'X').must_equal false
98
- Rewritten.has_flag?('/with/flags', 'L').must_equal true
99
- Rewritten.has_flag?('/with/flags', '1').must_equal true
100
- Rewritten.has_flag?('/with/flags', '2').must_equal true
89
+ it 'must query flags' do
90
+ Rewritten.flag?('/with/flags', 'X').must_equal false
91
+ Rewritten.flag?('/with/flags', 'L').must_equal true
92
+ Rewritten.flag?('/with/flags', '1').must_equal true
93
+ Rewritten.flag?('/with/flags', '2').must_equal true
101
94
  end
102
-
103
95
  end
104
-
105
96
  end
106
-
107
-
@@ -5,15 +5,13 @@ require 'coveralls'
5
5
 
6
6
  Coveralls.wear!
7
7
 
8
- class Minitest::Spec
9
-
8
+ class Minitest::Spec
10
9
  before :each do
11
- Rewritten.redis = "localhost:6379/test_rewritten"
10
+ Rewritten.redis = 'localhost:6379/test_rewritten'
12
11
  Rewritten.clear_translations
13
12
  end
14
13
 
15
14
  after :each do
16
15
  Rewritten.clear_translations
17
16
  end
18
-
19
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rewritten
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Rubarth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-namespace
@@ -163,6 +163,8 @@ extensions: []
163
163
  extra_rdoc_files: []
164
164
  files:
165
165
  - ".gitignore"
166
+ - ".rubocop.yml"
167
+ - ".rubocop_todo.yml"
166
168
  - ".travis.yml"
167
169
  - Gemfile
168
170
  - HISTORY.rdoc