Skip to content

Commit d4e9ddb

Browse files
extract mock env to be reused
1 parent fa91234 commit d4e9ddb

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

.github/workflows/ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
env:
4040
BUNDLE_WITHOUT: benchmark
4141
strategy:
42-
fail-fast: false
42+
fail-fast: false # don't fail all matrix builds if one fails
4343
matrix:
4444
ruby:
4545
- '3.1'

test/support/mock_env.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
def mock_env(partial_env_hash)
4+
old = ENV.to_hash
5+
ENV.update partial_env_hash
6+
begin
7+
yield
8+
ensure
9+
ENV.replace old
10+
end
11+
end

test/test_faker.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require_relative 'test_helper'
4+
require_relative 'support/mock_env'
45

56
module Faker
67
class TestFake
@@ -163,14 +164,4 @@ def test_unique
163164

164165
assert_equal(unique_numbers.uniq, unique_numbers)
165166
end
166-
167-
def mock_env(partial_env_hash)
168-
old = ENV.to_hash
169-
ENV.update partial_env_hash
170-
begin
171-
yield
172-
ensure
173-
ENV.replace old
174-
end
175-
end
176167
end

0 commit comments

Comments
 (0)