Created
January 25, 2018 22:49
-
-
Save JunichiIto/b1b499d4b56e8eb5001be7b31ed826a6 to your computer and use it in GitHub Desktop.
Suggestion for http://leokun0210.hatenablog.com/entry/2018/01/25/225602
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example(it)内でローカル変数を宣言する | |
describe 'convert_hash_syntax' do | |
it '=>が:に置き換わる' do | |
old_syntax = <<~TEXT | |
{ | |
:name => 'Alice', | |
:age => 20, | |
:gender => :female | |
} | |
TEXT | |
expected = <<~TEXT | |
{ | |
name: 'Alice', | |
age: 20, | |
gender: :female | |
} | |
TEXT | |
expect(convert_hash_syntax(old_syntax)).to eq(expected) | |
end | |
end | |
# letを使う | |
describe 'convert_hash_syntax' do | |
let(:old_syntax) do | |
<<~TEXT | |
{ | |
:name => 'Alice', | |
:age => 20, | |
:gender => :female | |
} | |
TEXT | |
end | |
let(:expected) do | |
<<~TEXT | |
{ | |
name: 'Alice', | |
age: 20, | |
gender: :female | |
} | |
TEXT | |
end | |
it '=>が:に置き換わる' do | |
expect(convert_hash_syntax(old_syntax)).to eq(expected) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment