Skip to content

Commit

Permalink
Use I18n.with_locale for improved test isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
tuzz committed Jan 5, 2018
1 parent 49188cd commit 155cd85
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions spec/components/radio_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ def render_component(locals)
render file: "components/_radio", locals: locals
end

before(:each) do
I18n.default_locale = :en
end

it "does not render anything if no data is passed" do
assert_empty render_component({})
end
Expand Down Expand Up @@ -170,22 +166,23 @@ def render_component(locals)
end

it "renders radio-group with welsh translated 'or'" do
I18n.default_locale = :cy
I18n.with_locale(:cy) do
render_component(
name: "radio-welsh-or",
items: [
{
value: "government-gateway",
text: "Use Government Gateway"
},
:or,
{
value: "govuk-verify",
text: "Use GOV.UK Verify"
}
]
)
end

render_component(
name: "radio-welsh-or",
items: [
{
value: "government-gateway",
text: "Use Government Gateway"
},
:or,
{
value: "govuk-verify",
text: "Use GOV.UK Verify"
}
]
)
assert_select ".gem-c-radio__block-text", text: "neu"
end
end
Expand Down

0 comments on commit 155cd85

Please sign in to comment.