Skip to content

Commit 4aa910e

Browse files
authored
Merge pull request #1914 from splattael/rspec-order-rand
Run specs in random order
2 parents 3241eb7 + 137d474 commit 4aa910e

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
--color
22
--format=documentation
3+
--order=rand

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Your contribution here.
66
* [#1904](https://github.com/ruby-grape/grape/pull/1904): Allows Grape to load files on startup rather than on the first call - [@myxoh](https://github.com/myxoh).
77
* [#1907](https://github.com/ruby-grape/grape/pull/1907): Adds outside configuration to Grape with `configure` - [@unleashy](https://github.com/unleashy).
8+
* [#1914](https://github.com/ruby-grape/grape/pull/1914): Run specs in random order - [@splattael](https://github.com/splattael).
89

910
#### Fixes
1011

spec/grape/endpoint_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def app
88
end
99

1010
describe '.before_each' do
11-
after { Grape::Endpoint.before_each(nil) }
11+
after { Grape::Endpoint.before_each.clear }
1212

1313
it 'is settable via block' do
1414
block = ->(_endpoint) { 'noop' }

spec/grape/exceptions/base_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
let(:attributes) { { klass: String, to_format: 'xml' } }
99

1010
after do
11+
I18n.enforce_available_locales = true
1112
I18n.available_locales = %i[en]
13+
I18n.locale = :en
1214
I18n.default_locale = :en
15+
I18n.reload!
1316
end
1417

1518
context 'when I18n enforces available locales' do
@@ -29,6 +32,7 @@
2932
context 'when the fallback locale is not available' do
3033
before do
3134
I18n.available_locales = %i[de jp]
35+
I18n.locale = :de
3236
I18n.default_locale = :de
3337
end
3438

spec/grape/middleware/formatter_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ def self.call(_, _)
391391
Grape::Formatter.register :invalid, InvalidFormatter
392392
Grape::ContentTypes::CONTENT_TYPES[:invalid] = 'application/x-invalid'
393393
end
394+
after do
395+
Grape::ContentTypes::CONTENT_TYPES.delete(:invalid)
396+
Grape::Formatter.default_elements.delete(:invalid)
397+
end
394398

395399
it 'returns response by invalid formatter' do
396400
env = { 'PATH_INFO' => '/hello.invalid', 'HTTP_ACCEPT' => 'application/x-invalid' }

spec/grape/validations/validators/coerce_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ class User
2020

2121
context 'i18n' do
2222
after :each do
23+
I18n.available_locales = %i[en]
2324
I18n.locale = :en
25+
I18n.default_locale = :en
2426
end
2527

2628
it 'i18n error on malformed input' do
29+
I18n.available_locales = %i[en zh-CN]
2730
I18n.load_path << File.expand_path('../zh-CN.yml', __FILE__)
2831
I18n.reload!
2932
I18n.locale = 'zh-CN'.to_sym
@@ -40,6 +43,7 @@ class User
4043
end
4144

4245
it 'gives an english fallback error when default locale message is blank' do
46+
I18n.available_locales = %i[en pt-BR]
4347
I18n.locale = 'pt-BR'.to_sym
4448
subject.params do
4549
requires :age, type: Integer

0 commit comments

Comments
 (0)