bisu 3.0.2 → 3.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.
@@ -1,212 +0,0 @@
1
- describe Bisu::Localizer do
2
- def translates(text, fallbacks: [], to:, lang: nil)
3
- translation = localizer.localize(text, lang || language, locale, fallbacks)
4
- expect(translation).to eq to
5
- end
6
-
7
- let(:language) { "Portuguese" }
8
- let(:locale) { "pt-PT" }
9
-
10
- let(:keys) { {
11
- language => {
12
- "kTranslationKey" => "Não sabes nada João das Neves",
13
- "kTranslationKey2" => "Naaada!",
14
- "k1ParameterKey" => "Não sabes nada %{name}",
15
- "k2ParametersKey" => "Sabes %{perc} por cento %{name}",
16
- "kNewLineSingle" => "Não sabes nada\nJoão das Neves",
17
- "kNewLineMultiple" => "Não sabes nada\\nJoão das Neves",
18
-
19
- # type dependent translations
20
- "kDoubleQuoted" => "Não sabes nada \"João das Neves\"",
21
- "kSingleQuoted" => "Não sabes nada 'João das Neves'",
22
- "kEllipsis" => "Não sabes nada João das Neves...",
23
- "kAmpersand" => "Não sabes nada João das Neves T&C",
24
- "kAtSign" => "\@johnsnow sabes alguma coisa?",
25
- "kPercentage" => "Sabes 0% João das Neves."
26
- },
27
- "Spanish" => {
28
- "kMissingTransKey" => "Sabes poco John Snow"
29
- },
30
- "English" => {
31
- "kMissingTransKey" => "You know little John Snow"
32
- }
33
- } }
34
-
35
- let(:kb) { Bisu::Dictionary.new(keys) }
36
- let(:localizer) { Bisu::Localizer.new(kb, type) }
37
-
38
- shared_examples_for "a localizer" do
39
- it { expect { localizer }.not_to raise_error }
40
-
41
- it { translates("a line with no key", to: "a line with no key") }
42
-
43
- it { translates("this special key: $specialKComment1$", to: "this special key: This file was automatically generated based on a translation template.") }
44
- it { translates("this special key: $specialKComment2$", to: "this special key: Remember to CHANGE THE TEMPLATE and not this file!") }
45
- it { translates("this special key: $specialKLanguage$", to: "this special key: #{language}") }
46
- it { translates("this special key: $specialKLocale$", to: "this special key: #{locale}") }
47
-
48
- it { translates("this key: $kTranslationKey$", to: "this key: Não sabes nada João das Neves") }
49
- it { translates("this key: $kTranslationKey$", to: "this key: Não sabes nada João das Neves", lang: "portuguese") }
50
- it { translates("this unknown key: $kUnknownKey$", to: "this unknown key: $kUnknownKey$") }
51
- it { translates("this key with missing translations: $kMissingTransKey$", to: "this key with missing translations: $kMissingTransKey$") }
52
- it { translates("this key with missing translations: $kMissingTransKey$", fallbacks: ["English"], to: "this key with missing translations: You know little John Snow") }
53
- it { translates("this key with missing translations: $kMissingTransKey$", fallbacks: ["Spanish", "English"], to: "this key with missing translations: Sabes poco John Snow") }
54
- it { translates("these 2 keys: $kTranslationKey$, $kTranslationKey2$", to: "these 2 keys: Não sabes nada João das Neves, Naaada!") }
55
-
56
- it { translates("1 parameter: $k1ParameterKey$", to: "1 parameter: Não sabes nada %{name}") }
57
- it { translates("1 parameter: $k1ParameterKey{name:%1$s}$", to: "1 parameter: Não sabes nada %1$s") }
58
- it { translates("2 parameters: $k2ParametersKey$", to: "2 parameters: Sabes %{perc} por cento %{name}") }
59
- it { translates("2 parameters: $k2ParametersKey{perc:%2$d, name:%1$s}$", to: "2 parameters: Sabes %2$d por cento %1$s") }
60
- it { translates("2 parameters: $k2ParametersKey{name:%1$s, perc:%2$d}$", to: "2 parameters: Sabes %2$d por cento %1$s") }
61
-
62
- it { translates("$kNewLineSingle$", to: "Não sabes nada\\nJoão das Neves") }
63
- it { translates("$kNewLineMultiple$", to: "Não sabes nada\\nJoão das Neves") }
64
-
65
- # type dependent translations
66
-
67
- it { translates("$kDoubleQuoted$", to: expected[:double_quoted]) }
68
- it { translates("$kSingleQuoted$", to: expected[:single_quoted]) }
69
- it { translates("$kEllipsis$", to: expected[:ellipsis]) }
70
- it { translates("$kAmpersand$", to: expected[:ampersand]) }
71
- it { translates("$kAtSign$", to: expected[:at_sign]) }
72
- it { translates("$kPercentage$", to: expected[:percentage]) }
73
- it { translates("$kPercentage//formatted-string$", to: expected[:percentage_formatted]) }
74
-
75
- # error handling
76
-
77
- it "throws a warnings when key has no translation" do
78
- expect {
79
- localizer.localize("$kUnknownKey$", language, locale)
80
- }.to change { Bisu::Logger.summary[:warn] }.by(1)
81
- .and not_change { Bisu::Logger.summary[:error] }
82
- end
83
-
84
- it "does not throw a warning when key is found" do
85
- expect {
86
- localizer.localize("$kTranslationKey$", language, locale)
87
- }.to not_change { Bisu::Logger.summary[:warn] }
88
- .and not_change { Bisu::Logger.summary[:error] }
89
- end
90
-
91
- it "throws a error when missing key parameters (expect on ruby on rails)" do
92
- if type == :ror
93
- expect {
94
- localizer.localize("$k1ParameterKey$", language, locale)
95
- }.to not_change { Bisu::Logger.summary[:warn] }
96
- .and not_change { Bisu::Logger.summary[:error] }
97
- else
98
- expect {
99
- localizer.localize("$k1ParameterKey$", language, locale)
100
- }.to not_change { Bisu::Logger.summary[:warn] }
101
- .and change { Bisu::Logger.summary[:error] }.by(1)
102
- end
103
- end
104
-
105
- it "does not throw an error when key parameters where given" do
106
- expect {
107
- localizer.localize("$k1ParameterKey{name:%1$s}$", language, locale)
108
- }.to not_change { Bisu::Logger.summary[:warn] }
109
- .and not_change { Bisu::Logger.summary[:error] }
110
- end
111
-
112
- it "throws an error when given parameters for parameterless key" do
113
- expect {
114
- localizer.localize("$kTranslationKey{param:%s}$", language, locale)
115
- }.to not_change { Bisu::Logger.summary[:warn] }
116
- .and change { Bisu::Logger.summary[:error] }.by(1)
117
- end
118
-
119
- # non localizable text with params
120
-
121
- it "does not try to translate params outside $$" do
122
- translates("%{some_text}", to: "%{some_text}")
123
-
124
- expect {
125
- localizer.localize("%{some_text}", language, locale)
126
- }.to not_change { Bisu::Logger.summary[:warn] }
127
- .and not_change { Bisu::Logger.summary[:error] }
128
- end
129
- end
130
-
131
- let(:type_dependent_defaults) { {
132
- double_quoted: keys[language]["kDoubleQuoted"],
133
- single_quoted: keys[language]["kSingleQuoted"],
134
- ellipsis: keys[language]["kEllipsis"],
135
- ampersand: keys[language]["kAmpersand"],
136
- at_sign: keys[language]["kAtSign"],
137
- percentage: keys[language]["kPercentage"],
138
- percentage_formatted: keys[language]["kPercentage"],
139
- } }
140
-
141
- describe "of type iOS" do
142
- let(:type) { :ios }
143
-
144
- let(:expected) { type_dependent_defaults.merge(
145
- double_quoted: "Não sabes nada \\\"João das Neves\\\"",
146
- percentage: "Sabes 0% João das Neves.",
147
- percentage_formatted: "Sabes 0%% João das Neves.",
148
- ) }
149
-
150
- it_behaves_like "a localizer"
151
-
152
- context "when a parameter replacemnt was not defined" do
153
- let(:line) { "1 parameter: $k1ParameterKey$" }
154
- let(:expected) { "1 parameter: Não sabes nada %{name}" }
155
-
156
- it { translates(line, to: expected) }
157
-
158
- it "returns an error" do
159
- expect {
160
- localizer.localize(line, language, locale)
161
- }.to not_change { Bisu::Logger.summary[:warn] }
162
- .and change { Bisu::Logger.summary[:error] }.by(1)
163
- end
164
-
165
- context "when passing //ignore-params" do
166
- let(:line) { "1 parameter: $k1ParameterKey//ignore-params$" }
167
-
168
- it { translates(line, to: expected) }
169
-
170
- it "does not return an error" do
171
- expect {
172
- localizer.localize(line, language, locale)
173
- }.to not_change { Bisu::Logger.summary[:warn] }
174
- .and not_change { Bisu::Logger.summary[:error] }
175
- end
176
- end
177
- end
178
- end
179
-
180
- describe "of type Android" do
181
- let(:type) { :android }
182
-
183
- let(:expected) { type_dependent_defaults.merge(
184
- single_quoted: "Não sabes nada \\'João das Neves\\'",
185
- double_quoted: "Não sabes nada \\\"João das Neves\\\"",
186
- ellipsis: "Não sabes nada João das Neves…",
187
- ampersand: "Não sabes nada João das Neves T&C",
188
- at_sign: "\\@johnsnow sabes alguma coisa?",
189
- percentage: "Sabes 0% João das Neves.",
190
- percentage_formatted: "Sabes 0%% João das Neves.",
191
- ) }
192
-
193
- it_behaves_like "a localizer"
194
- end
195
-
196
- describe "of type Ruby on Rails" do
197
- let(:type) { :ror }
198
-
199
- let(:expected) { type_dependent_defaults.merge(
200
- double_quoted: "Não sabes nada \\\"João das Neves\\\"",
201
- ) }
202
-
203
- it_behaves_like "a localizer"
204
- end
205
-
206
- describe "of an unkown type" do
207
- let(:type) { :dunno }
208
- it do
209
- expect { localizer }.to raise_error /Unknown type/
210
- end
211
- end
212
- end
@@ -1,36 +0,0 @@
1
- describe Bisu::Logger do
2
- let(:summary) { Bisu::Logger.summary }
3
- let(:info) { summary[:info] }
4
- let(:warn) { summary[:warn] }
5
- let(:error) { summary[:error] }
6
-
7
- context "when logging to info" do
8
- before { Bisu::Logger.info "msg" }
9
-
10
- it "returns the expected totals" do
11
- expect(info).to eq 1
12
- expect(warn).to eq 0
13
- expect(error).to eq 0
14
- end
15
- end
16
-
17
- context "when logging to warn" do
18
- before { Bisu::Logger.warn "msg" }
19
-
20
- it "returns the expected totals" do
21
- expect(info).to eq 0
22
- expect(warn).to eq 1
23
- expect(error).to eq 0
24
- end
25
- end
26
-
27
- context "when logging to error" do
28
- before { Bisu::Logger.error "msg" }
29
-
30
- it "returns the expected totals" do
31
- expect(info).to eq 0
32
- expect(warn).to eq 0
33
- expect(error).to eq 1
34
- end
35
- end
36
- end
@@ -1,100 +0,0 @@
1
- describe Object do
2
-
3
- describe "#deep_symbolize" do
4
- subject { obj.deep_symbolize }
5
-
6
- context "when object is an Hash" do
7
- let(:obj) { { "key1" => "value1", key2: "value2" } }
8
- it { should eq({ key1: "value1", key2: "value2" }) }
9
-
10
- context "with inner Hashes" do
11
- before { obj["key2"] = { "key3" => { "key4" => "value4" } } }
12
- it { should eq({ key1: "value1", key2: { key3: { key4: "value4" } }}) }
13
- end
14
- end
15
-
16
- context "when object is an Array" do
17
- let(:obj) { ["value1"] }
18
- it { should eq obj }
19
-
20
- context "with inner Hashes" do
21
- let(:obj) { [{ "key1" => "value1" }, { "key2" => "value2" }] }
22
- it { should eq([{ key1: "value1" }, { key2: "value2" }]) }
23
- end
24
- end
25
-
26
- context "when object is something else" do
27
- let(:obj) { "value1" }
28
- it { should eq obj }
29
- end
30
- end
31
-
32
- describe "#validate_structure!" do
33
- subject { obj.validate_structure!(structure) }
34
-
35
- context "when object type differs of the structure type" do
36
- let(:obj) { "a string" }
37
- let(:structure) { { type: Integer } }
38
- it { expect { subject }.to raise_error /expected Integer, got String/i }
39
- end
40
-
41
- context "when object is a Nil" do
42
- let(:obj) { nil }
43
- let(:structure) { { type: Integer } }
44
- it { expect { subject }.to raise_error /expected Integer, got NilClass/i }
45
-
46
- context "but is also optional" do
47
- before { structure[:optional] = true }
48
- it { expect { subject }.not_to raise_error }
49
- end
50
- end
51
-
52
- context "when object is an Array" do
53
- let(:obj) { ["elem1", "elem2"] }
54
- let(:structure) { { type: Array } }
55
- it { expect { subject }.not_to raise_error }
56
-
57
- context "given an element structure" do
58
- before { structure[:elements] = { type: String } }
59
- it { expect { subject }.not_to raise_error }
60
-
61
- context "which is not respected" do
62
- before { structure[:elements] = { type: Integer } }
63
- it { expect { subject }.to raise_error /expected Integer, got String/i }
64
- end
65
- end
66
- end
67
-
68
- context "when object is an Hash" do
69
- let(:obj) { { key1: "value1", key2: "value2", key3: "value3" } }
70
- let(:structure) { { type: Hash } }
71
- it { expect { subject }.not_to raise_error }
72
-
73
- context "when given an element structure" do
74
- let(:structure) { { type: Hash, elements: { key1: { type: String }, key2: { type: String }, key3: { type: String } } } }
75
- it { expect { subject }.not_to raise_error }
76
-
77
- context "which is not respected" do
78
- before { obj[:key2] = {} }
79
- it { expect { subject }.to raise_error /expected String, got Hash/i }
80
- end
81
-
82
- context "when missing keys" do
83
- before do
84
- obj.delete(:key1)
85
- obj.delete(:key3)
86
- end
87
- it { expect { subject }.to raise_error /missing keys: key1, key3/i }
88
-
89
- context "which are optional" do
90
- before do
91
- structure[:elements][:key1][:optional] = true
92
- structure[:elements][:key3][:optional] = true
93
- end
94
- it { expect { subject }.not_to raise_error }
95
- end
96
- end
97
- end
98
- end
99
- end
100
- end
@@ -1,43 +0,0 @@
1
- describe Bisu::Source::GoogleSheet do
2
- subject(:to_i18) { Bisu::Source::GoogleSheet.new(url, "key name").to_i18 }
3
-
4
- let(:url) { "https://docs.google.com/spreadsheets/d/e/2PACX-1vTm6yu_zfbxKizC-PvUE1HVFCsplmiyz0s0qLSIGeokA7KtS3BgtqaA79CsfYfPsXH6xzUaP8HDTcj8/pub?gid=0&single=true&output=csv" }
5
- let(:response) { File.read("spec/fixtures/sample_google_response.csv") }
6
-
7
- def stub_url(status:, response:)
8
- stub_request(:get, url).
9
- to_return(:status => status, :body => response, :headers => {})
10
- end
11
-
12
- before { stub_url(status: 200, response: response) }
13
-
14
- it do
15
- expect { to_i18 }.not_to raise_error
16
- end
17
-
18
- it "returns an hash in i18 format" do
19
- expect(to_i18).to eq({
20
- "en" => { "kConnectFacebook" => "Connect with Facebook", "kNoNoNoMr" => "No, no, no. Mr %{name} not here" },
21
- "ja" => { "kConnectFacebook" => "フェイスブックへ接続" },
22
- "fr" => { "kConnectFacebook" => "Connexion par Facebook" },
23
- "de" => { "kConnectFacebook" => "Mit Facebook verbinden" },
24
- "ko" => { "kConnectFacebook" => "페이스북으로 접속", "kTwitterServer" => "트위터 서버연결 실패. \\n잠시 후 재시도." }
25
- })
26
- end
27
-
28
- context "when given an inexistent sheet" do
29
- before { stub_url(status: 400, response: "Not Found") }
30
-
31
- it do
32
- expect { to_i18 }.to raise_error /Http Error/
33
- end
34
- end
35
-
36
- context "when url content is not CSV" do
37
- before { stub_url(status: 200, response: "{\"asdsa\": \"This is a json\"}") }
38
-
39
- it do
40
- expect { to_i18 }.to raise_error /Cannot parse. Expected CSV/
41
- end
42
- end
43
- end
@@ -1,53 +0,0 @@
1
- describe Bisu::Source::OneSky do
2
- subject(:to_i18) { Bisu::Source::OneSky.new(api_key, api_secret, project_id, file_name).to_i18 }
3
-
4
- let(:api_key) { "a123" }
5
- let(:api_secret) { "b123" }
6
- let(:project_id) { 98765 }
7
- let(:file_name) { "file456.json" }
8
-
9
- let(:os_response) { File.read("spec/fixtures/sample_one_sky_response.json") }
10
-
11
- def stub_multilingual(status:, response:)
12
- stub_request(:get, "https://platform.api.onesky.io/1/projects/#{project_id}/translations/multilingual").
13
- with(query: hash_including(api_key: api_key, file_format: "I18NEXT_MULTILINGUAL_JSON", source_file_name: file_name)).
14
- to_return(:status => status, :body => response, :headers => {})
15
- end
16
-
17
- before { stub_multilingual(status: 200, response: os_response) }
18
-
19
- it { expect { to_i18 }.not_to raise_error }
20
-
21
- it "returns an hash in i18 format" do
22
- expect(to_i18).to eq({
23
- "en" => { "kConnectFacebook" => "Connect with Facebook", "kNoNoNoMr" => "No, no, no. Mr %{name} not here" },
24
- "ja" => { "kConnectFacebook" => "フェイスブックへ接続" },
25
- "fr" => { "kConnectFacebook" => "Connexion par Facebook" },
26
- "de" => { "kConnectFacebook" => "Mit Facebook verbinden" },
27
- "ko" => { "kConnectFacebook" => "페이스북으로 접속", "kTwitterServer" => "트위터 서버연결 실패. \\n잠시 후 재시도." }
28
- })
29
- end
30
-
31
- context "when OneSky raises an error" do
32
- before { stub_multilingual(status: 400, response: { error: "ups... not allowed!" }.to_json) }
33
-
34
- it "raises that same error" do
35
- expect { to_i18 }.to raise_error /not allowed/
36
- end
37
- end
38
-
39
- context "when OneSky returns the newline bug" do
40
- let(:os_response) { File.read("spec/fixtures/sample_one_sky_response_with_bug.json") }
41
-
42
- it { expect { to_i18 }.not_to raise_error }
43
-
44
- it "returns an hash in i18 format with the newline bug fixed" do
45
- expect(to_i18).to eq({
46
- "en" => {
47
- "kRegularNewLine" => "This is the first line\\nthis is the second line",
48
- "kErrorNewLine" => "This is the first line\\nthis is the second line"
49
- }
50
- })
51
- end
52
- end
53
- end
@@ -1,45 +0,0 @@
1
- describe Bisu::Source::Tolgee do
2
- subject(:to_i18) { Bisu::Source::Tolgee.new(api_key).to_i18 }
3
-
4
- let(:api_key) { "a123" }
5
- let(:os_response) { File.read("spec/fixtures/sample_tolgee_response.zip") }
6
-
7
- def stub_url(status:, response:, host: "app.tolgee.io")
8
- stub_request(:get, "https://#{host}/v2/projects/export?format=JSON&structureDelimiter=").
9
- to_return(:status => status, :body => response, :headers => {})
10
- end
11
-
12
- before { stub_url(status: 200, response: os_response) }
13
-
14
- it { expect { to_i18 }.not_to raise_error }
15
-
16
- it "returns an hash in i18 format" do
17
- expect(to_i18).to eq({
18
- "en" => { "kConnectFacebook" => "Connect with Facebook", "kNoNoNoMr" => "No, no, no. Mr %{name} not here" },
19
- "ja" => { "kConnectFacebook" => "フェイスブックへ接続" },
20
- "fr" => { "kConnectFacebook" => "Connexion par Facebook" },
21
- "de" => { "kConnectFacebook" => "Mit Facebook verbinden" },
22
- "ko" => { "kConnectFacebook" => "페이스북으로 접속", "kTwitterServer" => "트위터 서버연결 실패. \\n잠시 후 재시도." }
23
- })
24
- end
25
-
26
- context "when get request to that URL raises an error" do
27
- before { stub_url(status: 400, response: { error: "ups... not allowed!" }.to_json) }
28
-
29
- it "raises that same error" do
30
- expect { to_i18 }.to raise_error /not allowed/
31
- end
32
- end
33
-
34
- context "with a custom host" do
35
- let(:host) { "translations.example.com" }
36
- subject(:to_i18) { Bisu::Source::Tolgee.new(api_key, host).to_i18 }
37
-
38
- before { stub_url(status: 200, response: os_response, host: host) }
39
-
40
- it "uses that host" do
41
- to_i18
42
- expect(WebMock).to have_requested(:get, "https://translations.example.com/v2/projects/export?format=JSON&structureDelimiter=")
43
- end
44
- end
45
- end
@@ -1,33 +0,0 @@
1
- describe Bisu::Source::Url do
2
- subject(:to_i18) { Bisu::Source::Url.new(url).to_i18 }
3
-
4
- let(:url) { "https://in17n-08c12b370aeb6c66.herokuapp.com/documents/1/json?api_key=0320cd5d-1a51-4785-a832-a5bed8e62ed6" }
5
- let(:os_response) { File.read("spec/fixtures/sample_json_response.json") }
6
-
7
- def stub_url(status:, response:)
8
- stub_request(:get, url).
9
- to_return(:status => status, :body => response, :headers => {})
10
- end
11
-
12
- before { stub_url(status: 200, response: os_response) }
13
-
14
- it { expect { to_i18 }.not_to raise_error }
15
-
16
- it "returns an hash in i18 format" do
17
- expect(to_i18).to eq({
18
- "en" => { "kConnectFacebook" => "Connect with Facebook", "kNoNoNoMr" => "No, no, no. Mr %{name} not here" },
19
- "ja" => { "kConnectFacebook" => "フェイスブックへ接続" },
20
- "fr" => { "kConnectFacebook" => "Connexion par Facebook" },
21
- "de" => { "kConnectFacebook" => "Mit Facebook verbinden" },
22
- "ko" => { "kConnectFacebook" => "페이스북으로 접속", "kTwitterServer" => "트위터 서버연결 실패. \\n잠시 후 재시도." }
23
- })
24
- end
25
-
26
- context "when get request to that URL raises an error" do
27
- before { stub_url(status: 400, response: { error: "ups... not allowed!" }.to_json) }
28
-
29
- it "raises that same error" do
30
- expect { to_i18 }.to raise_error /not allowed/
31
- end
32
- end
33
- end
@@ -1,36 +0,0 @@
1
- describe Bisu do
2
- subject(:run) { Bisu.run([]) }
3
-
4
- context "when there is a translatable.yml" do
5
- let(:file) { File.open("spec/fixtures/sample.translatable.yml") }
6
-
7
- before do
8
- allow(Bisu).to receive(:open_file).and_return(file)
9
- allow_any_instance_of(Bisu::Source::GoogleSheet).to receive(:to_i18).and_return({
10
- "english" => { "kKey" => "Value" },
11
- "english-us" => { "kKey" => "Value" }
12
- })
13
- allow(Bisu).to receive(:localize_file)
14
- end
15
-
16
- it { expect { run }.not_to raise_error }
17
-
18
- it "logs an error" do
19
- expect {
20
- run
21
- }.to not_change { Bisu::Logger.summary[:warn] }
22
- .and not_change { Bisu::Logger.summary[:error] }
23
- end
24
- end
25
-
26
- context "when translatable.yml does not exist locally" do
27
- it { expect { run }.not_to raise_error }
28
-
29
- it "logs an error" do
30
- expect {
31
- run
32
- }.to not_change { Bisu::Logger.summary[:warn] }
33
- .and change { Bisu::Logger.summary[:error] }.by(1)
34
- end
35
- end
36
- end
data/spec/spec_helper.rb DELETED
@@ -1,117 +0,0 @@
1
- require 'bisu'
2
- require 'webmock/rspec'
3
- require 'rspec/its'
4
-
5
- # This file was generated by the `rspec --init` command. Conventionally, all
6
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
- # The generated `.rspec` file contains `--require spec_helper` which will cause
8
- # this file to always be loaded, without a need to explicitly require it in any
9
- # files.
10
- #
11
- # Given that it is always loaded, you are encouraged to keep this file as
12
- # light-weight as possible. Requiring heavyweight dependencies from this file
13
- # will add to the boot time of your test suite on EVERY test run, even for an
14
- # individual file that may not need all of that loaded. Instead, consider making
15
- # a separate helper file that requires the additional dependencies and performs
16
- # the additional setup, and require it from the spec files that actually need
17
- # it.
18
- #
19
- # The `.rspec` file also contains a few flags that are not defaults but that
20
- # users commonly want.
21
- #
22
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
23
- RSpec.configure do |config|
24
- config.before do
25
- Bisu::Logger.silent_mode = true
26
- end
27
-
28
- config.after do
29
- Bisu::Logger.clean_summary
30
- end
31
-
32
- RSpec::Matchers.define_negated_matcher :not_change, :change
33
-
34
- # rspec-expectations config goes here. You can use an alternate
35
- # assertion/expectation library such as wrong or the stdlib/minitest
36
- # assertions if you prefer.
37
- config.expect_with :rspec do |expectations|
38
- # This option will default to `true` in RSpec 4. It makes the `description`
39
- # and `failure_message` of custom matchers include text for helper methods
40
- # defined using `chain`, e.g.:
41
- # be_bigger_than(2).and_smaller_than(4).description
42
- # # => "be bigger than 2 and smaller than 4"
43
- # ...rather than:
44
- # # => "be bigger than 2"
45
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
46
- end
47
-
48
- # rspec-mocks config goes here. You can use an alternate test double
49
- # library (such as bogus or mocha) by changing the `mock_with` option here.
50
- config.mock_with :rspec do |mocks|
51
- # Prevents you from mocking or stubbing a method that does not exist on
52
- # a real object. This is generally recommended, and will default to
53
- # `true` in RSpec 4.
54
- mocks.verify_partial_doubles = true
55
- end
56
-
57
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
58
- # have no way to turn it off -- the option exists only for backwards
59
- # compatibility in RSpec 3). It causes shared context metadata to be
60
- # inherited by the metadata hash of host groups and examples, rather than
61
- # triggering implicit auto-inclusion in groups with matching metadata.
62
- config.shared_context_metadata_behavior = :apply_to_host_groups
63
-
64
- # The settings below are suggested to provide a good initial experience
65
- # with RSpec, but feel free to customize to your heart's content.
66
- =begin
67
- # This allows you to limit a spec run to individual examples or groups
68
- # you care about by tagging them with `:focus` metadata. When nothing
69
- # is tagged with `:focus`, all examples get run. RSpec also provides
70
- # aliases for `it`, `describe`, and `context` that include `:focus`
71
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
72
- config.filter_run_when_matching :focus
73
-
74
- # Allows RSpec to persist some state between runs in order to support
75
- # the `--only-failures` and `--next-failure` CLI options. We recommend
76
- # you configure your source control system to ignore this file.
77
- config.example_status_persistence_file_path = "spec/examples.txt"
78
-
79
- # Limits the available syntax to the non-monkey patched syntax that is
80
- # recommended. For more details, see:
81
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
82
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
83
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
84
- config.disable_monkey_patching!
85
-
86
- # This setting enables warnings. It's recommended, but in some cases may
87
- # be too noisy due to issues in dependencies.
88
- config.warnings = true
89
-
90
- # Many RSpec users commonly either run the entire suite or an individual
91
- # file, and it's useful to allow more verbose output when running an
92
- # individual spec file.
93
- if config.files_to_run.one?
94
- # Use the documentation formatter for detailed output,
95
- # unless a formatter has already been configured
96
- # (e.g. via a command-line flag).
97
- config.default_formatter = 'doc'
98
- end
99
-
100
- # Print the 10 slowest examples and example groups at the
101
- # end of the spec run, to help surface which specs are running
102
- # particularly slow.
103
- config.profile_examples = 10
104
-
105
- # Run specs in random order to surface order dependencies. If you find an
106
- # order dependency and want to debug it, you can fix the order by providing
107
- # the seed, which is printed after each run.
108
- # --seed 1234
109
- config.order = :random
110
-
111
- # Seed global randomization in this process using the `--seed` CLI option.
112
- # Setting this allows you to use `--seed` to deterministically reproduce
113
- # test failures related to randomization by passing the same `--seed` value
114
- # as the one that triggered the failure.
115
- Kernel.srand config.seed
116
- =end
117
- end