From bab36b0260bb8e05ef27d1b36a87e8de31a12330 Mon Sep 17 00:00:00 2001 From: Kohei Suzuki Date: Mon, 12 May 2014 00:23:25 +0900 Subject: [PATCH 1/5] Update RSpec --- Gemfile | 5 ++--- Gemfile.lock | 39 ++++++++++++++++++++------------------- spec/spec_helper.rb | 1 - 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 310fc15..dba7eed 100644 --- a/Gemfile +++ b/Gemfile @@ -47,10 +47,9 @@ group :development do end group :test do - gem 'rspec-rails', '3.0.0.beta1' + gem 'rspec-rails', '>= 3.0.0.beta1' gem 'fuubar', '>= 1.3.2' - # Let bundler find pre-released RSpec 3 depended by fuubar. - gem 'rspec', '3.0.0.beta1' + gem 'rspec', '>= 3.0.0.beta1' gem 'factory_girl_rails' gem 'webrat' gem 'capybara', '>= 2.2.0', require: 'capybara/rspec' # For RSpec 3 diff --git a/Gemfile.lock b/Gemfile.lock index 376212c..f971a76 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -206,29 +206,30 @@ GEM ref (1.0.5) rest-client (1.6.7) mime-types (>= 1.16) - rspec (3.0.0.beta1) - rspec-core (= 3.0.0.beta1) - rspec-expectations (= 3.0.0.beta1) - rspec-mocks (= 3.0.0.beta1) + rspec (3.0.0.beta2) + rspec-core (= 3.0.0.beta2) + rspec-expectations (= 3.0.0.beta2) + rspec-mocks (= 3.0.0.beta2) rspec-collection_matchers (0.0.4) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.0.0.beta1) - rspec-support (= 3.0.0.beta1) - rspec-expectations (3.0.0.beta1) - diff-lcs (>= 1.1.3, < 2.0) - rspec-support (= 3.0.0.beta1) - rspec-mocks (3.0.0.beta1) - rspec-support (= 3.0.0.beta1) - rspec-rails (3.0.0.beta1) + rspec-core (3.0.0.beta2) + rspec-support (= 3.0.0.beta2) + rspec-expectations (3.0.0.beta2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (= 3.0.0.beta2) + rspec-mocks (3.0.0.beta2) + rspec-support (= 3.0.0.beta2) + rspec-rails (3.0.0.beta2) actionpack (>= 3.0) activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) rspec-collection_matchers - rspec-core (= 3.0.0.beta1) - rspec-expectations (= 3.0.0.beta1) - rspec-mocks (= 3.0.0.beta1) - rspec-support (3.0.0.beta1) + rspec-core (= 3.0.0.beta2) + rspec-expectations (= 3.0.0.beta2) + rspec-mocks (= 3.0.0.beta2) + rspec-support (= 3.0.0.beta2) + rspec-support (3.0.0.beta2) rubocop (0.21.0) json (>= 1.7.7, < 2) parser (~> 2.1.9) @@ -284,7 +285,7 @@ GEM thread_safe (0.3.3) tilt (1.4.1) timecop (0.7.1) - tins (1.1.0) + tins (1.2.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) @@ -345,8 +346,8 @@ DEPENDENCIES rails (= 4.1.1) redis redis-rails - rspec (= 3.0.0.beta1) - rspec-rails (= 3.0.0.beta1) + rspec (>= 3.0.0.beta1) + rspec-rails (>= 3.0.0.beta1) rubocop sass-rails (~> 4.0.0) sdoc diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 55f433b..d52346f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,6 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' -require 'rspec/autorun' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter, From 0c24f5453529eaaecbed42ede638b938d803488b Mon Sep 17 00:00:00 2001 From: Kohei Suzuki Date: Mon, 12 May 2014 00:51:40 +0900 Subject: [PATCH 2/5] Drop webrat --- Gemfile | 1 - Gemfile.lock | 5 ----- spec/support/shared_examples/site_problems/show.rb | 4 ++-- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index dba7eed..6b015c4 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,6 @@ group :test do gem 'fuubar', '>= 1.3.2' gem 'rspec', '>= 3.0.0.beta1' gem 'factory_girl_rails' - gem 'webrat' gem 'capybara', '>= 2.2.0', require: 'capybara/rspec' # For RSpec 3 gem 'poltergeist', require: 'capybara/poltergeist' gem 'database_rewinder' diff --git a/Gemfile.lock b/Gemfile.lock index f971a76..05bd5a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -302,10 +302,6 @@ GEM webmock (1.17.4) addressable (>= 2.2.7) crack (>= 0.3.2) - webrat (0.7.3) - nokogiri (>= 1.2.0) - rack (>= 1.0) - rack-test (>= 0.5.3) websocket-driver (0.3.3) xpath (2.0.0) nokogiri (~> 1.3) @@ -360,4 +356,3 @@ DEPENDENCIES unicorn vcr webmock - webrat diff --git a/spec/support/shared_examples/site_problems/show.rb b/spec/support/shared_examples/site_problems/show.rb index 8089610..24353db 100644 --- a/spec/support/shared_examples/site_problems/show.rb +++ b/spec/support/shared_examples/site_problems/show.rb @@ -15,7 +15,7 @@ assign :used_contests, [contest] render expect(rendered).to have_content('Used in') - expect(rendered).to have_selector('a', href: contest_path(contest)) + expect(rendered).to have_link('', href: contest_path(contest)) end end @@ -32,7 +32,7 @@ assign :solved_users, [user] render expect(rendered).to have_content('Solved by') - expect(rendered).to have_selector('a', href: user_path(user)) + expect(rendered).to have_link('', href: user_path(user)) end end From 4f38786affb00b69fb06ac4302ed61c2b58a4854 Mon Sep 17 00:00:00 2001 From: Kohei Suzuki Date: Mon, 12 May 2014 01:05:09 +0900 Subject: [PATCH 3/5] RSpec 3: config.expose_dsl_globally = false --- spec/controllers/aoj_controller_spec.rb | 2 +- spec/controllers/codeboard_controller_spec.rb | 3 +- spec/controllers/contests_controller_spec.rb | 2 +- spec/controllers/home_controller_spec.rb | 3 +- spec/controllers/poj_controller_spec.rb | 2 +- spec/controllers/sessions_controller_spec.rb | 2 +- spec/controllers/tags_controller_spec.rb | 2 +- spec/controllers/users_controller_spec.rb | 2 +- spec/features/activities_spec.rb | 10 +++---- spec/features/contest_edit_spec.rb | 28 +++++++++---------- spec/features/contest_spec.rb | 18 ++++++------ spec/features/site_problems_spec.rb | 2 +- spec/features/tag_spec.rb | 18 ++++++------ spec/features/user_spec.rb | 24 ++++++++-------- spec/libs/aoj_crawler_spec.rb | 2 +- spec/libs/poj_crawler_spec.rb | 2 +- spec/mailers/alert_mailer_spec.rb | 2 +- spec/models/aoj_submission_spec.rb | 2 +- spec/models/contest_spec.rb | 2 +- spec/models/poj_submission_spec.rb | 2 +- spec/models/standing_cache_spec.rb | 2 +- spec/models/tag_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- spec/routing/site_controller_spec.rb | 2 +- spec/spec_helper.rb | 1 + .../shared_examples/site_problems_feature.rb | 12 ++++---- spec/syntax/ruby_syntax_spec.rb | 2 +- spec/views/contests/show.html.slim_spec.rb | 2 +- .../site_problems/show.html.slim_spec.rb | 2 +- 29 files changed, 78 insertions(+), 79 deletions(-) diff --git a/spec/controllers/aoj_controller_spec.rb b/spec/controllers/aoj_controller_spec.rb index abbf546..ea01bc9 100644 --- a/spec/controllers/aoj_controller_spec.rb +++ b/spec/controllers/aoj_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AojController do +RSpec.describe AojController do let(:user) { FactoryGirl.create(:user) } let(:tag1) { FactoryGirl.create(:tag, name: 'abc') } let(:tag2) { FactoryGirl.create(:tag, name: 'aba') } diff --git a/spec/controllers/codeboard_controller_spec.rb b/spec/controllers/codeboard_controller_spec.rb index 299c865..49dc52a 100644 --- a/spec/controllers/codeboard_controller_spec.rb +++ b/spec/controllers/codeboard_controller_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -describe CodeboardController do - +RSpec.describe CodeboardController do end diff --git a/spec/controllers/contests_controller_spec.rb b/spec/controllers/contests_controller_spec.rb index 93bcb53..492bd4c 100644 --- a/spec/controllers/contests_controller_spec.rb +++ b/spec/controllers/contests_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ContestsController do +RSpec.describe ContestsController do let(:users) { 2.times.map { FactoryGirl.create :user } } let(:u1) { users[0] } let(:u2) { users[1] } diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 9d48b6a..76bb050 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -describe HomeController do - +RSpec.describe HomeController do end diff --git a/spec/controllers/poj_controller_spec.rb b/spec/controllers/poj_controller_spec.rb index 2b52fd5..074071b 100644 --- a/spec/controllers/poj_controller_spec.rb +++ b/spec/controllers/poj_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PojController do +RSpec.describe PojController do let(:user) { FactoryGirl.create(:user) } let(:tag1) { FactoryGirl.create(:tag, name: 'abc') } let(:tag2) { FactoryGirl.create(:tag, name: 'aba') } diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index b7d8934..934bb3d 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SessionsController do +RSpec.describe SessionsController do describe '#create_user' do let(:user_params) do { diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 39da29e..03107f3 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe TagsController do +RSpec.describe TagsController do let(:problem1) { FactoryGirl.create(:poj_problem) } let(:problem2) { FactoryGirl.create(:aoj_problem) } let(:problem3) { FactoryGirl.create(:poj_problem) } diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 4d7090a..8792ee7 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe UsersController do +RSpec.describe UsersController do describe '#show' do let(:user) { FactoryGirl.create(:user) } let(:problem1) { '1000' } diff --git a/spec/features/activities_spec.rb b/spec/features/activities_spec.rb index 6c1ec70..9528b2d 100644 --- a/spec/features/activities_spec.rb +++ b/spec/features/activities_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' -feature 'Activity' do - given(:user1) { FactoryGirl.create(:user) } - given(:user2) { FactoryGirl.create(:user) } +RSpec.describe 'Activity' do + let(:user1) { FactoryGirl.create(:user) } + let(:user2) { FactoryGirl.create(:user) } - background do + before do FactoryGirl.create(:poj_submission_ac, user: user1.poj_user) FactoryGirl.create(:aoj_submission_wa, user_id: user2.aoj_user) FactoryGirl.create(:contest, owner: user1) end - scenario 'list recent activities' do + it 'list recent activities' do visit '/activities' expect(page).to have_content("#{user1.name} submitted") expect(page).to have_link('AC') diff --git a/spec/features/contest_edit_spec.rb b/spec/features/contest_edit_spec.rb index 1bb1b42..123aac0 100644 --- a/spec/features/contest_edit_spec.rb +++ b/spec/features/contest_edit_spec.rb @@ -1,20 +1,20 @@ require 'spec_helper' -feature 'Contest edition' do - given(:user) { FactoryGirl.create(:twitter_user).user } - given!(:contest) { FactoryGirl.create(:contest, name: 'ayakashi') } - given!(:poj4000) { FactoryGirl.create(:poj_problem, problem_id: '4000') } - given!(:poj3000) { FactoryGirl.create(:poj_problem, problem_id: '3000') } - given!(:aoj4000) { FactoryGirl.create(:aoj_problem, problem_id: '4000') } - - background do +RSpec.describe 'Contest edition' do + let(:user) { FactoryGirl.create(:twitter_user).user } + let!(:contest) { FactoryGirl.create(:contest, name: 'ayakashi') } + let!(:poj4000) { FactoryGirl.create(:poj_problem, problem_id: '4000') } + let!(:poj3000) { FactoryGirl.create(:poj_problem, problem_id: '3000') } + let!(:aoj4000) { FactoryGirl.create(:aoj_problem, problem_id: '4000') } + + before do contest.users << FactoryGirl.create(:twitter_user).user << FactoryGirl.create(:twitter_user).user contest.site_problems << poj3000 << aoj4000 login :twitter, user end - scenario 'Update message' do + it 'Update message' do visit '/' click_link contest.name @@ -29,7 +29,7 @@ expect(page).to have_content("#{user.name} updated contest #{contest.name}") end - scenario 'Add a problem' do + it 'Add a problem' do visit '/' click_link contest.name @@ -48,7 +48,7 @@ expect(page).to have_content('AOJ 1234') end - scenario 'Add a problem with empty problem_id' do + it 'Add a problem with empty problem_id' do visit '/' click_link contest.name click_link 'Edit this contest' @@ -61,7 +61,7 @@ expect(page).to have_content('Invalid problem') end - scenario 'Failed to add a problem with non-numeric problem_id' do + it 'Failed to add a problem with non-numeric problem_id' do visit '/' click_link contest.name click_link 'Edit this contest' @@ -74,7 +74,7 @@ expect(page).to have_content('Invalid problem') end - scenario 'Remove a problem' do + it 'Remove a problem' do visit '/' click_link contest.name @@ -93,7 +93,7 @@ expect(page).not_to have_content(poj4000.description) end - scenario 'Up-down a problem' do + it 'Up-down a problem' do contest.site_problems << poj4000 visit '/' diff --git a/spec/features/contest_spec.rb b/spec/features/contest_spec.rb index aeb3a5f..efd4c13 100644 --- a/spec/features/contest_spec.rb +++ b/spec/features/contest_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' -feature 'Contest' do - given(:contest) { FactoryGirl.create(:contest) } +RSpec.describe 'Contest' do + let(:contest) { FactoryGirl.create(:contest) } context 'with login user' do - given(:user) { FactoryGirl.create(:twitter_user).user } + let(:user) { FactoryGirl.create(:twitter_user).user } - background do + before do login :twitter, user end - scenario 'Create a contest' do + it 'Create a contest' do new_contest_name = '__CONTEST__' click_link 'New contest' fill_in 'contest_name', with: new_contest_name @@ -24,7 +24,7 @@ expect(page).to have_link(new_contest_name) end - scenario 'Join to and leave a contest' do + it 'Join to and leave a contest' do visit contest_path(contest) within '#content' do expect(page).to have_button('Join') @@ -56,7 +56,7 @@ end end - scenario 'Reload standing', :js do + it 'Reload standing', :js do problem = FactoryGirl.create(:poj_problem) visit contest_path(contest) @@ -70,14 +70,14 @@ end context 'with short reload interval' do - given(:interval) { 3.seconds } + let(:interval) { 3.seconds } before do ContestsController.class_eval {} # autoload first stub_const('ContestsController::STANDING_RELOAD_INTERVAL', interval) end - scenario 'Automatic standing reload', :js do + it 'Automatic standing reload', :js do problem = FactoryGirl.create(:poj_problem) visit contest_path(contest) diff --git a/spec/features/site_problems_spec.rb b/spec/features/site_problems_spec.rb index 65e7dae..75b3774 100644 --- a/spec/features/site_problems_spec.rb +++ b/spec/features/site_problems_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Site problem' do +RSpec.describe 'Site problem' do describe 'POJ' do let(:site) { 'poj' } it_behaves_like 'a site problem page' diff --git a/spec/features/tag_spec.rb b/spec/features/tag_spec.rb index f3889b8..b710128 100644 --- a/spec/features/tag_spec.rb +++ b/spec/features/tag_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' -feature 'Tags' do - given(:user) { FactoryGirl.create(:twitter_user).user } - given!(:poj_problem) { FactoryGirl.create(:poj_problem, problem_id: '1000') } - given!(:aoj_problem) { FactoryGirl.create(:aoj_problem, problem_id: '1000') } +RSpec.describe 'Tags' do + let(:user) { FactoryGirl.create(:twitter_user).user } + let!(:poj_problem) { FactoryGirl.create(:poj_problem, problem_id: '1000') } + let!(:aoj_problem) { FactoryGirl.create(:aoj_problem, problem_id: '1000') } - background do + before do FactoryGirl.create(:tag, name: 'simple') FactoryGirl.create(:tag, name: 'dp') FactoryGirl.create(:tag, name: 'parsing') end - scenario 'Create a new tag' do + it 'Create a new tag' do login :twitter, user visit '/poj/1000' click_link 'Edit tags' @@ -21,7 +21,7 @@ expect(page.current_path).to eq(path) end - scenario 'Edit tags' do + it 'Edit tags' do login :twitter, user visit '/poj/1000' expect(page).not_to have_link('simple') @@ -78,7 +78,7 @@ expect(page).to have_field('parsing', unchecked: false) end - scenario 'Show tagged problems' do + it 'Show tagged problems' do poj_problem.tag_list = %w[simple] poj_problem.save! aoj_problem.tag_list = %w[simple dp] @@ -101,7 +101,7 @@ expect(page).to have_link('AOJ 1000') end - scenario 'Create invalid tag name' do + it 'Create invalid tag name' do login :twitter, user visit '/poj/2000' click_link 'Edit tags' diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index d34d8c1..f072aa5 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'User CRUD' do - given(:username) { OmniAuth.config.mock_auth[:twitter].info.nickname } - scenario 'Sign in with Twitter' do +RSpec.describe 'User CRUD' do + let(:username) { OmniAuth.config.mock_auth[:twitter].info.nickname } + it 'Sign in with Twitter' do visit '/' click_link 'Login' click_link 'Sign in with Twitter' @@ -17,7 +17,7 @@ end end - scenario 'Create a new account with custom username' do + it 'Create a new account with custom username' do visit '/' click_link 'Login' click_link 'Sign in with Twitter' @@ -37,18 +37,18 @@ expect(page).to have_content(custom_aoj_user) end - scenario 'Reject direct access to /users/new' do + it 'Reject direct access to /users/new' do visit '/users/new' expect(page.current_path).to eq('/login') end context 'with duplication' do - background do + before do user = FactoryGirl.create(:user, name: username) FactoryGirl.create(:twitter_user, user: user) end - scenario 'Try to create a new account but fail' do + it 'Try to create a new account but fail' do visit '/' click_link 'Login' click_link 'Sign in with Twitter' @@ -56,7 +56,7 @@ expect(page).to have_css('.alert', text: 'username') end - scenario 'Create a new account with retry' do + it 'Create a new account with retry' do visit '/' click_link 'Login' click_link 'Sign in with Twitter' @@ -74,7 +74,7 @@ end end - scenario 'Returns to the previous page after login' do + it 'Returns to the previous page after login' do visit '/contests/new' expect(page.current_path).to eq('/login') click_link 'Sign in with Twitter' @@ -82,7 +82,7 @@ expect(page.current_path).to eq('/contests/new') end - scenario 'Edits an existing user' do + it 'Edits an existing user' do visit '/' click_link 'Login' click_link 'Sign in with Twitter' @@ -116,7 +116,7 @@ expect(page).not_to have_content('AC') end - scenario 'View username on each page' do + it 'View username on each page' do visit '/' expect(page).to_not have_link(username) @@ -128,7 +128,7 @@ expect(page).to have_link(username) end - scenario 'Edit Twitter link visibility' do + it 'Edit Twitter link visibility' do visit '/' click_link 'Login' click_link 'Sign in with Twitter' diff --git a/spec/libs/aoj_crawler_spec.rb b/spec/libs/aoj_crawler_spec.rb index 080c4e8..8c9d8af 100644 --- a/spec/libs/aoj_crawler_spec.rb +++ b/spec/libs/aoj_crawler_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'aoj_crawler' -describe AojCrawler do +RSpec.describe AojCrawler do let(:crawler) { AojCrawler.new } describe '#crawl' do diff --git a/spec/libs/poj_crawler_spec.rb b/spec/libs/poj_crawler_spec.rb index fc4924f..81ad701 100644 --- a/spec/libs/poj_crawler_spec.rb +++ b/spec/libs/poj_crawler_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'poj_crawler' -describe PojCrawler do +RSpec.describe PojCrawler do let(:crawler) { PojCrawler.new } let(:top) { 100_000_000 } diff --git a/spec/mailers/alert_mailer_spec.rb b/spec/mailers/alert_mailer_spec.rb index 764ab5c..d0d7c55 100644 --- a/spec/mailers/alert_mailer_spec.rb +++ b/spec/mailers/alert_mailer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AlertMailer do +RSpec.describe AlertMailer do describe 'controller_exception' do class SomethingWentWrong < StandardError end diff --git a/spec/models/aoj_submission_spec.rb b/spec/models/aoj_submission_spec.rb index 126becd..2d6c11c 100644 --- a/spec/models/aoj_submission_spec.rb +++ b/spec/models/aoj_submission_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe AojSubmission do +RSpec.describe AojSubmission do describe '#save' do it 'saves' do sub = FactoryGirl.build :aoj_submission_ac diff --git a/spec/models/contest_spec.rb b/spec/models/contest_spec.rb index 489aa6a..68153f7 100644 --- a/spec/models/contest_spec.rb +++ b/spec/models/contest_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Contest do +RSpec.describe Contest do let(:user) { FactoryGirl.create(:user) } describe '#save' do diff --git a/spec/models/poj_submission_spec.rb b/spec/models/poj_submission_spec.rb index 55d147b..7c4f23e 100644 --- a/spec/models/poj_submission_spec.rb +++ b/spec/models/poj_submission_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PojSubmission do +RSpec.describe PojSubmission do describe '#save' do it 'saves' do sub = FactoryGirl.build :poj_submission_ac diff --git a/spec/models/standing_cache_spec.rb b/spec/models/standing_cache_spec.rb index 444b6fa..f2ad5ce 100644 --- a/spec/models/standing_cache_spec.rb +++ b/spec/models/standing_cache_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe StandingCache do +RSpec.describe StandingCache do let(:attributes) do { user: 'user001', diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 4e3a555..f2837e1 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Tag do +RSpec.describe Tag do describe '#save' do let(:tag) { FactoryGirl.build(:tag) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 12645e9..0451a11 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe User do +RSpec.describe User do describe '#save' do it 'saves' do u = described_class.new name: 'name', poj_user: 'poj', aoj_user: 'aoj' diff --git a/spec/routing/site_controller_spec.rb b/spec/routing/site_controller_spec.rb index 799c0a2..c43983c 100644 --- a/spec/routing/site_controller_spec.rb +++ b/spec/routing/site_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'site controller routing' do +RSpec.describe 'site controller routing' do describe '/poj' do it 'routes integer problem_id' do expect(get: '/poj/0123').to route_to(controller: 'poj', action: 'show', problem_id: '0123') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d52346f..c995810 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -67,4 +67,5 @@ # the seed, which is printed after each run. # --seed 1234 config.order = 'random' + config.expose_dsl_globally = false end diff --git a/spec/support/shared_examples/site_problems_feature.rb b/spec/support/shared_examples/site_problems_feature.rb index eb7d1c5..84da231 100644 --- a/spec/support/shared_examples/site_problems_feature.rb +++ b/spec/support/shared_examples/site_problems_feature.rb @@ -1,5 +1,5 @@ shared_examples 'a site problem page' do - given(:submission_class) { "#{site.camelize}Submission".constantize } + let(:submission_class) { "#{site.camelize}Submission".constantize } def create_submission(sym, problem, user, submitted_at) params = {} @@ -17,13 +17,13 @@ def create_wa(problem, user, submitted_at) create_submission(:wa, problem, user, submitted_at) end - given(:problem) { FactoryGirl.create(:problem, site: site) } - given(:user1) { FactoryGirl.create(:user) } - given(:user2) { FactoryGirl.create(:user) } + let(:problem) { FactoryGirl.create(:problem, site: site) } + let(:user1) { FactoryGirl.create(:user) } + let(:user2) { FactoryGirl.create(:user) } let!(:sub1) { create_ac(problem, user1, 5.days.ago) } let!(:sub2) { create_wa(problem, user2, 4.days.ago) } - scenario ':site/recent shows recent ACs and graph', js: true do + it ':site/recent shows recent ACs and graph', js: true do visit "/#{site}/recent" expect(page).to have_content("ACs at #{site.upcase}") expect(page).to have_css('#weekly-graph svg') @@ -31,7 +31,7 @@ def create_wa(problem, user, submitted_at) expect(page).not_to have_link(user2.name) end - scenario ':site/:problem_id creates a new SiteProblem if not exists' do + it ':site/:problem_id creates a new SiteProblem if not exists' do expect { visit "/#{site}/#{problem.problem_id}0" }.to change { SiteProblem.count }.by(1) diff --git a/spec/syntax/ruby_syntax_spec.rb b/spec/syntax/ruby_syntax_spec.rb index a772ea4..fec6065 100644 --- a/spec/syntax/ruby_syntax_spec.rb +++ b/spec/syntax/ruby_syntax_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'open3' -describe 'Ruby files' do +RSpec.describe 'Ruby files' do let(:ruby_files) { find_files(Rails.root, '.rb') } let(:syntax_checker) { Rails.root.join('spec', 'tools', 'ruby_syntax_check.rb').to_s } let(:stderr) { StringIO.new } diff --git a/spec/views/contests/show.html.slim_spec.rb b/spec/views/contests/show.html.slim_spec.rb index bd12437..ecadc81 100644 --- a/spec/views/contests/show.html.slim_spec.rb +++ b/spec/views/contests/show.html.slim_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'contests/show' do +RSpec.describe 'contests/show' do let(:t1) { Time.parse '2013-06-04 10:00' } let(:t2) { Time.parse '2013-06-04 12:00' } let(:t3) { Time.parse '2013-06-04 14:00' } diff --git a/spec/views/site_problems/show.html.slim_spec.rb b/spec/views/site_problems/show.html.slim_spec.rb index 4b83227..8ebfc99 100644 --- a/spec/views/site_problems/show.html.slim_spec.rb +++ b/spec/views/site_problems/show.html.slim_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'site_problems/show' do +RSpec.describe 'site_problems/show' do context 'with poj' do let(:site) { 'poj' } it_behaves_like 'a site problems show' From be1b40e416a69417f99af64141076052498c8446 Mon Sep 17 00:00:00 2001 From: Kohei Suzuki Date: Mon, 12 May 2014 01:10:41 +0900 Subject: [PATCH 4/5] Update capybara to silence RSpec 3 deprecation warnings --- Gemfile | 6 +++++- Gemfile.lock | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 6b015c4..2a723dd 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,11 @@ group :test do gem 'fuubar', '>= 1.3.2' gem 'rspec', '>= 3.0.0.beta1' gem 'factory_girl_rails' - gem 'capybara', '>= 2.2.0', require: 'capybara/rspec' # For RSpec 3 + gem 'capybara', '>= 2.2.0', require: 'capybara/rspec', + # For RSpec 3 beta2 + # https://github.com/jnicklas/capybara/pull/1219 + git: 'https://github.com/jnicklas/capybara', + ref: 'f18637bf905db7f05a9e9187a30e1cc435fbf593' gem 'poltergeist', require: 'capybara/poltergeist' gem 'database_rewinder' gem 'simplecov' diff --git a/Gemfile.lock b/Gemfile.lock index 05bd5a7..aeb6505 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,15 @@ +GIT + remote: https://github.com/jnicklas/capybara + revision: f18637bf905db7f05a9e9187a30e1cc435fbf593 + ref: f18637bf905db7f05a9e9187a30e1cc435fbf593 + specs: + capybara (2.2.0) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + GEM remote: https://rubygems.org/ specs: @@ -55,12 +67,6 @@ GEM capistrano-rbenv (2.0.2) capistrano (~> 3.1) sshkit (~> 1.3) - capybara (2.2.1) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) cliver (0.3.2) coderay (1.1.0) coffee-rails (4.0.1) @@ -318,7 +324,7 @@ DEPENDENCIES capistrano-bundler (>= 1.1.2) capistrano-rails capistrano-rbenv (>= 2.0.0) - capybara (>= 2.2.0) + capybara (>= 2.2.0)! coffee-rails (~> 4.0.0) coveralls database_rewinder From 1d738d90456170421a689a62a60947ae203ac73a Mon Sep 17 00:00:00 2001 From: Kohei Suzuki Date: Mon, 12 May 2014 01:13:18 +0900 Subject: [PATCH 5/5] Update fuubar to silence RSpec 3 deprecation warnings --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 2a723dd..87fec9e 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,7 @@ end group :test do gem 'rspec-rails', '>= 3.0.0.beta1' - gem 'fuubar', '>= 1.3.2' + gem 'fuubar', '>= 2.0.0.beta1' gem 'rspec', '>= 3.0.0.beta1' gem 'factory_girl_rails' gem 'capybara', '>= 2.2.0', require: 'capybara/rspec', diff --git a/Gemfile.lock b/Gemfile.lock index aeb6505..5b35483 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,8 +104,8 @@ GEM fluent-logger (0.4.9) msgpack (>= 0.4.4, < 0.6.0, != 0.5.3, != 0.5.2, != 0.5.1, != 0.5.0) yajl-ruby (~> 1.0) - fuubar (1.3.2) - rspec (>= 2.14.0, < 3.1.0) + fuubar (2.0.0.beta1) + rspec (~> 3.0.beta) ruby-progressbar (~> 1.3) hashie (2.1.1) hike (1.2.3) @@ -332,7 +332,7 @@ DEPENDENCIES fakeredis faraday fluent-logger - fuubar (>= 1.3.2) + fuubar (>= 2.0.0.beta1) jbuilder jquery-rails launchy