corrector 0.0.1

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.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +67 -0
  3. data/CHANGELOG.rdoc +13 -0
  4. data/LICENSE.rdoc +21 -0
  5. data/README.rdoc +81 -0
  6. data/Rakefile +43 -0
  7. data/app/models/corrector/base.rb +36 -0
  8. data/app/models/corrector/phrase.rb +9 -0
  9. data/app/models/corrector/prefix.rb +30 -0
  10. data/app/models/corrector/word.rb +10 -0
  11. data/app/services/corrector/cyrillic.rb +36 -0
  12. data/app/services/corrector/parse.rb +66 -0
  13. data/app/services/corrector/words.rb +71 -0
  14. data/db/migrate/20141014223624_create_corrector_bases.rb +13 -0
  15. data/lib/corrector/engine.rb +12 -0
  16. data/lib/corrector/version.rb +6 -0
  17. data/lib/corrector.rb +6 -0
  18. data/lib/tasks/corrector_tasks.rake +7 -0
  19. data/spec/dummy/README.rdoc +28 -0
  20. data/spec/dummy/Rakefile +6 -0
  21. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  22. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  23. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +13 -0
  26. data/spec/dummy/bin/bundle +3 -0
  27. data/spec/dummy/bin/rails +4 -0
  28. data/spec/dummy/bin/rake +4 -0
  29. data/spec/dummy/config/application.rb +29 -0
  30. data/spec/dummy/config/boot.rb +5 -0
  31. data/spec/dummy/config/database.yml +25 -0
  32. data/spec/dummy/config/environment.rb +5 -0
  33. data/spec/dummy/config/environments/development.rb +37 -0
  34. data/spec/dummy/config/environments/production.rb +78 -0
  35. data/spec/dummy/config/environments/test.rb +39 -0
  36. data/spec/dummy/config/initializers/assets.rb +8 -0
  37. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  39. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  40. data/spec/dummy/config/initializers/inflections.rb +16 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  42. data/spec/dummy/config/initializers/session_store.rb +3 -0
  43. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/spec/dummy/config/locales/en.yml +23 -0
  45. data/spec/dummy/config/routes.rb +4 -0
  46. data/spec/dummy/config/secrets.yml +22 -0
  47. data/spec/dummy/config.ru +4 -0
  48. data/spec/dummy/db/schema.rb +26 -0
  49. data/spec/dummy/db/test.sqlite3 +0 -0
  50. data/spec/dummy/log/development.log +0 -0
  51. data/spec/dummy/log/test.log +25007 -0
  52. data/spec/dummy/public/404.html +67 -0
  53. data/spec/dummy/public/422.html +67 -0
  54. data/spec/dummy/public/500.html +66 -0
  55. data/spec/dummy/public/favicon.ico +0 -0
  56. data/spec/dummy/tmp/cache/206/7F1/UNITS%2F%D0%9A%D0%98%D0%9B%D0%9E%D0%9C%D0%95%D0%A2%D0%A0%D0%90+%D0%92+%D0%A7%D0%90%D0%A1 +1 -0
  57. data/spec/dummy/tmp/cache/262/AB1/UNITS%2F%D0%9A%D0%98%D0%9B%D0%9E%D0%9C%D0%95%D0%A2%D0%A0%D0%9E%D0%92%2F%D0%A7%D0%90%D0%A1 +1 -0
  58. data/spec/dummy/tmp/cache/D58/820/UNITS%2F3+%D0%9A%D0%98%D0%9B%D0%9E%D0%9C%D0%95%D0%A2%D0%A0%D0%90 +1 -0
  59. data/spec/dummy/tmp/cache/E42/C10/UNITS%2F100+%D0%9C%D0%95%D0%A2%D0%A0%D0%9E%D0%92%2F%D0%A7%D0%90%D0%A1 +1 -0
  60. data/spec/factories/bases.rb +7 -0
  61. data/spec/factories/phrases.rb +7 -0
  62. data/spec/factories/prefixes.rb +7 -0
  63. data/spec/factories/words.rb +7 -0
  64. data/spec/models/corrector/base_spec.rb +90 -0
  65. data/spec/models/corrector/phrase_spec.rb +11 -0
  66. data/spec/models/corrector/prefix_spec.rb +35 -0
  67. data/spec/models/corrector/word_spec.rb +22 -0
  68. data/spec/services/corrector/cyrillic_spec.rb +26 -0
  69. data/spec/services/corrector/parse_spec.rb +58 -0
  70. data/spec/services/corrector/words_spec.rb +62 -0
  71. data/spec/spec_helper.rb +9 -0
  72. data/spec/support/initializers/caching.rb +12 -0
  73. data/spec/support/initializers/coveralls.rb +4 -0
  74. data/spec/support/initializers/database_cleaner.rb +24 -0
  75. data/spec/support/initializers/factory_girl_rails.rb +5 -0
  76. data/spec/support/initializers/focus.rb +5 -0
  77. data/spec/support/initializers/garbage_collection.rb +11 -0
  78. data/spec/support/initializers/i18n.rb +1 -0
  79. data/spec/support/initializers/migrations.rb +3 -0
  80. data/spec/support/initializers/rails.rb +6 -0
  81. data/spec/support/initializers/random_order.rb +4 -0
  82. data/spec/support/initializers/rspec.rb +10 -0
  83. metadata +306 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @valueI" КМ/Ч:ET:@created_atf1413660198.7723005:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @valueI" КМ/Ч:ET:@created_atf1413660198.7860334:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @valueI" 3 КМ:ET:@created_atf1413660198.7994218:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @valueI"100 М/Ч:ET:@created_atf1413660198.7577171:@expires_in0
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :base, class: Corrector::Base do
3
+ sequence(:scope) { |n| "UNITS-#{ n }" }
4
+ sequence(:from) { |n| "#{ n }-ЧЛЕН" }
5
+ to { "МНОГОЧЛЕН" }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :phrase, class: Corrector::Phrase do
3
+ sequence(:scope) { |n| "UNITS-#{ n }" }
4
+ sequence(:from) { |n| "#{ n } СЛОВ" }
5
+ to { "ПРЕДЛОЖЕНИЕ" }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :prefix, class: Corrector::Prefix do
3
+ sequence(:scope) { |n| "UNITS-#{ n }" }
4
+ from { 10.times.map { ("А".."Я").to_a.sample }.join("") }
5
+ to { "КГ" }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :word, class: Corrector::Word do
3
+ sequence(:scope) { |n| "UNITS-#{ n }" }
4
+ sequence(:from) { |n| "#{ n }-ЧЛЕН" }
5
+ to { "МНОГОЧЛЕН" }
6
+ end
7
+ end
@@ -0,0 +1,90 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ module Corrector
5
+ describe Base do
6
+
7
+ subject { build :base }
8
+
9
+ describe "#from=" do
10
+
11
+ it "assigns #from" do
12
+ value = "#{ subject.from }-1"
13
+ expect { subject.from = value }.to change { subject.from }.to value
14
+ end
15
+ end
16
+
17
+ describe "#to=" do
18
+
19
+ it "assigns #to" do
20
+ value = "#{ subject.to }-1"
21
+ expect { subject.to = value }.to change { subject.to }.to value
22
+ end
23
+ end
24
+
25
+ describe "#scope=" do
26
+
27
+ it "assings #scope" do
28
+ value = "#{ subject.scope }-1"
29
+ expect { subject.scope = value }
30
+ .to change { subject.scope }.to value
31
+ end
32
+ end
33
+
34
+ describe "#valid?" do
35
+
36
+ before { expect(subject).to be_valid }
37
+
38
+ it "fails when #from isn't set" do
39
+ subject.from = ""
40
+ expect(subject).not_to be_valid
41
+ end
42
+
43
+ it "fails when #to isn't set" do
44
+ subject.to = ""
45
+ expect(subject).not_to be_valid
46
+ end
47
+
48
+ it "fails when #scope isn't set" do
49
+ subject.scope = ""
50
+ expect(subject).not_to be_valid
51
+ end
52
+
53
+ it "fails when #from is taken in the same scope" do
54
+ create(:base, from: subject.from, scope: subject.scope)
55
+ expect(subject).not_to be_valid
56
+ end
57
+
58
+ it "passes when #from is taken in anotner scope" do
59
+ create(:base, from: subject.from)
60
+ expect(subject).to be_valid
61
+ end
62
+
63
+ it "passes when #to is taken in the same scope" do
64
+ create(:base, to: subject.to, scope: subject.scope)
65
+ expect(subject).to be_valid
66
+ end
67
+ end
68
+
69
+ describe ".scan" do
70
+
71
+ it "returns translation" do
72
+ create :base, from: "ЧАС", to: "Ч", scope: "UNITS"
73
+ expect(Base.scan "ЧАС").to eq "Ч"
74
+ end
75
+
76
+ it "returns source if no translation found" do
77
+ expect(Base.scan "ЧАС").to eq "ЧАС"
78
+ end
79
+ end
80
+
81
+ describe ".by_scope" do
82
+
83
+ it "returns objects in a given scope" do
84
+ create :base, scope: "USER"
85
+ unit = create :base, scope: "UNITS"
86
+ expect(Base.by_scope("UNITS").to_a).to eq [unit]
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ module Corrector
5
+ describe Phrase do
6
+
7
+ it "is a kind of Corrector::Base" do
8
+ expect(subject).to be_kind_of Corrector::Base
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ module Corrector
5
+ describe Prefix do
6
+
7
+ it "is a kind of Corrector::Base" do
8
+ expect(subject).to be_kind_of Corrector::Base
9
+ end
10
+
11
+ describe "#valid?" do
12
+
13
+ subject { build :prefix }
14
+ before { expect(subject).to be_valid }
15
+
16
+ it "fails when #from has spaces" do
17
+ subject.from = "РАЗ ДВА"
18
+ expect(subject).not_to be_valid
19
+ end
20
+ end
21
+
22
+ describe ".scan" do
23
+
24
+ before { create :prefix, from: "КИЛО", to: "К" }
25
+
26
+ it "separates and changes a prefix" do
27
+ expect(Prefix.scan "КИЛОМЕТР").to eq(%w(К ^ МЕТР))
28
+ end
29
+
30
+ it "doesn't change middle of word" do
31
+ expect(Prefix.scan "ПОЛКИЛО").to eq(%w(ПОЛКИЛО))
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ module Corrector
5
+ describe Word do
6
+
7
+ it "is a kind of Corrector::Base" do
8
+ expect(subject).to be_kind_of Corrector::Base
9
+ end
10
+
11
+ describe "#valid?" do
12
+
13
+ subject { build :word }
14
+ before { expect(subject).to be_valid }
15
+
16
+ it "fails when #from has spaces" do
17
+ subject.from = "РАЗ ДВА"
18
+ expect(subject).not_to be_valid
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ module Corrector
5
+ describe Cyrillic do
6
+
7
+ describe ".new" do
8
+
9
+ it "uppercases a string" do
10
+ expect(Cyrillic.new("абвг")).to eq "АБВГ"
11
+ end
12
+
13
+ it "converts latin letters to cyrillic" do
14
+ expect(Cyrillic.new("abcd")).to eq "АВСД"
15
+ end
16
+ end
17
+
18
+ describe "#source" do
19
+
20
+ it "stores a source" do
21
+ source = "abcd"
22
+ expect(Cyrillic.new(source).source).to eq source
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ module Corrector
5
+ describe Parse do
6
+
7
+ describe ".new" do
8
+
9
+ before do
10
+ create :prefix, from: "КИЛО", to: "К", scope: "UNITS"
11
+ create :word, from: "МЕТРОВ", to: "М", scope: "UNITS"
12
+ create :word, from: "МЕТРА", to: "М", scope: "UNITS"
13
+ create :word, from: "ЧАС", to: "Ч", scope: "UNITS"
14
+ create :phrase, from: "КМ В Ч", to: "КМ/Ч", scope: "UNITS"
15
+ end
16
+
17
+ specify do
18
+ expect(Parse.new "Километров/час", scope: "UNITS").to eq "КМ/Ч"
19
+ end
20
+
21
+ specify do
22
+ expect(Parse.new "Километра в час", scope: "UNITS").to eq "КМ/Ч"
23
+ end
24
+
25
+ specify do
26
+ expect(Parse.new "3 километра", scope: "UNITS").to eq "3 КМ"
27
+ end
28
+
29
+ specify do
30
+ expect(Parse.new "100 метров/час", scope: "UNITS").to eq "100 М/Ч"
31
+ end
32
+
33
+ it "caches db requests in a same scope", :caching do
34
+ str = "Километров/час"
35
+ Parse.new str, scope: "UNITS"
36
+ [Word, Prefix, Phrase]
37
+ .each { |klass| expect(klass).not_to receive(:scan) }
38
+ Parse.new str, scope: "UNITS"
39
+ end
40
+
41
+ it "doesn't use cache from another scope", :caching do
42
+ str = "Километров/час"
43
+ Parse.new str, scope: "UNITS"
44
+ [Word, Prefix, Phrase]
45
+ .each { |klass| expect(klass).to receive(:scan).at_least(:once) }
46
+ Parse.new str, scope: "CURRENCIES"
47
+ end
48
+ end
49
+
50
+ describe "#source" do
51
+
52
+ it "stores a source" do
53
+ source = "abcd"
54
+ expect(Parse.new(source, scope: "UNITS").source).to eq source
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ module Corrector
5
+ describe Words do
6
+
7
+ describe ".new" do
8
+
9
+ specify { expect(Words.new %w(А1)).to eq %w(А1) }
10
+ specify { expect(Words.new "АБ12").to eq %w(АБ 12) }
11
+ specify { expect(Words.new "А Б1 2").to eq %w(А Б 1 2) }
12
+ specify { expect(Words.new "А.Б.").to eq %w(А Б) }
13
+ specify { expect(Words.new "А:Б").to eq %w(А Б) }
14
+ specify { expect(Words.new "А;Б").to eq %w(А Б) }
15
+ specify { expect(Words.new "А,Б").to eq %w(А Б) }
16
+ specify { expect(Words.new "12.").to eq %w(12) }
17
+ specify { expect(Words.new "1.2.1").to eq %w(1.2 1) }
18
+ specify { expect(Words.new "1,2,1").to eq %w(1.2 1) }
19
+ specify { expect(Words.new "А-Б1-2").to eq %w(А Б 1 2) }
20
+ specify { expect(Words.new "А№Б").to eq %w(А № Б) }
21
+ specify { expect(Words.new "А$Б").to eq %w(А $ Б) }
22
+ specify { expect(Words.new "А^Б").to eq %w(А ^ Б) }
23
+ specify { expect(Words.new "12%").to eq %w(12 %) }
24
+ specify { expect(Words.new "А/1/2").to eq %w(А / 1 / 2) }
25
+ specify { expect(Words.new "А|1").to eq %w(А / 1) }
26
+ end
27
+
28
+ describe "#source" do
29
+
30
+ it "stores a source" do
31
+ source = "abcd"
32
+ expect(Words.new(source).source).to eq source
33
+ end
34
+ end
35
+
36
+ describe "#map" do
37
+
38
+ it "returns a Words object" do
39
+ expect(Words.new("А1").map { |word| word }).to be_kind_of Words
40
+ end
41
+ end
42
+
43
+ describe "#to_s" do
44
+
45
+ it "joins words with spaces" do
46
+ expect(Words.new(%w(А 1)).to_s).to eq "А 1"
47
+ end
48
+
49
+ it "strips words before joining" do
50
+ expect(Words.new(["А ", "Б "]).to_s).to eq "А Б"
51
+ end
52
+
53
+ it "removes spaces around /" do
54
+ expect(Words.new(%w(А / 1)).to_s).to eq "А/1"
55
+ end
56
+
57
+ it "removes ^" do
58
+ expect(Words.new(%w(А ^ 1)).to_s).to eq "А1"
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,9 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+
3
+ root = File.dirname File.dirname(__FILE__)
4
+
5
+ # Application files
6
+ require File.expand_path("../dummy/config/environment", __FILE__)
7
+
8
+ # Support files and Rspec settings
9
+ Dir[File.join(root, "spec/support/**/*.rb")].each { |file| require file }
@@ -0,0 +1,12 @@
1
+ require "rails"
2
+ require "rspec/rails"
3
+
4
+ RSpec.configure do |config|
5
+ config.around(:each, :caching) do |example|
6
+ caching = ActionController::Base.perform_caching
7
+ ActionController::Base.perform_caching = example.metadata[:caching]
8
+ example.run
9
+ Rails.cache.clear
10
+ ActionController::Base.perform_caching = caching
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ # Check test coverage
2
+ require "coveralls"
3
+
4
+ Coveralls.wear!
@@ -0,0 +1,24 @@
1
+ require "database_cleaner"
2
+ require "rspec/rails"
3
+
4
+ RSpec.configure do |config|
5
+
6
+ # stop wrapping each of test examples within a transaction
7
+ config.use_transactional_fixtures = false
8
+
9
+ config.before :suite do
10
+ DatabaseCleaner.clean_with :truncation
11
+ end
12
+
13
+ config.before :each do
14
+ DatabaseCleaner.strategy = :transaction
15
+ end
16
+
17
+ config.before :each do
18
+ DatabaseCleaner.start
19
+ end
20
+
21
+ config.after :each do
22
+ DatabaseCleaner.clean
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ require "factory_girl_rails"
2
+
3
+ RSpec.configure do |config|
4
+ config.include FactoryGirl::Syntax::Methods
5
+ end
@@ -0,0 +1,5 @@
1
+ # Run only tests tagged by :focus
2
+ RSpec.configure do |config|
3
+ config.filter_run focus: true
4
+ config.run_all_when_everything_filtered = true
5
+ end
@@ -0,0 +1,11 @@
1
+ # Delayg garbage collection to the end of tests
2
+ RSpec.configure do |config|
3
+
4
+ config.before(:each) do
5
+ GC.disable
6
+ end
7
+
8
+ config.after(:each) do
9
+ GC.enable
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ I18n.enforce_available_locales = false
@@ -0,0 +1,3 @@
1
+ require "active_record"
2
+
3
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
@@ -0,0 +1,6 @@
1
+ require "rspec/rails"
2
+
3
+ RSpec.configure do |config|
4
+ config.infer_spec_type_from_file_location!
5
+ config.infer_base_class_for_anonymous_controllers = false
6
+ end
@@ -0,0 +1,4 @@
1
+ # Run tests in a random order
2
+ RSpec.configure do |config|
3
+ config.order = "random"
4
+ end
@@ -0,0 +1,10 @@
1
+ RSpec.configure do |config|
2
+
3
+ config.mock_with :rspec do |mocks|
4
+ mocks.yield_receiver_to_any_instance_implementation_blocks = false
5
+ end
6
+
7
+ config.expect_with :rspec do |c|
8
+ c.syntax = :expect
9
+ end
10
+ end