Last active
August 29, 2015 13:57
-
-
Save refiute/9787603 to your computer and use it in GitHub Desktop.
AOJの補助サイトをTDDやってみながら作った時のテスト
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
require 'spec_helper' | |
describe 'Diff' do | |
before { visit diff_index_path } | |
specify 'ユーザーがどちらも存在する時' do | |
within('form') do | |
fill_in 'user1', with: 'refiute' | |
fill_in 'user2', with: 'kagasan' | |
click_button 'Submit' | |
end | |
expect(current_path).to eq(diff_path(user1:'refiute', user2:'kagasan')) | |
end | |
specify 'ユーザー1が存在しない時' do | |
within('form') do | |
fill_in 'user1', with: 'wrong_refiute' | |
fill_in 'user2', with: 'kagasan' | |
click_button 'Submit' | |
end | |
expect(current_path).to eq(diff_index_path) | |
end | |
specify 'ユーザー2が存在しない時' do | |
within('form') do | |
fill_in 'user1', with: 'refiute' | |
fill_in 'user2', with: 'wrong_kagasan' | |
click_button 'Submit' | |
end | |
expect(current_path).to eq(diff_index_path) | |
end | |
specify 'ユーザーがどちらも存在しない時' do | |
within('form') do | |
fill_in 'user1', with: 'wrong_refiute' | |
fill_in 'user2', with: 'wrong_kagasan' | |
click_button 'Submit' | |
end | |
expect(current_path).to eq(diff_index_path) | |
end | |
end |
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
require 'spec_helper' | |
describe 'Subject' do | |
before { visit subject_index_path } | |
specify 'ユーザーが存在する時' do | |
within('form') do | |
fill_in 'username', with: 'bardiche' | |
click_button 'Submit' | |
end | |
expect(current_path).to eq(subject_path(user: 'bardiche')) | |
end | |
specify 'ユーザーが存在しない時' do | |
within('form') do | |
fill_in 'username', with: 'wrong_refiute' | |
click_button 'Submit' | |
end | |
expect(current_path).to eq(subject_index_path) | |
end | |
end |
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
require 'spec_helper' | |
describe 'TopPage' do | |
before { visit root_path } | |
specify '挨拶文が表示される' do | |
expect(page).to have_css('h1', text: 'Welcome to AOJ-Support') | |
end | |
specify 'Diffページへのリンクがある' do | |
expect(find_link("Diff")).to be_present | |
find_link("Diff").click | |
expect(current_path).to eq(diff_index_path) | |
end | |
specify 'Subjectページへのリンクがある' do | |
expect(find_link("Subject")).to be_present | |
find_link("Subject").click | |
expect(current_path).to eq(subject_index_path) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment