Last active
January 3, 2016 04:49
-
-
Save hzm-s/8412105 to your computer and use it in GitHub Desktop.
異常系ValidationのE2Eテスト(RSpec,Rails)
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
context '入力が正しくない' do | |
[ | |
[:name, "未入力", nil, "can't be blank"], | |
[:name, "101文字以上", 'a' * 101, "is too long"], | |
[:display, "101文字以上", 'a' * 101, "is too long"] | |
] | |
.each do |attr, state, value, msg| | |
context "#{attr.to_s.humanize}が#{state}" do | |
let(:input) { valid_input.merge(attr => value) } | |
it '保存されないこと' do | |
expect { subject }.not_to change { Model.count } | |
end | |
it 'エラーが表示されること' do | |
subject | |
expect(page).to have_content("#{attr.to_s.humanize} #{msg}") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment