From a40c037d81997604a964f82d9bac60441c3aac30 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Mon, 13 Oct 2014 12:51:52 -0600 Subject: [PATCH] rspec 3-ify spec/integration refs CNVS-16239 Change-Id: Ifdda42582111e144648af46ab6c383f71c1858ab Reviewed-on: https://gerrit.instructure.com/42678 Tested-by: Jenkins Reviewed-by: Braden Anderson Product-Review: Braden Anderson QA-Review: Braden Anderson --- spec/integration/account_spec.rb | 22 +- spec/integration/application_spec.rb | 32 +- spec/integration/asset_accesses_spec.rb | 28 +- spec/integration/assignments_spec.rb | 84 +-- spec/integration/collaborations_spec.rb | 12 +- .../integration/concluded_unconcluded_spec.rb | 44 +- spec/integration/conferences_spec.rb | 24 +- spec/integration/content_zipper_spec.rb | 10 +- spec/integration/context_module_spec.rb | 70 +-- spec/integration/course_spec.rb | 16 +- spec/integration/course_wizard_spec.rb | 12 +- spec/integration/cross_listing_spec.rb | 2 +- spec/integration/discussion_topics_spec.rb | 14 +- .../enrollment_date_restrictions_spec.rb | 46 +- spec/integration/external_tools_spec.rb | 92 +-- spec/integration/files_spec.rb | 184 +++--- spec/integration/groups_spec.rb | 8 +- spec/integration/hair_trigger_spec.rb | 2 +- spec/integration/info_controller_spec.rb | 12 +- spec/integration/locale_selection_spec.rb | 8 +- spec/integration/navigation_spec.rb | 12 +- spec/integration/oauth_token_spec.rb | 52 +- spec/integration/otp_spec.rb | 10 +- spec/integration/page_view_spec.rb | 8 +- spec/integration/profile_spec.rb | 12 +- .../pseudonym_sessions_controller_spec.rb | 64 +- spec/integration/quiz_regrading_spec.rb | 16 +- spec/integration/quiz_submissions_spec.rb | 20 +- spec/integration/quizzes_spec.rb | 50 +- spec/integration/security_spec.rb | 550 +++++++++--------- spec/integration/sessions_timeout_spec.rb | 10 +- spec/integration/student_interactions_spec.rb | 24 +- spec/integration/syllabus_spec.rb | 10 +- spec/integration/user_content_spec.rb | 10 +- spec/integration/users_controller_spec.rb | 114 ++-- spec/integration/varied_due_dates_spec.rb | 10 +- spec/integration/wiki_page_spec.rb | 18 +- 37 files changed, 854 insertions(+), 858 deletions(-) diff --git a/spec/integration/account_spec.rb b/spec/integration/account_spec.rb index ff32f8ddfee..70c545f97cd 100644 --- a/spec/integration/account_spec.rb +++ b/spec/integration/account_spec.rb @@ -22,18 +22,14 @@ describe AccountsController do context "SAML meta data" do before(:each) do - pending("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled - ConfigFile.stub('saml', { - :tech_contact_name => nil, - :tech_contact_email => nil - }) + skip("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled @account = Account.create!(:name => "test") end it 'should render for non SAML configured accounts' do get "/saml_meta_data" - response.should be_success - response.body.should_not == "" + expect(response).to be_success + expect(response.body).not_to eq "" end it "should use the correct entity_id" do @@ -41,9 +37,9 @@ describe AccountsController do @aac = @account.account_authorization_configs.create!(:auth_type => "saml") get "/saml_meta_data" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css("EntityDescriptor")['entityID'].should == "http://bob.cody.instructure.com/saml2" + expect(doc.at_css("EntityDescriptor")['entityID']).to eq "http://bob.cody.instructure.com/saml2" end end @@ -57,9 +53,9 @@ describe AccountsController do user_session @admin Timecop.freeze(61.minutes.ago) do get "/accounts/#{@account.id}" - response.should be_ok + expect(response).to be_ok doc = Nokogiri::HTML(response.body) - doc.at_css('#section-tabs .section .outcomes').should_not be_nil + expect(doc.at_css('#section-tabs .section .outcomes')).not_to be_nil end # change a permission on the user's role @@ -68,9 +64,9 @@ describe AccountsController do # ensure the change is reflected once the user's cached permissions expire get "/accounts/#{@account.id}" - response.should be_ok + expect(response).to be_ok doc = Nokogiri::HTML(response.body) - doc.at_css('#section-tabs .section .outcomes').should be_nil + expect(doc.at_css('#section-tabs .section .outcomes')).to be_nil end end end diff --git a/spec/integration/application_spec.rb b/spec/integration/application_spec.rb index bd98bf586b7..b91740c514f 100644 --- a/spec/integration/application_spec.rb +++ b/spec/integration/application_spec.rb @@ -35,25 +35,25 @@ describe "site-wide" do it "should set the x-ua-compatible http header" do get "/login" - response['x-ua-compatible'].should == "IE=Edge,chrome=1" + expect(response['x-ua-compatible']).to eq "IE=Edge,chrome=1" end it "should set no-cache headers for html requests" do get "/login" - response['Pragma'].should match(/no-cache/) - response['Cache-Control'].should match(/must-revalidate/) + expect(response['Pragma']).to match(/no-cache/) + expect(response['Cache-Control']).to match(/must-revalidate/) end it "should NOT set no-cache headers for API/xhr requests" do get "/api/v1/courses" - response['Pragma'].should be_nil - response['Cache-Control'].should_not match(/must-revalidate/) + expect(response['Pragma']).to be_nil + expect(response['Cache-Control']).not_to match(/must-revalidate/) end it "should set the x-frame-options http header" do get "/login" - assigns[:files_domain].should be_false - response['x-frame-options'].should == "SAMEORIGIN" + expect(assigns[:files_domain]).to be_falsey + expect(response['x-frame-options']).to eq "SAMEORIGIN" end it "should not set x-frame-options when on a files domain" do @@ -61,7 +61,7 @@ describe "site-wide" do attachment_model(:context => @user) FilesController.any_instance.expects(:files_domain?).returns(true) get "http://files-test.host/files/#{@attachment.id}/download" - response['x-frame-options'].should be_nil + expect(response['x-frame-options']).to be_nil end context "user headers" do @@ -81,36 +81,36 @@ describe "site-wide" do it "should not set the logged in user headers when no one is logged in" do get "/" - response['x-canvas-user-id'].should be_nil - response['x-canvas-real-user-id'].should be_nil + expect(response['x-canvas-user-id']).to be_nil + expect(response['x-canvas-real-user-id']).to be_nil end it "should set them when a user is logged in" do user_session(@student, @student_pseudonym) get "/" - response['x-canvas-user-id'].should == @student.global_id.to_s - response['x-canvas-real-user-id'].should be_nil + expect(response['x-canvas-user-id']).to eq @student.global_id.to_s + expect(response['x-canvas-real-user-id']).to be_nil end it "should set them when masquerading" do user_session(@admin, @admin.pseudonyms.first) post "/users/#{@student.id}/masquerade" get "/" - response['x-canvas-user-id'].should == @student.global_id.to_s - response['x-canvas-real-user-id'].should == @admin.global_id.to_s + expect(response['x-canvas-user-id']).to eq @student.global_id.to_s + expect(response['x-canvas-real-user-id']).to eq @admin.global_id.to_s end end context "breadcrumbs" do it "should be absent for error pages" do get "/apagethatdoesnotexist" - response.body.should_not match(%r{id="breadcrumbs"}) + expect(response.body).not_to match(%r{id="breadcrumbs"}) end it "should be absent for error pages with user info" do course_with_teacher get "/users/#{@user.id}/files/apagethatdoesnotexist" - response.body.to_s.should_not match(%r{id="breadcrumbs"}) + expect(response.body.to_s).not_to match(%r{id="breadcrumbs"}) end end diff --git a/spec/integration/asset_accesses_spec.rb b/spec/integration/asset_accesses_spec.rb index eb08c4e3fd2..240e5c3ab2c 100644 --- a/spec/integration/asset_accesses_spec.rb +++ b/spec/integration/asset_accesses_spec.rb @@ -52,17 +52,17 @@ describe "user asset accesses" do user_session(@student) get "/courses/#{@course.id}/assignments/#{assignment.id}" - response.should be_success + expect(response).to be_success user_session(@teacher) get "/courses/#{@course.id}/users/#{@student.id}/usage" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#usage_report .access.assignment').length.should == 1 - html.css('#usage_report .access.assignment .readable_name').text.strip.should == 'Assignment 1' - html.css('#usage_report .access.assignment .view_score').text.strip.should == '1' - html.css('#usage_report .access.assignment .last_viewed').text.strip.should == datetime_string(now) - AssetUserAccess.where(:user_id => @student).first.last_access.to_i.should == now.to_i + expect(html.css('#usage_report .access.assignment').length).to eq 1 + expect(html.css('#usage_report .access.assignment .readable_name').text.strip).to eq 'Assignment 1' + expect(html.css('#usage_report .access.assignment .view_score').text.strip).to eq '1' + expect(html.css('#usage_report .access.assignment .last_viewed').text.strip).to eq datetime_string(now) + expect(AssetUserAccess.where(:user_id => @student).first.last_access.to_i).to eq now.to_i now2 = now + 1.hour Time.stubs(:now).returns(now2) @@ -72,16 +72,16 @@ describe "user asset accesses" do user_session(@student) get "/courses/#{@course.id}/assignments/#{assignment.id}" - response.should be_success + expect(response).to be_success user_session(@teacher) get "/courses/#{@course.id}/users/#{@student.id}/usage" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#usage_report .access.assignment').length.should == 1 - html.css('#usage_report .access.assignment .readable_name').text.strip.should == 'Assignment 1' - html.css('#usage_report .access.assignment .view_score').text.strip.should == '2' - html.css('#usage_report .access.assignment .last_viewed').text.strip.should == datetime_string(now2) - AssetUserAccess.where(:user_id => @student).first.last_access.to_i.should == now2.to_i + expect(html.css('#usage_report .access.assignment').length).to eq 1 + expect(html.css('#usage_report .access.assignment .readable_name').text.strip).to eq 'Assignment 1' + expect(html.css('#usage_report .access.assignment .view_score').text.strip).to eq '2' + expect(html.css('#usage_report .access.assignment .last_viewed').text.strip).to eq datetime_string(now2) + expect(AssetUserAccess.where(:user_id => @student).first.last_access.to_i).to eq now2.to_i end end diff --git a/spec/integration/assignments_spec.rb b/spec/integration/assignments_spec.rb index 1bc5e6eb309..2ee52145120 100644 --- a/spec/integration/assignments_spec.rb +++ b/spec/integration/assignments_spec.rb @@ -45,8 +45,8 @@ describe "assignments" do course_with_teacher_logged_in(:course => @course, :active_all => true) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success - Nokogiri::HTML(response.body).at_css('.graded_count').text.should match(/0 out of 2/) + expect(response).to be_success + expect(Nokogiri::HTML(response.body).at_css('.graded_count').text).to match(/0 out of 2/) end it "should correctly list ungraded and total submissions for ta" do @@ -59,8 +59,8 @@ describe "assignments" do get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success - Nokogiri::HTML(response.body).at_css('.graded_count').text.should match(/0 out of 1/) + expect(response).to be_success + expect(Nokogiri::HTML(response.body).at_css('.graded_count').text).to match(/0 out of 1/) end it "should show student view student submission as needing grading" do @@ -71,8 +71,8 @@ describe "assignments" do get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success - Nokogiri::HTML(response.body).at_css('.graded_count').text.should match(/0 out of 1/) + expect(response).to be_success + expect(Nokogiri::HTML(response.body).at_css('.graded_count').text).to match(/0 out of 1/) end describe "due date overrides" do @@ -90,8 +90,8 @@ describe "assignments" do get "courses/#{@course.id}/assignments/#{@assignment.id}" doc = Nokogiri::HTML(response.body) - doc.css(".assignment_dates").text.should include "Everyone" - doc.css(".assignment_dates").text.should_not include "Everyone else" + expect(doc.css(".assignment_dates").text).to include "Everyone" + expect(doc.css(".assignment_dates").text).not_to include "Everyone else" end it "should show 'Everyone else' when some sections have due date overrides" do @@ -101,7 +101,7 @@ describe "assignments" do get "courses/#{@course.id}/assignments/#{@assignment.id}" doc = Nokogiri::HTML(response.body) - doc.css(".assignment_dates").text.should include "Everyone else" + expect(doc.css(".assignment_dates").text).to include "Everyone else" end it "should not show 'Everyone else' when all sections have due date overrides" do @@ -112,7 +112,7 @@ describe "assignments" do get "courses/#{@course.id}/assignments/#{@assignment.id}" doc = Nokogiri::HTML(response.body) - doc.css(".assignment_dates").text.should_not include "Everyone" + expect(doc.css(".assignment_dates").text).not_to include "Everyone" end end end @@ -139,20 +139,20 @@ describe "download submissions link" do it "should not show download submissions button with no submissions" do get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#download_submission_button').should be_nil + expect(doc.at_css('#download_submission_button')).to be_nil end it "should show download submissions button with submission not graded" do @submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url') - @submission.state.should eql(:submitted) + expect(@submission.state).to eql(:submitted) @submission.save! get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#download_submission_button').should_not be_nil + expect(doc.at_css('#download_submission_button')).not_to be_nil end it "should show download submissions button with a submission graded" do @@ -161,13 +161,13 @@ describe "download submissions link" do @submission.grade_it @submission.score = 5 @submission.save! - @submission.state.should eql(:graded) + expect(@submission.state).to eql(:graded) @submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url') @submission2.save! get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#download_submission_button').should_not be_nil + expect(doc.at_css('#download_submission_button')).not_to be_nil end it "should show download submissions button with all submissions graded" do @@ -176,28 +176,28 @@ describe "download submissions link" do @submission.grade_it @submission.score = 5 @submission.save! - @submission.state.should eql(:graded) + expect(@submission.state).to eql(:graded) @submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url') @submission2.grade_it @submission2.score = 5 @submission2.save! - @submission2.state.should eql(:graded) + expect(@submission2.state).to eql(:graded) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#download_submission_button').should_not be_nil + expect(doc.at_css('#download_submission_button')).not_to be_nil end it "should not show download submissions button to students" do @submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url') - @submission.state.should eql(:submitted) + expect(@submission.state).to eql(:submitted) @submission.save! user_session(@student) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#download_submission_button').should be_nil + expect(doc.at_css('#download_submission_button')).to be_nil end end @@ -224,23 +224,23 @@ describe "ratio of submissions graded" do it "should not show ratio of submissions graded with no submissions" do get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#ratio_of_submissions_graded').should be_nil + expect(doc.at_css('#ratio_of_submissions_graded')).to be_nil end it "should show ratio of submissions graded with submission not graded" do @submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url') @submission.save! - @submission.state.should eql(:submitted) + expect(@submission.state).to eql(:submitted) @submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url') - @submission2.state.should eql(:submitted) + expect(@submission2.state).to eql(:submitted) @submission2.save! get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#ratio_of_submissions_graded').text.strip.should == "0 out of 2 Submissions Graded" + expect(doc.at_css('#ratio_of_submissions_graded').text.strip).to eq "0 out of 2 Submissions Graded" end it "should show ratio of submissions graded with a submission graded" do @@ -249,14 +249,14 @@ describe "ratio of submissions graded" do @submission.grade_it @submission.score = 5 @submission.save! - @submission.state.should eql(:graded) + expect(@submission.state).to eql(:graded) @submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url') - @submission2.state.should eql(:submitted) + expect(@submission2.state).to eql(:submitted) @submission2.save! get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#ratio_of_submissions_graded').text.strip.should == "1 out of 2 Submissions Graded" + expect(doc.at_css('#ratio_of_submissions_graded').text.strip).to eq "1 out of 2 Submissions Graded" end it "should show ratio of submissions graded with all submissions graded" do @@ -266,28 +266,28 @@ describe "ratio of submissions graded" do @submission.grade_it @submission.score = 5 @submission.save! - @submission.state.should eql(:graded) + expect(@submission.state).to eql(:graded) @submission2 = Submission.new(:assignment => @assignment, :user => @student2, :submission_type => 'online_url') @submission2.grade_it @submission2.score = 5 @submission2.save! - @submission2.state.should eql(:graded) + expect(@submission2.state).to eql(:graded) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#ratio_of_submissions_graded').text.strip.should == "2 out of 2 Submissions Graded" + expect(doc.at_css('#ratio_of_submissions_graded').text.strip).to eq "2 out of 2 Submissions Graded" end it "should not show ratio of submissions graded to students" do @submission = Submission.new(:assignment => @assignment, :user => @student, :submission_type => 'online_url') - @submission.state.should eql(:submitted) + expect(@submission.state).to eql(:submitted) @submission.save! user_session(@student) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('#ratio_of_submissions_graded').should be_nil + expect(doc.at_css('#ratio_of_submissions_graded')).to be_nil end end diff --git a/spec/integration/collaborations_spec.rb b/spec/integration/collaborations_spec.rb index 71558a82f82..aacd9674f9c 100644 --- a/spec/integration/collaborations_spec.rb +++ b/spec/integration/collaborations_spec.rb @@ -35,19 +35,19 @@ describe CollaborationsController, type: :request do ) get "/courses/#{@course.id}/collaborations/" - response.should be_success + expect(response).to be_success post "/courses/#{@course.id}/collaborations/", { :collaboration => { :collaboration_type => "EtherPad", :title => "My Collab" } } - response.should be_redirect + expect(response).to be_redirect get "/courses/#{@course.id}/collaborations/" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) links = html.css("div.collaboration_#{Collaboration.last.id} a.collaborator_link") - links.count.should == 1 + expect(links.count).to eq 1 link = links.first - link.attr("href").should == "/courses/#{@course.id}/users/#{@teacher.id}" - link.text.should == "teacher 1" + expect(link.attr("href")).to eq "/courses/#{@course.id}/users/#{@teacher.id}" + expect(link.text).to eq "teacher 1" end end diff --git a/spec/integration/concluded_unconcluded_spec.rb b/spec/integration/concluded_unconcluded_spec.rb index dbed476c0ed..b6d5120a3de 100644 --- a/spec/integration/concluded_unconcluded_spec.rb +++ b/spec/integration/concluded_unconcluded_spec.rb @@ -39,76 +39,76 @@ describe "concluded/unconcluded courses" do @group = @course.assignment_groups.create!(:name => "default") @assignment = @course.assignments.create!(:submission_types => 'online_quiz', :title => 'quiz assignment', :assignment_group => @group) @quiz = @assignment.reload.quiz - @quiz.should_not be_nil + expect(@quiz).not_to be_nil @qsub = Quizzes::SubmissionManager.new(@quiz).find_or_create_submission(@student) @qsub.quiz_data = [{:correct_comments=>"", :assessment_question_id=>nil, :incorrect_comments=>"", :question_name=>"Question 1", :points_possible=>1, :question_text=>"Which book(s) are required for this course?", :name=>"Question 1", :id=>128, :answers=>[{:weight=>0, :text=>"A", :comments=>"", :id=>1490}, {:weight=>0, :text=>"B", :comments=>"", :id=>1020}, {:weight=>0, :text=>"C", :comments=>"", :id=>7051}], :question_type=>"multiple_choice_question"}] @qsub.submission_data = [{:points=>0, :text=>"7051", :question_id=>128, :correct=>false, :answer_id=>7051}] @qsub.workflow_state = 'complete' @qsub.save! @sub = @qsub.submission - @sub.should_not be_nil + expect(@sub).not_to be_nil end it "should let the teacher change grades in the speed grader by default" do get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#add_a_comment').length.should == 1 - html.css('#grade_container').length.should == 1 + expect(html.css('#add_a_comment').length).to eq 1 + expect(html.css('#grade_container').length).to eq 1 end it "should not let the teacher change grades in the speed grader when concluded" do @e.conclude get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#add_a_comment').length.should == 0 - html.css('#grade_container').length.should == 0 + expect(html.css('#add_a_comment').length).to eq 0 + expect(html.css('#grade_container').length).to eq 0 end it "should let the teacher change grades on the submission details page by default" do get "/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.submission_details .grading_box').length.should == 1 - html.css('#add_comment_form').length.should == 1 + expect(html.css('.submission_details .grading_box').length).to eq 1 + expect(html.css('#add_comment_form').length).to eq 1 end it "should not let the teacher change grades on the submission details page when concluded" do @e.conclude get "/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.submission_details .grading_box').length.should == 0 - html.css('#add_comment_form')[0]['style'].should match(/display: none/) + expect(html.css('.submission_details .grading_box').length).to eq 0 + expect(html.css('#add_comment_form')[0]['style']).to match(/display: none/) end it "should let the teacher change quiz submission scores by default" do get "/courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@qsub.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#fudge_points_entry').length.should == 1 - html.css('.quiz_comment textarea').length.should == 1 - html.css('.user_points .question_input').length.should == 1 + expect(html.css('#fudge_points_entry').length).to eq 1 + expect(html.css('.quiz_comment textarea').length).to eq 1 + expect(html.css('.user_points .question_input').length).to eq 1 end it "should not let the teacher change quiz submission scores when concluded" do @e.conclude get "/courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@qsub.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#fudge_points_entry').length.should == 0 - html.css('.quiz_comment textarea').length.should == 0 - html.css('.user_points .question_input').length.should == 0 + expect(html.css('#fudge_points_entry').length).to eq 0 + expect(html.css('.quiz_comment textarea').length).to eq 0 + expect(html.css('.user_points .question_input').length).to eq 0 end end diff --git a/spec/integration/conferences_spec.rb b/spec/integration/conferences_spec.rb index edd367ee94d..a1affa404d6 100644 --- a/spec/integration/conferences_spec.rb +++ b/spec/integration/conferences_spec.rb @@ -34,15 +34,15 @@ describe ConferencesController, type: :request do @student2.register! post "/courses/#{@course.id}/conferences", { :web_conference => {"duration"=>"60", "conference_type"=>"Wimba", "title"=>"let's chat", "description"=>""}, :user => { "all" => "1" } } - response.should be_redirect + expect(response).to be_redirect @conference = WebConference.first - Set.new(Message.all.map(&:user)).should == Set.new([@teacher, @student1, @student2]) + expect(Set.new(Message.all.map(&:user))).to eq Set.new([@teacher, @student1, @student2]) @student3 = student_in_course(:active_all => true, :user => user_with_pseudonym(:username => "student3@example.com")).user @student3.register! put "/courses/#{@course.id}/conferences/#{@conference.id}", { :web_conference => { "title" => "moar" }, :user => { @student3.id => '1' } } - response.should be_redirect - Set.new(Message.all.map(&:user)).should == Set.new([@teacher, @student1, @student2, @student3]) + expect(response).to be_redirect + expect(Set.new(Message.all.map(&:user))).to eq Set.new([@teacher, @student1, @student2, @student3]) end it "should find the correct conferences for group news feed" do @@ -56,8 +56,8 @@ describe ConferencesController, type: :request do group_conference.add_initiator(@user) get "/courses/#{@course.id}/groups/#{@group.id}" - response.should be_success - assigns['current_conferences'].map(&:id).should == [group_conference.id] + expect(response).to be_success + expect(assigns['current_conferences'].map(&:id)).to eq [group_conference.id] end it "shouldn't show concluded users" do @@ -71,14 +71,14 @@ describe ConferencesController, type: :request do @student2 = @enroll2.user @student2.register! - @enroll1.attributes['workflow_state'].should == 'active' - @enroll2.attributes['workflow_state'].should == 'active' + expect(@enroll1.attributes['workflow_state']).to eq 'active' + expect(@enroll2.attributes['workflow_state']).to eq 'active' @enroll2.update_attributes('workflow_state' => 'completed') - @enroll2.attributes['workflow_state'].should == 'completed' + expect(@enroll2.attributes['workflow_state']).to eq 'completed' get "/courses/#{@course.id}/conferences" - assigns['users'].member?(@teacher).should be_false - assigns['users'].member?(@student1).should be_true - assigns['users'].member?(@student2).should be_false + expect(assigns['users'].member?(@teacher)).to be_falsey + expect(assigns['users'].member?(@student1)).to be_truthy + expect(assigns['users'].member?(@student2)).to be_falsey end end diff --git a/spec/integration/content_zipper_spec.rb b/spec/integration/content_zipper_spec.rb index 7ec6542fbdb..aab4b611e9d 100644 --- a/spec/integration/content_zipper_spec.rb +++ b/spec/integration/content_zipper_spec.rb @@ -8,17 +8,17 @@ describe ContentZipper do # This really needs to get refactored at some point. def grab_zip expect { yield }.to change(Delayed::Job, :count).by(1) - response.should be_success + expect(response).to be_success attachment_id = json_parse['attachment']['id'] - attachment_id.should be_present + expect(attachment_id).to be_present a = Attachment.find attachment_id - a.should be_to_be_zipped + expect(a).to be_to_be_zipped # a second query should just return status expect { yield }.to change(Delayed::Job, :count).by(0) - response.should be_success - json_parse['attachment']['id'].should == a.id + expect(response).to be_success + expect(json_parse['attachment']['id']).to eq a.id end context "submission zips" do diff --git a/spec/integration/context_module_spec.rb b/spec/integration/context_module_spec.rb index 9e8cb65d4e4..057ccbe968e 100644 --- a/spec/integration/context_module_spec.rb +++ b/spec/integration/context_module_spec.rb @@ -29,14 +29,14 @@ describe ContextModule do course_with_teacher_logged_in active_all: true get "/courses/#{@course.id}/modules" doc = Nokogiri::HTML(response.body) - doc.at_css('.context-modules-main-toolbar .add_module_link').should_not be_nil + expect(doc.at_css('.context-modules-main-toolbar .add_module_link')).not_to be_nil @course.account.role_overrides.create! enrollment_type: 'TaEnrollment', permission: 'manage_content', enabled: false course_with_ta course: @course user_session(@ta) get "/courses/#{@course.id}/modules" doc = Nokogiri::HTML(response.body) - doc.at_css('.context-modules-main-toolbar .add_module_link').should be_nil + expect(doc.at_css('.context-modules-main-toolbar .add_module_link')).to be_nil end end @@ -47,12 +47,12 @@ describe ContextModule do content_tag = context_module.add_item :type => 'context_module_sub_header', :title => "My Sub Header Title" ContextModule.where(:id => context_module).update_all(:updated_at => 1.hour.ago) get "/courses/#{@course.id}/modules" - response.body.should match(/My Sub Header Title/) + expect(response.body).to match(/My Sub Header Title/) content_tag.update_attributes(:title => "My New Title") get "/courses/#{@course.id}/modules" - response.body.should match(/My New Title/) + expect(response.body).to match(/My New Title/) end end @@ -68,14 +68,14 @@ describe ContextModule do @module.save! @progression = @module.evaluate_for(@user) - @progression.should_not be_nil - @progression.should_not be_completed - @progression.should be_unlocked - @progression.current_position.should eql(@tag.position) + expect(@progression).not_to be_nil + expect(@progression).not_to be_completed + expect(@progression).to be_unlocked + expect(@progression.current_position).to eql(@tag.position) yield @progression = @module.evaluate_for(@user) - @progression.should be_completed - @progression.current_position.should eql(@tag.position) + expect(@progression).to be_completed + expect(@progression.current_position).to eql(@tag.position) end it "should progress for discussions" do @@ -83,7 +83,7 @@ describe ContextModule do @tag = @module.add_item(:type => 'discussion_topic', :id => @discussion.id) before_after do post "/courses/#{@course.id}/discussion_entries", :discussion_entry => { :message => 'ohai', :discussion_topic_id => @discussion.id } - response.should be_redirect + expect(response).to be_redirect end end @@ -92,7 +92,7 @@ describe ContextModule do @tag = @module.add_item(:type => 'wiki_page', :id => @page.id) before_after do put "/courses/#{@course.id}/wiki/#{@page.url}", :wiki_page => { :body => 'i agree', :title => 'talk page' } - response.should be_redirect + expect(response).to be_redirect end end @@ -101,7 +101,7 @@ describe ContextModule do @tag = @module.add_item(:type => 'assignment', :id => @assignment.id) before_after do post "/courses/#{@course.id}/discussion_entries", :discussion_entry => { :message => 'ohai', :discussion_topic_id => @assignment.discussion_topic.id } - response.should be_redirect + expect(response).to be_redirect end end end @@ -131,23 +131,23 @@ describe ContextModule do end # all modules, tags, etc need to be published - @mod1.should be_published - @mod2.should be_published - @quiz.should be_published - @tag1.should be_published + expect(@mod1).to be_published + expect(@mod2).to be_published + expect(@quiz).to be_published + expect(@tag1).to be_published yield '
yay!
' - @tag2.should be_published + expect(@tag2).to be_published # verify the second item is locked (doesn't display) get @test_url - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#test_content').length.should == (@test_content_length || 0) + expect(html.css('#test_content').length).to eq(@test_content_length || 0) # complete first module's requirements p1 = @mod1.evaluate_for(@student) - p1.workflow_state.should == 'unlocked' + expect(p1.workflow_state).to eq 'unlocked' @quiz_submission = @quiz.generate_submission(@student) Quizzes::SubmissionGrader.new(@quiz_submission).grade_submission @@ -161,17 +161,17 @@ describe ContextModule do "/courses/#{@course.id}/modules/items/#{@tag2.id}" : "/courses/#{@course.id}/modules/#{@mod2.id}/items/first" get next_link - response.should be_redirect - response.location.ends_with?(@test_url + "?module_item_id=#{@tag2.id}").should be_true + expect(response).to be_redirect + expect(response.location.ends_with?(@test_url + "?module_item_id=#{@tag2.id}")).to be_truthy # verify the second item is accessible get @test_url - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) if @is_attachment - html.at_css('#file_content')['src'].should =~ %r{#{@test_url}} + expect(html.at_css('#file_content')['src']).to match %r{#{@test_url}} else - html.css('#test_content').length.should == 1 + expect(html.css('#test_content').length).to eq 1 end end end @@ -182,7 +182,7 @@ describe ContextModule do asmnt = @course.assignments.create!(:title => 'assignment', :description => content) @test_url = "/courses/#{@course.id}/assignments/#{asmnt.id}" @tag2 = @mod2.add_item(:type => 'assignment', :id => asmnt.id) - @tag2.should be_published + expect(@tag2).to be_published end end end @@ -193,7 +193,7 @@ describe ContextModule do discussion = @course.discussion_topics.create!(:title => "topic", :message => content) @test_url = "/courses/#{@course.id}/discussion_topics/#{discussion.id}" @tag2 = @mod2.add_item(:type => 'discussion_topic', :id => discussion.id) - @tag2.should be_published + expect(@tag2).to be_published @test_content_length = 1 end end @@ -206,7 +206,7 @@ describe ContextModule do quiz.publish! @test_url = "/courses/#{@course.id}/quizzes/#{quiz.id}" @tag2 = @mod2.add_item(:type => 'quiz', :id => quiz.id) - @tag2.should be_published + expect(@tag2).to be_published end end end @@ -217,7 +217,7 @@ describe ContextModule do page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => content) @test_url = "/courses/#{@course.id}/wiki/#{page.url}" @tag2 = @mod2.add_item(:type => 'wiki_page', :id => page.id) - @tag2.should be_published + expect(@tag2).to be_published end end end @@ -229,7 +229,7 @@ describe ContextModule do att = Attachment.create!(:filename => 'test.html', :display_name => "test.html", :uploaded_data => StringIO.new(content), :folder => Folder.unfiled_folder(@course), :context => @course) @test_url = "/courses/#{@course.id}/files/#{att.id}" @tag2 = @mod2.add_item(:type => 'attachment', :id => att.id) - @tag2.should be_published + expect(@tag2).to be_published end end end @@ -255,16 +255,16 @@ describe ContextModule do user_session teacher1 get "/courses/#{@course.id}/modules" - response.should be_success + expect(response).to be_success body1 = Nokogiri::HTML(response.body) user_session teacher2 get "/courses/#{@course.id}/modules" - response.should be_success + expect(response).to be_success body2 = Nokogiri::HTML(response.body) - body1.at_css("#context_module_content_#{mod.id} .unlock_details").text.should =~ /4am/ - body2.at_css("#context_module_content_#{mod.id} .unlock_details").text.should =~ /7am/ + expect(body1.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /4am/ + expect(body2.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /7am/ end end end diff --git a/spec/integration/course_spec.rb b/spec/integration/course_spec.rb index 64726cafcb6..cc43a6fd95f 100644 --- a/spec/integration/course_spec.rb +++ b/spec/integration/course_spec.rb @@ -26,14 +26,14 @@ describe "course" do course(:active_all => true) @course.update_attribute(:is_public, true) get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success end it "should load syllabus on public course with no user logged in" do course(:active_all => true) @course.update_attribute(:is_public, true) get "/courses/#{@course.id}/assignments/syllabus" - response.should be_success + expect(response).to be_success end it "should show the migration-in-progress notice" do @@ -46,15 +46,15 @@ describe "course" do migration.update_attribute(:workflow_state, 'importing') get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success body = Nokogiri::HTML(response.body) - body.css('div.import-in-progress-notice').should_not be_empty + expect(body.css('div.import-in-progress-notice')).not_to be_empty migration.update_attribute(:workflow_state, 'imported') get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success body = Nokogiri::HTML(response.body) - body.css('div.import-in-progress-notice').should be_empty + expect(body.css('div.import-in-progress-notice')).to be_empty end end @@ -69,9 +69,9 @@ describe "course" do migration.update_attribute(:workflow_state, 'importing') get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success body = Nokogiri::HTML(response.body) - body.css('div.import-in-progress-notice').should be_empty + expect(body.css('div.import-in-progress-notice')).to be_empty end end end diff --git a/spec/integration/course_wizard_spec.rb b/spec/integration/course_wizard_spec.rb index af05487ed04..cb225499ca0 100644 --- a/spec/integration/course_wizard_spec.rb +++ b/spec/integration/course_wizard_spec.rb @@ -32,7 +32,7 @@ describe CoursesController, type: :request do @course.reload user_session(ta) get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success # We do a page load before the test because something during the first load # will touch the course, invalidating the cache anyway and making this test @@ -41,16 +41,16 @@ describe CoursesController, type: :request do original_course_updated_at = @course.reload.updated_at get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success page = Nokogiri::HTML(response.body) - page.css(".wizard_options_list li.publish_step").length.should == 0 + expect(page.css(".wizard_options_list li.publish_step").length).to eq 0 user_session(teacher) get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success page = Nokogiri::HTML(response.body) - page.css(".wizard_options_list li.publish_step").length.should == 1 - @course.reload.updated_at.should == original_course_updated_at + expect(page.css(".wizard_options_list li.publish_step").length).to eq 1 + expect(@course.reload.updated_at).to eq original_course_updated_at end end end diff --git a/spec/integration/cross_listing_spec.rb b/spec/integration/cross_listing_spec.rb index 8d03d8e8bd4..4eed7e00db8 100644 --- a/spec/integration/cross_listing_spec.rb +++ b/spec/integration/cross_listing_spec.rb @@ -54,7 +54,7 @@ describe "cross listing" do "X1,S2,active", "C4,S3,active") - CommunicationChannel.find_by_path('u1@example.com').user.cached_current_enrollments.map(&:course).map(&:sis_source_id).sort.should == ["C1", "X1", "C4"].sort + expect(CommunicationChannel.find_by_path('u1@example.com').user.cached_current_enrollments.map(&:course).map(&:sis_source_id).sort).to eq ["C1", "X1", "C4"].sort end end diff --git a/spec/integration/discussion_topics_spec.rb b/spec/integration/discussion_topics_spec.rb index b6b3391fb4b..12f596e98e4 100644 --- a/spec/integration/discussion_topics_spec.rb +++ b/spec/integration/discussion_topics_spec.rb @@ -30,13 +30,13 @@ describe "discussion_topics" do @group.users << @user get "/groups/#{@group.id}/discussion_topics/#{@topic.id}" - response.should be_success + expect(response).to be_success post "/groups/#{@group.id}/discussion_entries", :discussion_entry => { :discussion_topic_id => @topic.id, :message => "frist!!1" } - response.should be_redirect + expect(response).to be_redirect get "/groups/#{@group.id}/discussion_topics/#{@topic.id}" - response.should be_success + expect(response).to be_success end it "should show speed grader button" do @@ -44,9 +44,9 @@ describe "discussion_topics" do discussion_assignment get "/courses/#{@course.id}/discussion_topics/#{@topic.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('.admin-links .icon-speed-grader').should_not be_nil + expect(doc.at_css('.admin-links .icon-speed-grader')).not_to be_nil end it "should show peer reviews button" do @@ -56,9 +56,9 @@ describe "discussion_topics" do @assignment.save get "/courses/#{@course.id}/discussion_topics/#{@topic.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::XML(response.body) - doc.at_css('.admin-links .icon-peer-review').should_not be_nil + expect(doc.at_css('.admin-links .icon-peer-review')).not_to be_nil end end diff --git a/spec/integration/enrollment_date_restrictions_spec.rb b/spec/integration/enrollment_date_restrictions_spec.rb index fb4ca16582f..8f1adcc6509 100644 --- a/spec/integration/enrollment_date_restrictions_spec.rb +++ b/spec/integration/enrollment_date_restrictions_spec.rb @@ -28,28 +28,28 @@ describe "enrollment_date_restrictions" do @course.update_attributes(:start_at => 2.days.from_now, :conclude_at => 4.days.from_now, :restrict_enrollments_to_course_dates => true) e2 = student_in_course(:user => @student, :active_all => 1) - e1.state.should == :active - e1.state_based_on_date.should == :active - e2.state.should == :active - e2.state_based_on_date.should == :inactive + expect(e1.state).to eq :active + expect(e1.state_based_on_date).to eq :active + expect(e2.state).to eq :active + expect(e2.state_based_on_date).to eq :inactive user_session(@student, @pseudonym) get "/" page = Nokogiri::HTML(response.body) list = page.css(".menu-item-drop-column-list li") - list.length.should == 1 - list[0].text.should match /Course 1/ - page.css(".menu-item-drop-padded").should be_empty + expect(list.length).to eq 1 + expect(list[0].text).to match /Course 1/ + expect(page.css(".menu-item-drop-padded")).to be_empty get "/courses" page = Nokogiri::HTML(response.body) active_enrollments = page.css(".current_enrollments tr") - active_enrollments.length.should == 1 + expect(active_enrollments.length).to eq 1 # Make sure that the active coures have the star column. - active_enrollments[0].css('td')[0]['class'].should match /star-column/ + expect(active_enrollments[0].css('td')[0]['class']).to match /star-column/ - page.css(".past_enrollments tr").should be_empty + expect(page.css(".past_enrollments tr")).to be_empty end it "should not show deleted enrollments in past enrollments when course is completed" do @@ -57,16 +57,16 @@ describe "enrollment_date_restrictions" do e1 = student_in_course(:user => @student, :active_all => 1) e1.destroy - e1.workflow_state.should == 'deleted' + expect(e1.workflow_state).to eq 'deleted' @course.complete - @course.workflow_state.should == 'completed' + expect(@course.workflow_state).to eq 'completed' user_session(@student, @pseudonym) get "/courses" page = Nokogiri::HTML(response.body) - page.css(".past_enrollments tr").should be_empty + expect(page.css(".past_enrollments tr")).to be_empty end it "should not list groups from inactive enrollments in the menu" do @@ -90,10 +90,10 @@ describe "enrollment_date_restrictions" do list = page.css(".menu-item-drop-column-list li").to_a # course lis are still there and view all groups should always show up when # there's at least one 'visible' group - list.size.should == 3 - list.select{ |li| li.text =~ /Group 1/ }.should_not be_empty - list.select{ |li| li.text =~ /View all groups/ }.should_not be_empty - list.select{ |li| li.text =~ /Group 2/ }.should be_empty + expect(list.size).to eq 3 + expect(list.select{ |li| li.text =~ /Group 1/ }).not_to be_empty + expect(list.select{ |li| li.text =~ /View all groups/ }).not_to be_empty + expect(list.select{ |li| li.text =~ /Group 2/ }).to be_empty end it "should not show date inactive/completed courses in grades" do @@ -121,13 +121,13 @@ describe "enrollment_date_restrictions" do get '/grades' html = Nokogiri::HTML(response.body) - html.css('.course').length.should == 2 + expect(html.css('.course').length).to eq 2 Account.default.account_users.create!(user: @user) get "/users/#{@user.id}" - response.body.should match /Inactive/ - response.body.should match /Completed/ - response.body.should match /Active/ + expect(response.body).to match /Inactive/ + expect(response.body).to match /Completed/ + expect(response.body).to match /Active/ end it "should not included date-inactive courses when searching for pertinent contexts" do @@ -139,10 +139,10 @@ describe "enrollment_date_restrictions" do @course.conclude_at = 4.days.from_now @course.restrict_enrollments_to_course_dates = true @course.save! - @enrollment.reload.state_based_on_date.should == :inactive + expect(@enrollment.reload.state_based_on_date).to eq :inactive get '/calendar2' html = Nokogiri::HTML(response.body) - html.css(".group_course_#{@course.id}").length.should == 0 + expect(html.css(".group_course_#{@course.id}").length).to eq 0 end end diff --git a/spec/integration/external_tools_spec.rb b/spec/integration/external_tools_spec.rb index 41732e33a80..906771859cd 100644 --- a/spec/integration/external_tools_spec.rb +++ b/spec/integration/external_tools_spec.rb @@ -33,18 +33,18 @@ describe "External Tools" do student_in_course(:course => @course, :active_all => true) user_session(@user) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) form = doc.at_css('form#tool_form') - form.at_css('input#launch_presentation_locale')['value'].should == 'en' - form.at_css('input#oauth_callback')['value'].should == 'about:blank' - form.at_css('input#oauth_signature_method')['value'].should == 'HMAC-SHA1' - form.at_css('input#launch_presentation_return_url')['value'].should == "http://www.example.com/external_content/success/external_tool_redirect" - form.at_css('input#lti_message_type')['value'].should == "basic-lti-launch-request" - form.at_css('input#lti_version')['value'].should == "LTI-1p0" - form.at_css('input#oauth_version')['value'].should == "1.0" - form.at_css('input#roles')['value'].should == "Learner" + expect(form.at_css('input#launch_presentation_locale')['value']).to eq 'en' + expect(form.at_css('input#oauth_callback')['value']).to eq 'about:blank' + expect(form.at_css('input#oauth_signature_method')['value']).to eq 'HMAC-SHA1' + expect(form.at_css('input#launch_presentation_return_url')['value']).to eq "http://www.example.com/external_content/success/external_tool_redirect" + expect(form.at_css('input#lti_message_type')['value']).to eq "basic-lti-launch-request" + expect(form.at_css('input#lti_version')['value']).to eq "LTI-1p0" + expect(form.at_css('input#oauth_version')['value']).to eq "1.0" + expect(form.at_css('input#roles')['value']).to eq "Learner" end it "should include outcome service params when viewing as student" do @@ -54,22 +54,22 @@ describe "External Tools" do payload = [@tool.id, @course.id, @assignment.id, @user.id].join('-') get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) - doc.at_css('form#tool_form input#lis_result_sourcedid')['value'].should == "#{payload}-some_sha" - doc.at_css('form#tool_form input#lis_outcome_service_url')['value'].should == lti_grade_passback_api_url(@tool) - doc.at_css('form#tool_form input#ext_ims_lis_basic_outcome_url')['value'].should == blti_legacy_grade_passback_api_url(@tool) + expect(doc.at_css('form#tool_form input#lis_result_sourcedid')['value']).to eq "#{payload}-some_sha" + expect(doc.at_css('form#tool_form input#lis_outcome_service_url')['value']).to eq lti_grade_passback_api_url(@tool) + expect(doc.at_css('form#tool_form input#ext_ims_lis_basic_outcome_url')['value']).to eq blti_legacy_grade_passback_api_url(@tool) end it "should not include outcome service sourcedid when viewing as teacher" do @course.enroll_teacher(user(:active_all => true)) user_session(@user) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) - doc.at_css('form#tool_form input#lis_result_sourcedid').should be_nil - doc.at_css('form#tool_form input#lis_outcome_service_url').should_not be_nil + expect(doc.at_css('form#tool_form input#lis_result_sourcedid')).to be_nil + expect(doc.at_css('form#tool_form input#lis_outcome_service_url')).not_to be_nil end it "should include time zone in LTI paramaters if included in custom fields" do @@ -85,17 +85,17 @@ describe "External Tools" do account.save! get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) - doc.at_css('form#tool_form input#custom_time_zone')['value'].should == "America/Juneau" + expect(doc.at_css('form#tool_form input#custom_time_zone')['value']).to eq "America/Juneau" @user.time_zone = "Hawaii" @user.save! get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) - doc.at_css('form#tool_form input#custom_time_zone')['value'].should == "Pacific/Honolulu" + expect(doc.at_css('form#tool_form input#custom_time_zone')['value']).to eq "Pacific/Honolulu" end it "should redirect if the tool can't be configured" do @@ -104,18 +104,18 @@ describe "External Tools" do student_in_course(:active_all => true) user_session(@user) get "/courses/#{@course.id}/assignments/#{@assignment.id}" - response.should redirect_to(course_url(@course)) - flash[:error].should be_present + expect(response).to redirect_to(course_url(@course)) + expect(flash[:error]).to be_present end it "should render inline external tool links with a full return url" do student_in_course(:active_all => true) user_session(@user) get "/courses/#{@course.id}/external_tools/retrieve?url=#{CGI.escape(@tag.url)}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) - doc.at_css('#tool_form').should_not be_nil - doc.at_css("input[name='launch_presentation_return_url']")['value'].should match(/^http/) + expect(doc.at_css('#tool_form')).not_to be_nil + expect(doc.at_css("input[name='launch_presentation_return_url']")['value']).to match(/^http/) end it "should render user navigation tools with a full return url" do @@ -126,10 +126,10 @@ describe "External Tools" do student_in_course(:active_all => true) user_session(@user) get "/users/#{@user.id}/external_tools/#{tool.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) - doc.at_css('#tool_form').should_not be_nil - doc.at_css("input[name='launch_presentation_return_url']")['value'].should match(/^http/) + expect(doc.at_css('#tool_form')).not_to be_nil + expect(doc.at_css("input[name='launch_presentation_return_url']")['value']).to match(/^http/) end end @@ -142,11 +142,11 @@ describe "External Tools" do @tool.save! get "/courses/#{@course.id}/external_tools/#{@tool.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) tab = doc.at_css("a.#{@tool.asset_string}") - tab.should_not be_nil - tab['class'].split.should include("active") + expect(tab).not_to be_nil + expect(tab['class'].split).to include("active") end it "should highlight the navigation tab when using an external tool" do @@ -157,11 +157,11 @@ describe "External Tools" do @tool.save! get "/courses/#{@course.id}/external_tools/#{@tool.id}" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) tab = doc.at_css("a.#{@tool.asset_string}") - tab.should_not be_nil - tab['class'].split.should include("active") + expect(tab).not_to be_nil + expect(tab['class'].split).to include("active") end context 'global navigation' do @@ -178,33 +178,33 @@ describe "External Tools" do it "should show the admin level global navigation menu items to teachers" do course_with_teacher_logged_in(:account => @account, :active_all => true) get "/courses" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) menu_link1 = doc.at_css("##{@admin_tool.asset_string}_menu_item a") - menu_link1.should_not be_nil - menu_link1['href'].should == account_external_tool_path(Account.default, @admin_tool, :launch_type => 'global_navigation') - menu_link1.text.should match_ignoring_whitespace(@admin_tool.label_for(:global_navigation)) + expect(menu_link1).not_to be_nil + expect(menu_link1['href']).to eq account_external_tool_path(Account.default, @admin_tool, :launch_type => 'global_navigation') + expect(menu_link1.text).to match_ignoring_whitespace(@admin_tool.label_for(:global_navigation)) menu_link2 = doc.at_css("##{@member_tool.asset_string}_menu_item a") - menu_link2.should_not be_nil - menu_link2['href'].should == account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation') - menu_link2.text.should match_ignoring_whitespace(@member_tool.label_for(:global_navigation)) + expect(menu_link2).not_to be_nil + expect(menu_link2['href']).to eq account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation') + expect(menu_link2.text).to match_ignoring_whitespace(@member_tool.label_for(:global_navigation)) end it "should only show the member level global navigation menu items to students" do course_with_student_logged_in(:account => @account, :active_all => true) get "/courses" - response.should be_success + expect(response).to be_success doc = Nokogiri::HTML.parse(response.body) menu_link1 = doc.at_css("##{@admin_tool.asset_string}_menu_item a") - menu_link1.should be_nil + expect(menu_link1).to be_nil menu_link2 = doc.at_css("##{@member_tool.asset_string}_menu_item a") - menu_link2.should_not be_nil - menu_link2['href'].should == account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation') - menu_link2.text.should match_ignoring_whitespace(@member_tool.label_for(:global_navigation)) + expect(menu_link2).not_to be_nil + expect(menu_link2['href']).to eq account_external_tool_path(Account.default, @member_tool, :launch_type => 'global_navigation') + expect(menu_link2.text).to match_ignoring_whitespace(@member_tool.label_for(:global_navigation)) end end end diff --git a/spec/integration/files_spec.rb b/spec/integration/files_spec.rb index ad4c5e7029f..5b94bd6ff78 100644 --- a/spec/integration/files_spec.rb +++ b/spec/integration/files_spec.rb @@ -15,30 +15,30 @@ describe FilesController do it "with safefiles" do HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/files/#{@submission.attachment.id}/download", :inline => '1', :verifier => @submission.attachment.uuid - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'files-test.host' - uri.path.should == "/files/#{@submission.attachment.id}/download" - @me.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true - qs['verifier'].should == @submission.attachment.uuid + expect(uri.host).to eq 'files-test.host' + expect(uri.path).to eq "/files/#{@submission.attachment.id}/download" + expect(@me.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy + expect(qs['verifier']).to eq @submission.attachment.uuid location = response['Location'] reset! get location - response.should be_success - response.content_type.should == 'image/png' + expect(response).to be_success + expect(response.content_type).to eq 'image/png' # ensure that the user wasn't logged in by the normal means - controller.instance_variable_get(:@current_user).should be_nil + expect(controller.instance_variable_get(:@current_user)).to be_nil end it "without safefiles" do HostUrl.stubs(:file_host_with_shard).returns(['test.host', Shard.default]) get "http://test.host/files/#{@submission.attachment.id}/download", :inline => '1', :verifier => @submission.attachment.uuid - response.should be_success - response.content_type.should == 'image/png' - response['Pragma'].should be_nil - response['Cache-Control'].should_not match(/no-cache/) + expect(response).to be_success + expect(response.content_type).to eq 'image/png' + expect(response['Pragma']).to be_nil + expect(response['Cache-Control']).not_to match(/no-cache/) end end @@ -54,30 +54,30 @@ describe FilesController do it "with safefiles" do HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/users/#{@me.id}/files/#{@att.id}/download" - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'files-test.host' + expect(uri.host).to eq 'files-test.host' # redirects to a relative url, since relative files are available in user context - uri.path.should == "/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/my-pic.png" - @me.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true + expect(uri.path).to eq "/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/my-pic.png" + expect(@me.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy location = response['Location'] reset! get location - response.should be_success - response.content_type.should == 'image/png' + expect(response).to be_success + expect(response.content_type).to eq 'image/png' # ensure that the user wasn't logged in by the normal means - controller.instance_variable_get(:@current_user).should be_nil + expect(controller.instance_variable_get(:@current_user)).to be_nil end it "without safefiles" do HostUrl.stubs(:file_host).returns('test.host') get "http://test.host/users/#{@me.id}/files/#{@att.id}/download" - response.should be_success - response.content_type.should == 'image/png' - response['Pragma'].should be_nil - response['Cache-Control'].should_not match(/no-cache/) + expect(response).to be_success + expect(response.content_type).to eq 'image/png' + expect(response['Pragma']).to be_nil + expect(response['Cache-Control']).not_to match(/no-cache/) end context "with inlineable html files" do @@ -88,39 +88,39 @@ describe FilesController do it "with safefiles" do HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/users/#{@me.id}/files/#{@att.id}/download", :wrap => '1' - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'test.host' - uri.path.should == "/users/#{@me.id}/files/#{@att.id}" + expect(uri.host).to eq 'test.host' + expect(uri.path).to eq "/users/#{@me.id}/files/#{@att.id}" location = response['Location'] get location # the response will be on the main domain, with an iframe pointing to the files domain and the actual uploaded html file - response.should be_success - response.content_type.should == 'text/html' + expect(response).to be_success + expect(response.content_type).to eq 'text/html' doc = Nokogiri::HTML::DocumentFragment.parse(response.body) - doc.at_css('iframe#file_content')['src'].should =~ %r{^http://files-test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html} + expect(doc.at_css('iframe#file_content')['src']).to match %r{^http://files-test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html} end it "without safefiles" do HostUrl.stubs(:file_host_with_shard).returns(['test.host', Shard.default]) get "http://test.host/users/#{@me.id}/files/#{@att.id}/download", :wrap => '1' - response.should be_redirect + expect(response).to be_redirect location = response['Location'] - URI.parse(location).path.should == "/users/#{@me.id}/files/#{@att.id}" + expect(URI.parse(location).path).to eq "/users/#{@me.id}/files/#{@att.id}" get location - response.content_type.should == 'text/html' + expect(response.content_type).to eq 'text/html' doc = Nokogiri::HTML::DocumentFragment.parse(response.body) - doc.at_css('iframe#file_content')['src'].should =~ %r{^http://test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html} + expect(doc.at_css('iframe#file_content')['src']).to match %r{^http://test.host/users/#{@me.id}/files/#{@att.id}/my%20files/unfiled/ohai.html} end it "should not inline the file if passed download_frd param" do HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/users/#{@me.id}/files/#{@att.id}/download?download_frd=1&verifier=#{@att.uuid}" - response.should be_redirect + expect(response).to be_redirect get response['Location'] - response.headers['Content-Disposition'].should match /attachment/ + expect(response.headers['Content-Disposition']).to match /attachment/ end end @@ -133,43 +133,43 @@ describe FilesController do a1 = attachment_model(:uploaded_data => stub_png_data, :content_type => 'image/png', :context => @course) HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/courses/#{@course.id}/files/#{a1.id}/download", :inline => '1' - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'files-test.host' - uri.path.should == "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png" - @user.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true - qs['verifier'].should be_nil + expect(uri.host).to eq 'files-test.host' + expect(uri.path).to eq "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png" + expect(@user.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy + expect(qs['verifier']).to be_nil location = response['Location'] reset! get location - response.should be_success - response.content_type.should == 'image/png' + expect(response).to be_success + expect(response.content_type).to eq 'image/png' # ensure that the user wasn't logged in by the normal means - controller.instance_variable_get(:@current_user).should be_nil + expect(controller.instance_variable_get(:@current_user)).to be_nil end - + it "should be able to use verifier in course context" do course_with_teacher(:active_all => true, :user => user_with_pseudonym) a1 = attachment_model(:uploaded_data => stub_png_data, :content_type => 'image/png', :context => @course) HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/courses/#{@course.id}/files/#{a1.id}/download?verifier=#{a1.uuid}" - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'files-test.host' - uri.path.should == "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png" - qs['verifier'].should == a1.uuid + expect(uri.host).to eq 'files-test.host' + expect(uri.path).to eq "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png" + expect(qs['verifier']).to eq a1.uuid location = response['Location'] reset! get location - response.should be_success - response.content_type.should == 'image/png' + expect(response).to be_success + expect(response.content_type).to eq 'image/png' # ensure that the user wasn't logged in by the normal means - controller.instance_variable_get(:@current_user).should be_nil + expect(controller.instance_variable_get(:@current_user)).to be_nil end it "should be able to directly download in course context preview links with verifier" do @@ -177,21 +177,21 @@ describe FilesController do a1 = attachment_model(:uploaded_data => stub_png_data, :content_type => 'image/png', :context => @course) HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/courses/#{@course.id}/files/#{a1.id}/preview?verifier=#{a1.uuid}" - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'files-test.host' - uri.path.should == "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png" - qs['verifier'].should == a1.uuid + expect(uri.host).to eq 'files-test.host' + expect(uri.path).to eq "/courses/#{@course.id}/files/#{a1.id}/course%20files/test%20my%20file%3F%20hai!%26.png" + expect(qs['verifier']).to eq a1.uuid location = response['Location'] reset! get location - response.should be_success - response.content_type.should == 'image/png' + expect(response).to be_success + expect(response.content_type).to eq 'image/png' # ensure that the user wasn't logged in by the normal means - controller.instance_variable_get(:@current_user).should be_nil + expect(controller.instance_variable_get(:@current_user)).to be_nil end it "should update module progressions for html safefiles iframe" do @@ -207,12 +207,12 @@ describe FilesController do hash[@tag.id.to_s] = {:type => 'must_view'} @module.completion_requirements = hash @module.save! - @module.evaluate_for(@user).state.should eql(:unlocked) + expect(@module.evaluate_for(@user).state).to eql(:unlocked) # the response will be on the main domain, with an iframe pointing to the files domain and the actual uploaded html file get "http://test.host/courses/#{@course.id}/files/#{@att.id}" - response.should be_success - response.content_type.should == 'text/html' + expect(response).to be_success + expect(response.content_type).to eq 'text/html' doc = Nokogiri::HTML::DocumentFragment.parse(response.body) location = doc.at_css('iframe#file_content')['src'] @@ -220,8 +220,8 @@ describe FilesController do # and verify the module progress was recorded reset! get location - response.should be_success - @module.evaluate_for(@user).state.should eql(:completed) + expect(response).to be_success + expect(@module.evaluate_for(@user).state).to eql(:completed) end context "should support AssessmentQuestion as a context" do @@ -237,28 +237,28 @@ describe FilesController do def do_with_safefiles_test(url) HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get url - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'files-test.host' - uri.path.should == "/files/#{@att.id}/download" - @user.valid_access_verifier?(qs['ts'], qs['sf_verifier']).should be_true - qs['verifier'].should == @att.uuid + expect(uri.host).to eq 'files-test.host' + expect(uri.path).to eq "/files/#{@att.id}/download" + expect(@user.valid_access_verifier?(qs['ts'], qs['sf_verifier'])).to be_truthy + expect(qs['verifier']).to eq @att.uuid location = response['Location'] reset! get location - response.should be_success - response.content_type.should == 'image/png' + expect(response).to be_success + expect(response.content_type).to eq 'image/png' # ensure that the user wasn't logged in by the normal means - controller.instance_variable_get(:@current_user).should be_nil + expect(controller.instance_variable_get(:@current_user)).to be_nil end context "with safefiles" do it "with new url style" do do_with_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/#{@att.uuid}") end - + it "with old url style" do do_with_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/download?verifier=#{@att.uuid}") end @@ -267,17 +267,17 @@ describe FilesController do def do_without_safefiles_test(url) HostUrl.stubs(:file_host).returns('test.host') get url - response.should be_success - response.content_type.should == 'image/png' - response['Pragma'].should be_nil - response['Cache-Control'].should_not match(/no-cache/) + expect(response).to be_success + expect(response.content_type).to eq 'image/png' + expect(response['Pragma']).to be_nil + expect(response['Cache-Control']).not_to match(/no-cache/) end context "without safefiles" do it "with new url style" do do_without_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/#{@att.uuid}") end - + it "with old url style" do do_without_safefiles_test("http://test.host/assessment_questions/#{@aq.id}/files/#{@att.id}/download?verifier=#{@att.uuid}") end @@ -290,21 +290,21 @@ describe FilesController do @submission.save! HostUrl.stubs(:file_host_with_shard).returns(['files-test.host', Shard.default]) get "http://test.host/users/#{@submission.user.id}/files/#{@submission.attachment.id}/download", :verifier => @submission.attachment.uuid - - response.should be_redirect + + expect(response).to be_redirect uri = URI.parse response['Location'] qs = Rack::Utils.parse_nested_query(uri.query) - uri.host.should == 'files-test.host' - uri.path.should == "/files/#{@submission.attachment.id}/download" - qs['verifier'].should == @submission.attachment.uuid + expect(uri.host).to eq 'files-test.host' + expect(uri.path).to eq "/files/#{@submission.attachment.id}/download" + expect(qs['verifier']).to eq @submission.attachment.uuid location = response['Location'] reset! get location - response.should be_success - response.content_type.should == 'image/png' - controller.instance_variable_get(:@current_user).should be_nil - controller.instance_variable_get(:@context).should be_nil + expect(response).to be_success + expect(response.content_type).to eq 'image/png' + expect(controller.instance_variable_get(:@current_user)).to be_nil + expect(controller.instance_variable_get(:@context)).to be_nil end it "shouldn't use relative urls for safefiles in other contexts" do @@ -318,17 +318,17 @@ describe FilesController do @attachment.any_instantiation.expects(:create_or_update_thumbnail).with(anything, sz, sz).returns { @attachment.thumbnails.create!(:thumbnail => "640x>", :uploaded_data => stub_png_data) } get "/images/thumbnails/#{@attachment.id}/#{@attachment.uuid}?size=640x#{URI.encode '>'}" thumb = @attachment.thumbnails.find_by_thumbnail("640x>") - response.should redirect_to(thumb.authenticated_s3_url) + expect(response).to redirect_to(thumb.authenticated_s3_url) end - + it "should reorder files" do course_with_teacher_logged_in(:active_all => true, :user => user_with_pseudonym) att1 = attachment_model(:uploaded_data => stub_png_data, :context => @course) att2 = attachment_model(:uploaded_data => stub_png_data("file2.png"), :context => @course) - + post "/courses/#{@course.id}/files/reorder", {:order => "#{att2.id}, #{att1.id}", :folder_id => @folder.id} - response.should be_success - - @folder.file_attachments.by_position_then_display_name.should == [att2, att1] + expect(response).to be_success + + expect(@folder.file_attachments.by_position_then_display_name).to eq [att2, att1] end end diff --git a/spec/integration/groups_spec.rb b/spec/integration/groups_spec.rb index 1c3a947f3f9..e90b7503e09 100644 --- a/spec/integration/groups_spec.rb +++ b/spec/integration/groups_spec.rb @@ -25,10 +25,10 @@ describe GroupsController do @group = Group.create!(:name => "group1", :group_category => group_category, :context => @course) get "/courses/#{@course.id}/groups/#{@group.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('#right-side a.add').attribute("href").text.should == "/groups/#{@group.id}/announcements#new" + expect(html.css('#right-side a.add').attribute("href").text).to eq "/groups/#{@group.id}/announcements#new" end it "should not rendering 'pending' page when joining a self-signup group" do @@ -40,7 +40,7 @@ describe GroupsController do g1 = @course.groups.create!(:name => "some group", :group_category => category1) get "/courses/#{@course.id}/groups/#{g1.id}?join=1" - response.body.should_not =~ /This group has received your request to join/ + expect(response.body).not_to match /This group has received your request to join/ end end @@ -49,6 +49,6 @@ describe GroupsController do group = Account.default.groups.create!(name: 'SIS imported') get "/groups/#{group.id}" - response.should be_success + expect(response).to be_success end end diff --git a/spec/integration/hair_trigger_spec.rb b/spec/integration/hair_trigger_spec.rb index f117410d8d3..4a4ce2a5a62 100644 --- a/spec/integration/hair_trigger_spec.rb +++ b/spec/integration/hair_trigger_spec.rb @@ -21,7 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "hair_trigger" do describe "migrations" do it "should be current for all models" do - HairTrigger::migrations_current?.should be_true + expect(HairTrigger::migrations_current?).to be_truthy end end end \ No newline at end of file diff --git a/spec/integration/info_controller_spec.rb b/spec/integration/info_controller_spec.rb index 44fb8cf28fb..d0511e056bc 100644 --- a/spec/integration/info_controller_spec.rb +++ b/spec/integration/info_controller_spec.rb @@ -25,17 +25,17 @@ describe InfoController do enable_cache do user get "/images/users/#{@user.id}" - response.should be_redirect - response['Location'].should match(%r{gravatar}) - response['Location'].should match(%r{avatar-50}) + expect(response).to be_redirect + expect(response['Location']).to match(%r{gravatar}) + expect(response['Location']).to match(%r{avatar-50}) @user.avatar_image = { 'type' => 'attachment', 'url' => '/images/thumbnails/blah' } @user.save! get "/images/users/#{@user.id}" - response.should be_redirect - response['Location'].should_not match(%r{gravatar}) - response['Location'].should match(%r{/images/thumbnails/blah}) + expect(response).to be_redirect + expect(response['Location']).not_to match(%r{gravatar}) + expect(response['Location']).to match(%r{/images/thumbnails/blah}) end end end diff --git a/spec/integration/locale_selection_spec.rb b/spec/integration/locale_selection_spec.rb index 22e59cd1e92..5fb08334526 100644 --- a/spec/integration/locale_selection_spec.rb +++ b/spec/integration/locale_selection_spec.rb @@ -33,16 +33,16 @@ describe "locale_selection" do @user.update_attribute :locale, 'es' @pseudonym.reload get dashboard_url - response.should be_success - I18n.locale.should eql(:es) + expect(response).to be_success + expect(I18n.locale).to eql(:es) end it "should set the locale when not authenticated" do account = Account.default account.update_attribute :default_locale, 'fr' get login_url - response.should be_success - I18n.locale.should eql(:fr) + expect(response).to be_success + expect(I18n.locale).to eql(:fr) end end diff --git a/spec/integration/navigation_spec.rb b/spec/integration/navigation_spec.rb index df59bc90a69..55ca282029f 100644 --- a/spec/integration/navigation_spec.rb +++ b/spec/integration/navigation_spec.rb @@ -39,11 +39,11 @@ describe "navigation" do list = page.css(".menu-item-drop-column-list li") # order of tests assumes alphabetical order of list - list[4].text.should match /Summer Term/m # course 3, Summer Term - list[3].text.should match /Spring Term/m # course 3, Spring Term - list[2].text.should match /Spring Term/ # don't show term cause it doesn't have a name collision - list[1].text.should_not match /Term/ # don't show term cause it's the default term - list[0].text.should_not match /Term/ # " + expect(list[4].text).to match /Summer Term/m # course 3, Summer Term + expect(list[3].text).to match /Spring Term/m # course 3, Spring Term + expect(list[2].text).to match /Spring Term/ # don't show term cause it doesn't have a name collision + expect(list[1].text).not_to match /Term/ # don't show term cause it's the default term + expect(list[0].text).not_to match /Term/ # " end it "should not fail on courses where the term no longer exists" do @@ -56,7 +56,7 @@ describe "navigation" do course_with_teacher :course_name => "Course of doom", :user => @user, :active_all => true get '/' page = Nokogiri::HTML(response.body) - page.css('.customListOpen').should_not be_empty + expect(page.css('.customListOpen')).not_to be_empty end end diff --git a/spec/integration/oauth_token_spec.rb b/spec/integration/oauth_token_spec.rb index 9accea4dc56..75430ef7be6 100644 --- a/spec/integration/oauth_token_spec.rb +++ b/spec/integration/oauth_token_spec.rb @@ -45,21 +45,21 @@ describe integration do it "should error if the service isn't enabled" do UsersController.any_instance.expects(:feature_and_service_enabled?).with(integration.underscore).returns(false) get "/oauth?service=#{integration.underscore}" - response.should redirect_to(user_profile_url(@user)) - flash[:error].should be_present + expect(response).to redirect_to(user_profile_url(@user)) + expect(flash[:error]).to be_present end it "should redirect to the service for auth" do oauth_start(integration) - response.should redirect_to("http://oauth.example.com/start") + expect(response).to redirect_to("http://oauth.example.com/start") oreq = OauthRequest.last - oreq.should be_present - oreq.service.should == integration.underscore - oreq.token.should == "test_token" - oreq.secret.should == "test_secret" - oreq.user.should == @user - oreq.return_url.should == user_profile_url(@user) + expect(oreq).to be_present + expect(oreq.service).to eq integration.underscore + expect(oreq.token).to eq "test_token" + expect(oreq.secret).to eq "test_secret" + expect(oreq.user).to eq @user + expect(oreq.return_url).to eq user_profile_url(@user) end describe "oauth_success" do @@ -76,20 +76,20 @@ describe integration do it "should fail without a valid token" do get "/oauth_success?service=#{integration.underscore}&oauth_token=wrong&oauth_verifier=test_verifier" - response.should redirect_to(user_profile_url(@user)) - flash[:error].should be_present + expect(response).to redirect_to(user_profile_url(@user)) + expect(flash[:error]).to be_present end it "should fail with the wrong user" do OauthRequest.last.update_attribute(:user, User.create!) get "/oauth_success?service=#{integration.underscore}&oauth_token=test_token&oauth_verifier=test_verifier" - response.should redirect_to(user_profile_url(@user)) - flash[:error].should be_present + expect(response).to redirect_to(user_profile_url(@user)) + expect(flash[:error]).to be_present end it "should redirect to the original host if a different host is returned to" do get "http://otherschool.example.com/oauth_success?service=#{integration.underscore}&oauth_token=test_token&oauth_verifier=test_verifier" - response.should redirect_to("http://www.example.com/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}") + expect(response).to redirect_to("http://www.example.com/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}") end it "should create the UserService on successful auth" do @@ -108,15 +108,15 @@ describe integration do end get "/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}" - response.should redirect_to(user_profile_url(@user)) - flash[:error].should be_blank - flash[:notice].should be_present + expect(response).to redirect_to(user_profile_url(@user)) + expect(flash[:error]).to be_blank + expect(flash[:notice]).to be_present us = UserService.find_by_service_and_user_id(integration.underscore, @user.id) - us.should be_present - us.service_user_id.should == "test_user_id" - us.service_user_name.should == "test_user_name" - us.token.should == "test_token" - us.secret.should == "test_secret" + expect(us).to be_present + expect(us.service_user_id).to eq "test_user_id" + expect(us.service_user_name).to eq "test_user_name" + expect(us.token).to eq "test_token" + expect(us.secret).to eq "test_secret" end it "should fail creating the UserService if getting the initial user info fails" do @@ -137,11 +137,11 @@ describe integration do end get "/oauth_success?oauth_token=test_token&oauth_verifier=test_verifier&service=#{integration.underscore}" - response.should redirect_to(user_profile_url(@user)) - flash[:error].should be_present - flash[:notice].should be_blank + expect(response).to redirect_to(user_profile_url(@user)) + expect(flash[:error]).to be_present + expect(flash[:notice]).to be_blank us = UserService.find_by_service_and_user_id(integration.underscore, @user.id) - us.should_not be_present + expect(us).not_to be_present end end end diff --git a/spec/integration/otp_spec.rb b/spec/integration/otp_spec.rb index f2cf6fd655b..c438def8091 100644 --- a/spec/integration/otp_spec.rb +++ b/spec/integration/otp_spec.rb @@ -30,21 +30,21 @@ describe "one time passwords" do context "mid-login" do before do post '/login', :pseudonym_session => { :unique_id => @pseudonym.unique_id, :password => 'qwerty' } - response.should render_template('otp_login') + expect(response).to render_template('otp_login') end it "should not allow access to the rest of canvas" do get '/' - response.should redirect_to login_url + expect(response).to redirect_to login_url follow_redirect! - response.should be_success + expect(response).to be_success end it "should not allow re-enrolling" do get '/login/otp' - response.should redirect_to login_url + expect(response).to redirect_to login_url follow_redirect! - response.should be_success + expect(response).to be_success end end end diff --git a/spec/integration/page_view_spec.rb b/spec/integration/page_view_spec.rb index 759afbe9aac..7879c900101 100644 --- a/spec/integration/page_view_spec.rb +++ b/spec/integration/page_view_spec.rb @@ -28,12 +28,12 @@ describe "page views" do @topic = @course.discussion_topics.create! post "/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}/entries", :message => 'hello' - response.should be_success + expect(response).to be_success pv = PageView.last - pv.context.should == @course - pv.controller.should == 'discussion_topics_api' - pv.action.should == 'add_entry' + expect(pv.context).to eq @course + expect(pv.controller).to eq 'discussion_topics_api' + expect(pv.action).to eq 'add_entry' end end diff --git a/spec/integration/profile_spec.rb b/spec/integration/profile_spec.rb index 73aa16f9ca4..954e6fc7048 100644 --- a/spec/integration/profile_spec.rb +++ b/spec/integration/profile_spec.rb @@ -28,22 +28,22 @@ describe ProfileController do user_session(u, p) get '/profile/settings' - Nokogiri::HTML(response.body).css('input#user_short_name').should_not be_empty + expect(Nokogiri::HTML(response.body).css('input#user_short_name')).not_to be_empty put '/profile', :user => { :short_name => 'Cody' } - response.should be_redirect - u.reload.short_name.should == 'Cody' + expect(response).to be_redirect + expect(u.reload.short_name).to eq 'Cody' a.settings[:users_can_edit_name] = false a.save! p.reload get '/profile/settings' - Nokogiri::HTML(response.body).css('input#user_short_name').should be_empty + expect(Nokogiri::HTML(response.body).css('input#user_short_name')).to be_empty put '/profile', :user => { :short_name => 'JT' } - response.should be_redirect - u.reload.short_name.should == 'Cody' + expect(response).to be_redirect + expect(u.reload.short_name).to eq 'Cody' end it "should not show student view student edit profile or other services options" do diff --git a/spec/integration/pseudonym_sessions_controller_spec.rb b/spec/integration/pseudonym_sessions_controller_spec.rb index 4274d2ac915..23cb17f972f 100644 --- a/spec/integration/pseudonym_sessions_controller_spec.rb +++ b/spec/integration/pseudonym_sessions_controller_spec.rb @@ -22,10 +22,10 @@ describe PseudonymSessionsController do def redirect_until(uri) count = 0 while true - response.should be_redirect + expect(response).to be_redirect return if response.location == uri count += 1 - count.should < 5 + expect(count).to be < 5 follow_redirect! end end @@ -59,11 +59,11 @@ describe PseudonymSessionsController do redirect_until(@cas_client.add_service_to_login_url(cas_login_url)) get cas_login_url :ticket => 'ST-abcd' - response.should redirect_to(dashboard_url(:login_success => 1)) - session[:cas_session].should == 'ST-abcd' + expect(response).to redirect_to(dashboard_url(:login_success => 1)) + expect(session[:cas_session]).to eq 'ST-abcd' delete logout_url - response.should redirect_to(@cas_client.logout_url(cas_login_url)) + expect(response).to redirect_to(@cas_client.logout_url(cas_login_url)) end it "should inform the user CAS validation denied" do @@ -73,8 +73,8 @@ describe PseudonymSessionsController do redirect_until(@cas_client.add_service_to_login_url(cas_login_url)) get cas_login_url :ticket => 'ST-abcd' - response.should redirect_to(cas_login_url :no_auto => true) - flash[:delegated_message].should match(/There was a problem logging in/) + expect(response).to redirect_to(cas_login_url :no_auto => true) + expect(flash[:delegated_message]).to match(/There was a problem logging in/) end it "should inform the user CAS validation failed" do @@ -87,8 +87,8 @@ describe PseudonymSessionsController do redirect_until(@cas_client.add_service_to_login_url(cas_login_url)) get cas_login_url :ticket => 'ST-abcd' - response.should redirect_to(cas_login_url :no_auto => true) - flash[:delegated_message].should match(/There was a problem logging in/) + expect(response).to redirect_to(cas_login_url :no_auto => true) + expect(flash[:delegated_message]).to match(/There was a problem logging in/) end it "should inform the user that CAS account doesn't exist" do @@ -98,9 +98,9 @@ describe PseudonymSessionsController do redirect_until(@cas_client.add_service_to_login_url(cas_login_url)) get cas_login_url :ticket => 'ST-abcd' - response.should redirect_to(cas_login_url(:no_auto => true)) + expect(response).to redirect_to(cas_login_url(:no_auto => true)) get cas_login_url :no_auto => true - flash[:delegated_message].should match(/Canvas doesn't have an account for user/) + expect(flash[:delegated_message]).to match(/Canvas doesn't have an account for user/) end it "should redirect to a custom url if the user CAS account doesn't exist" do @@ -115,7 +115,7 @@ describe PseudonymSessionsController do redirect_until(@cas_client.add_service_to_login_url(cas_login_url)) get cas_login_url :ticket => 'ST-abcd' - response.should redirect_to(redirect_url) + expect(response).to redirect_to(redirect_url) end it "should login case insensitively" do @@ -127,13 +127,13 @@ describe PseudonymSessionsController do redirect_until(@cas_client.add_service_to_login_url(cas_login_url)) get cas_login_url :ticket => 'ST-abcd' - response.should redirect_to(dashboard_url(:login_success => 1)) - session[:cas_session].should == 'ST-abcd' + expect(response).to redirect_to(dashboard_url(:login_success => 1)) + expect(session[:cas_session]).to eq 'ST-abcd' end context "single sign out" do before do - pending "needs redis" unless Canvas.redis_enabled? + skip "needs redis" unless Canvas.redis_enabled? end it "should do a single sign out" do @@ -145,13 +145,13 @@ describe PseudonymSessionsController do redirect_until(@cas_client.add_service_to_login_url(cas_login_url)) get cas_login_url :ticket => 'ST-abcd' - response.should redirect_to(dashboard_url(:login_success => 1)) - session[:cas_session].should == 'ST-abcd' - Canvas.redis.get("cas_session:ST-abcd").should == @pseudonym.global_id.to_s + expect(response).to redirect_to(dashboard_url(:login_success => 1)) + expect(session[:cas_session]).to eq 'ST-abcd' + expect(Canvas.redis.get("cas_session:ST-abcd")).to eq @pseudonym.global_id.to_s # pretend we lost the cache somehow Canvas.redis.del("cas_session:ST-abcd") - Canvas.redis.get("cas_session:ST-abcd").should == nil + expect(Canvas.redis.get("cas_session:ST-abcd")).to eq nil back_channel = open_session # it starts out as a clone of the current session @@ -164,19 +164,19 @@ describe PseudonymSessionsController do ST-abcd SAML - back_channel.response.status.to_i.should == 404 + expect(back_channel.response.status.to_i).to eq 404 # this should refresh it get dashboard_url - response.should be_success - Canvas.redis.get("cas_session:ST-abcd").should == @pseudonym.global_id.to_s + expect(response).to be_success + expect(Canvas.redis.get("cas_session:ST-abcd")).to eq @pseudonym.global_id.to_s # unrelated logout should have no effect back_channel.post cas_logout_url :garbage => 1 - back_channel.response.status.to_i.should == 404 + expect(back_channel.response.status.to_i).to eq 404 back_channel.post cas_logout_url :logoutRequest => "garbage" - back_channel.response.status.to_i.should == 404 + expect(back_channel.response.status.to_i).to eq 404 back_channel.post cas_logout_url :logoutRequest => <<-SAML @@ -184,12 +184,12 @@ describe PseudonymSessionsController do ST-abc SAML - back_channel.response.status.to_i.should == 404 + expect(back_channel.response.status.to_i).to eq 404 # still logged in get dashboard_url - response.should be_success - Canvas.redis.get("cas_session:ST-abcd").should == @pseudonym.global_id.to_s + expect(response).to be_success + expect(Canvas.redis.get("cas_session:ST-abcd")).to eq @pseudonym.global_id.to_s # this time it works back_channel.post cas_logout_url :logoutRequest => <<-SAML @@ -198,8 +198,8 @@ describe PseudonymSessionsController do ST-abcd SAML - back_channel.response.should be_success - Canvas.redis.get("cas_session:ST-abcd").should == nil + expect(back_channel.response).to be_success + expect(Canvas.redis.get("cas_session:ST-abcd")).to eq nil # logged out! get dashboard_url @@ -210,7 +210,7 @@ describe PseudonymSessionsController do context "SAML" do before do - pending("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled + skip("requires SAML extension") unless AccountAuthorizationConfig.saml_enabled end it 'redirects to the discovery page when hitting a deep link while unauthenticated' do @@ -229,9 +229,9 @@ describe PseudonymSessionsController do Account.site_admin.account_users.create!(user: @user) get jobs_url - response.should redirect_to login_url + expect(response).to redirect_to login_url post login_url, :pseudonym_session => { :unique_id => @pseudonym.unique_id, :password => 'qwerty' } - response.should redirect_to jobs_url + expect(response).to redirect_to jobs_url end end diff --git a/spec/integration/quiz_regrading_spec.rb b/spec/integration/quiz_regrading_spec.rb index f94edcc03e8..51470e33a0f 100644 --- a/spec/integration/quiz_regrading_spec.rb +++ b/spec/integration/quiz_regrading_spec.rb @@ -38,7 +38,7 @@ describe "QuizRegrading" do course_with_student_logged_in(active_all: true) quiz_model(course: @course) @regrade = @quiz.quiz_regrades.where(quiz_id: @quiz.id, quiz_version: @quiz.version_number).first_or_create(user: @student) - @regrade.should_not be_new_record + expect(@regrade).not_to be_new_record @true_false_question = create_quiz_question!({ :points_possible => 1, :question_type => 'true_false_question', @@ -76,13 +76,13 @@ describe "QuizRegrading" do @submission = @quiz.generate_submission(@student) reset_submission_data! @submission.save! - @submission.score.should == 0.5 + expect(@submission.score).to eq 0.5 end it 'succesfully regrades the submissions and updates the scores' do set_regrade_option!('full_credit') Quizzes::QuizRegrader::Regrader.regrade!(quiz: @quiz) - @submission.reload.score.should == 3 + expect(@submission.reload.score).to eq 3 set_regrade_option!('current_correct_only') data = @true_false_question.question_data @@ -102,7 +102,7 @@ describe "QuizRegrading" do @quiz.reload Quizzes::QuizRegrader::Regrader.regrade!(quiz: @quiz) - @submission.reload.score.should == 3 + expect(@submission.reload.score).to eq 3 end it 'does not expose the question names' do @@ -124,10 +124,10 @@ describe "QuizRegrading" do Quizzes::QuizRegrader::Regrader.regrade!(quiz: @quiz) @submission.reload - @quiz.quiz_data[0][:question_name].should == 'foo' - @quiz.quiz_data[1][:question_name].should == 'bar' - @submission.quiz_data[0][:question_name].should == 'Question 1' - @submission.quiz_data[1][:question_name].should == 'Question 2' + expect(@quiz.quiz_data[0][:question_name]).to eq 'foo' + expect(@quiz.quiz_data[1][:question_name]).to eq 'bar' + expect(@submission.quiz_data[0][:question_name]).to eq 'Question 1' + expect(@submission.quiz_data[1][:question_name]).to eq 'Question 2' end end diff --git a/spec/integration/quiz_submissions_spec.rb b/spec/integration/quiz_submissions_spec.rb index 214814ee183..185e6e9c6e2 100644 --- a/spec/integration/quiz_submissions_spec.rb +++ b/spec/integration/quiz_submissions_spec.rb @@ -44,19 +44,19 @@ describe Quizzes::QuizSubmissionsController do def record_answer_1 post "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/#{@qs.id}/record_answer", :question_1 => 'blah', :last_question_id => 1, :validation_token => @qs.validation_token - response.should be_redirect + expect(response).to be_redirect end def backup_answer_1 put "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/backup", :question_1 => 'blah_overridden', :validation_token => @qs.validation_token - response.should be_success + expect(response).to be_success end def record_answer_2 post "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/#{@qs.id}/record_answer", :question_2 => 'M&Ms', :last_question_id => 2, :validation_token => @qs.validation_token - response.should be_redirect + expect(response).to be_redirect end describe "record_answer / backup" do @@ -64,26 +64,26 @@ describe Quizzes::QuizSubmissionsController do @quiz.update_attribute :cant_go_back, true record_answer_1 backup_answer_1 - @qs.reload.submission_data[:question_1].should == 'blah' + expect(@qs.reload.submission_data[:question_1]).to eq 'blah' end it "should allow overwriting answers otherwise" do record_answer_1 backup_answer_1 - @qs.reload.submission_data[:question_1].should == 'blah_overridden' + expect(@qs.reload.submission_data[:question_1]).to eq 'blah_overridden' end it "should redirect back to take quiz if the user loses connection" do get "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/#{@qs.id}/record_answer", :question_1 => 'blah', :last_question_id => 1, :validation_token => @qs.validation_token - response.should be_redirect + expect(response).to be_redirect end end def submit_quiz post "/courses/#{@course.id}/quizzes/#{@quiz.id}/submissions/", :question_1 => 'password', :attempt => 1, :validation_token => @qs.validation_token - response.should be_redirect + expect(response).to be_redirect end describe "submit quiz" do @@ -94,14 +94,14 @@ describe Quizzes::QuizSubmissionsController do record_answer_1 submit_quiz - @qs.reload.submission_data[0][:correct].should be_true + expect(@qs.reload.submission_data[0][:correct]).to be_truthy end it "allows overwriting answers otherwise" do record_answer_1 submit_quiz - @qs.reload.submission_data[0][:correct].should be_false + expect(@qs.reload.submission_data[0][:correct]).to be_falsey end context "with a symbol in an answer" do @@ -109,7 +109,7 @@ describe Quizzes::QuizSubmissionsController do record_answer_2 submit_quiz - @qs.reload.submission_data[1][:correct].should be_true + expect(@qs.reload.submission_data[1][:correct]).to be_truthy end end end diff --git a/spec/integration/quizzes_spec.rb b/spec/integration/quizzes_spec.rb index b2c39c011a9..e3910f85921 100644 --- a/spec/integration/quizzes_spec.rb +++ b/spec/integration/quizzes_spec.rb @@ -30,8 +30,8 @@ describe Quizzes::QuizzesController do get "courses/#{@course.id}/quizzes/#{@quiz.id}" doc = Nokogiri::HTML(response.body) - doc.css(".assignment_dates").text.should include "Everyone" - doc.css(".assignment_dates").text.should_not include "Everyone else" + expect(doc.css(".assignment_dates").text).to include "Everyone" + expect(doc.css(".assignment_dates").text).not_to include "Everyone else" end end @@ -48,14 +48,14 @@ describe Quizzes::QuizzesController do get "courses/#{@course.id}/quizzes/#{@quiz.id}" doc = Nokogiri::HTML(response.body) - doc.css("#quiz_student_details .value").first.text.should include(datetime_string(@due_at)) + expect(doc.css("#quiz_student_details .value").first.text).to include(datetime_string(@due_at)) end it "should show 'Everyone else' when some sections have a due date override" do get "courses/#{@course.id}/quizzes/#{@quiz.id}" doc = Nokogiri::HTML(response.body) - doc.css(".assignment_dates").text.should include "Everyone else" + expect(doc.css(".assignment_dates").text).to include "Everyone else" end end @@ -70,16 +70,16 @@ describe Quizzes::QuizzesController do get "courses/#{@course.id}/quizzes/#{@quiz.id}" doc = Nokogiri::HTML(response.body) - doc.css(".assignment_dates tbody tr").count.should be 2 - doc.css(".assignment_dates tbody tr > td:first-child").text. - should include(datetime_string(@due_at1), datetime_string(@due_at2)) + expect(doc.css(".assignment_dates tbody tr").count).to be 2 + expect(doc.css(".assignment_dates tbody tr > td:first-child").text). + to include(datetime_string(@due_at1), datetime_string(@due_at2)) end it "should not show a date for 'Everyone else'" do get "courses/#{@course.id}/quizzes/#{@quiz.id}" doc = Nokogiri::HTML(response.body) - doc.css(".assignment_dates").text.should_not include "Everyone" + expect(doc.css(".assignment_dates").text).not_to include "Everyone" end end end @@ -89,14 +89,14 @@ describe Quizzes::QuizzesController do @course.large_roster = false @course.save! get "courses/#{@course.id}/quizzes/#{@quiz.id}" - response.body.should match(%r{SpeedGrader}) + expect(response.body).to match(%r{SpeedGrader}) end it "should not link to SpeedGrader when large_roster" do @course.large_roster = true @course.save! get "courses/#{@course.id}/quizzes/#{@quiz.id}" - response.body.should_not match(%r{SpeedGrader}) + expect(response.body).not_to match(%r{SpeedGrader}) end end end @@ -115,7 +115,7 @@ describe Quizzes::QuizzesController do get "courses/#{@course.id}/quizzes/#{@quiz.id}" doc = Nokogiri::HTML(response.body) - doc.css("#not_right_side .take_quiz_button").text.should include "Resume Quiz" + expect(doc.css("#not_right_side .take_quiz_button").text).to include "Resume Quiz" end end @@ -124,7 +124,7 @@ describe Quizzes::QuizzesController do get "courses/#{@course.id}/quizzes/#{@quiz.id}" doc = Nokogiri::HTML(response.body) - doc.css("#right-side .rs-margin-top").text.should_not include "Resume Quiz" + expect(doc.css("#right-side .rs-margin-top").text).not_to include "Resume Quiz" end end end @@ -146,12 +146,12 @@ describe Quizzes::QuizzesController do it "should list the questions needing review" do mkquiz get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}" - response.body.should match(%r{The following questions need review}) - response.body.should_not match(%r{The quiz has changed significantly since this submission was made}) + expect(response.body).to match(%r{The following questions need review}) + expect(response.body).not_to match(%r{The quiz has changed significantly since this submission was made}) doc = Nokogiri::HTML(response.body) needing_review = doc.at_css('#questions_needing_review') - needing_review.should be_present - needing_review.children.css('li a').map { |n| n.text }.should == @quiz.quiz_data.map { |qq| qq['name'] } + expect(needing_review).to be_present + expect(needing_review.children.css('li a').map { |n| n.text }).to eq @quiz.quiz_data.map { |qq| qq['name'] } end it "should display message about the quiz changing significantly" do @@ -161,20 +161,20 @@ describe Quizzes::QuizzesController do @quiz_submission.submission_data.each { |q| q[:correct] = "false" } @quiz_submission.save get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}" - response.body.should_not match(%r{The following questions need review}) - response.body.should match(%r{The quiz has changed significantly since this submission was made}) + expect(response.body).not_to match(%r{The following questions need review}) + expect(response.body).to match(%r{The quiz has changed significantly since this submission was made}) end it "should display both messages" do Quizzes::Quiz.any_instance.stubs(:changed_significantly_since?).returns(true) mkquiz get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}" - response.body.should match(%r{The following questions need review}) - response.body.should match(%r{The quiz has changed significantly since this submission was made}) + expect(response.body).to match(%r{The following questions need review}) + expect(response.body).to match(%r{The quiz has changed significantly since this submission was made}) doc = Nokogiri::HTML(response.body) needing_review = doc.at_css('#questions_needing_review') - needing_review.should be_present - needing_review.children.css('li a').map { |n| n.text }.should == @quiz.quiz_data.map { |qq| qq['name'] } + expect(needing_review).to be_present + expect(needing_review.children.css('li a').map { |n| n.text }).to eq @quiz.quiz_data.map { |qq| qq['name'] } end it "shoudn't show the user's name/email when it's an anonymous submission" do @@ -188,9 +188,9 @@ describe Quizzes::QuizzesController do @student.save! @student.reload get "courses/#{@course.id}/quizzes/#{@quiz.id}/history?quiz_submission_id=#{@quiz_submission.id}" - response.body.should_not match @student.name - response.body.should_not match @student.sortable_name - response.body.should_not match @student.email + expect(response.body).not_to match @student.name + expect(response.body).not_to match @student.sortable_name + expect(response.body).not_to match @student.email end end end diff --git a/spec/integration/security_spec.rb b/spec/integration/security_spec.rb index ca945175ca5..2b1c7731bcd 100644 --- a/spec/integration/security_spec.rb +++ b/spec/integration/security_spec.rb @@ -32,18 +32,18 @@ describe "security" do get_via_redirect "/login" assert_response :success cookie = cookies['_normandy_session'] - cookie.should be_present - path.should == "/login" + expect(cookie).to be_present + expect(path).to eq "/login" post_via_redirect "/login", "pseudonym_session[unique_id]" => "nobody@example.com", "pseudonym_session[password]" => "asdfasdf", "pseudonym_session[remember_me]" => "1", "redirect_to_ssl" => "1" assert_response :success - request.fullpath.should eql("/?login_success=1") + expect(request.fullpath).to eql("/?login_success=1") new_cookie = cookies['_normandy_session'] - new_cookie.should be_present - cookie.should_not eql(new_cookie) + expect(new_cookie).to be_present + expect(cookie).not_to eql(new_cookie) end end @@ -58,15 +58,15 @@ describe "security" do get "/courses/#{@course.to_param}/users" assert_response :success - RoleOverride.send(:instance_variable_get, '@cached_permissions').should_not be_empty - RoleOverride.send(:class_variable_get, '@@role_override_chain').should_not be_empty + expect(RoleOverride.send(:instance_variable_get, '@cached_permissions')).not_to be_empty + expect(RoleOverride.send(:class_variable_get, '@@role_override_chain')).not_to be_empty get "/dashboard" assert_response 301 # verify the cache is emptied on every request - RoleOverride.send(:instance_variable_get, '@cached_permissions').should be_empty - RoleOverride.send(:class_variable_get, '@@role_override_chain').should be_empty + expect(RoleOverride.send(:instance_variable_get, '@cached_permissions')).to be_empty + expect(RoleOverride.send(:class_variable_get, '@@role_override_chain')).to be_empty end end @@ -86,7 +86,7 @@ describe "security" do "pseudonym_session[password]" => "asdfasdf" assert_response 302 c = response['Set-Cookie'].lines.grep(/\A_normandy_session=/).first - c.should_not match(/expires=/) + expect(c).not_to match(/expires=/) reset! https! post "/login", "pseudonym_session[unique_id]" => "nobody@example.com", @@ -94,7 +94,7 @@ describe "security" do "pseudonym_session[remember_me]" => "1" assert_response 302 c = response['Set-Cookie'].lines.grep(/\A_normandy_session=/).first - c.should_not match(/expires=/) + expect(c).not_to match(/expires=/) end it "should not return pseudonym_credentials when not remember_me" do @@ -108,8 +108,8 @@ describe "security" do assert_response 302 c1 = response['Set-Cookie'].lines.grep(/\Apseudonym_credentials=/).first c2 = response['Set-Cookie'].lines.grep(/\A_normandy_session=/).first - c1.should_not be_present - c2.should be_present + expect(c1).not_to be_present + expect(c2).to be_present end end @@ -121,35 +121,35 @@ describe "security" do post "/login", { "pseudonym_session[unique_id]" => "nobody@example.com", "pseudonym_session[password]" => "asdfasdf", "pseudonym_session[remember_me]" => "1" }, { 'HTTP_ACCEPT' => 'application/json' } - response.should be_success - response['Content-Type'].should match(%r"^application/json") - response.body.should_not match(%r{^while\(1\);}) + expect(response).to be_success + expect(response['Content-Type']).to match(%r"^application/json") + expect(response.body).not_to match(%r{^while\(1\);}) json = JSON.parse response.body - json['pseudonym']['unique_id'].should == "nobody@example.com" + expect(json['pseudonym']['unique_id']).to eq "nobody@example.com" end it "should prepend GET JSON responses with protection" do course_with_teacher_logged_in get "/courses.json" - response.should be_success - response['Content-Type'].should match(%r"^application/json") - response.body.should match(%r{^while\(1\);}) + expect(response).to be_success + expect(response['Content-Type']).to match(%r"^application/json") + expect(response.body).to match(%r{^while\(1\);}) end it "should not prepend GET JSON responses to Accept application/json requests with protection" do course_with_teacher_logged_in get "/courses.json", nil, { 'HTTP_ACCEPT' => 'application/json' } - response.should be_success - response['Content-Type'].should match(%r"^application/json") - response.body.should_not match(%r{^while\(1\);}) + expect(response).to be_success + expect(response['Content-Type']).to match(%r"^application/json") + expect(response.body).not_to match(%r{^while\(1\);}) end it "should not prepend non-GET JSON responses with protection" do course_with_teacher_logged_in delete "/dashboard/ignore_stream_item/1" - response.should be_success - response['Content-Type'].should match(%r"^application/json") - response.body.should_not match(%r{^while\(1\);}) + expect(response).to be_success + expect(response['Content-Type']).to match(%r"^application/json") + expect(response.body).not_to match(%r{^while\(1\);}) end describe "remember me" do @@ -165,67 +165,67 @@ describe "security" do it "should not remember me when the wrong token is given" do # plain persistence_token no longer works get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{@p.persistence_token}" - response.should redirect_to("https://www.example.com/login") + expect(response).to redirect_to("https://www.example.com/login") token = SessionPersistenceToken.generate(@p) # correct token id, but nonsense uuid and persistence_token get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.id}::blah::blah" - response.should redirect_to("https://www.example.com/login") + expect(response).to redirect_to("https://www.example.com/login") # correct token id and persistence_token, but nonsense uuid get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.id}::#{@p.persistence_token}::blah" - response.should redirect_to("https://www.example.com/login") + expect(response).to redirect_to("https://www.example.com/login") end it "should login via persistence token when no session exists" do token = SessionPersistenceToken.generate(@p) get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.pseudonym_credentials}" - response.should be_success - cookies['_normandy_session'].should be_present - session[:used_remember_me_token].should be_true + expect(response).to be_success + expect(cookies['_normandy_session']).to be_present + expect(session[:used_remember_me_token]).to be_truthy # accessing sensitive areas of canvas require a fresh login get "/profile/settings" - response.should redirect_to login_url - flash[:warning].should_not be_empty + expect(response).to redirect_to login_url + expect(flash[:warning]).not_to be_empty post "/login", :pseudonym_session => { :unique_id => @p.unique_id, :password => 'asdfasdf' } - response.should redirect_to settings_profile_url - session[:used_remember_me_token].should_not be_true + expect(response).to redirect_to settings_profile_url + expect(session[:used_remember_me_token]).not_to be_truthy follow_redirect! - response.should be_success + expect(response).to be_success end it "should not allow login via the same valid token twice" do token = SessionPersistenceToken.generate(@p) get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.pseudonym_credentials}" - response.should be_success - SessionPersistenceToken.find_by_id(token.id).should be_nil + expect(response).to be_success + expect(SessionPersistenceToken.find_by_id(token.id)).to be_nil reset! https! get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.pseudonym_credentials}" - response.should redirect_to("https://www.example.com/login") + expect(response).to redirect_to("https://www.example.com/login") end it "should generate a new valid token when a token is used" do token = SessionPersistenceToken.generate(@p) get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.pseudonym_credentials}" - response.should be_success + expect(response).to be_success s1 = cookies['_normandy_session'] - s1.should be_present + expect(s1).to be_present cookie = cookies['pseudonym_credentials'] - cookie.should be_present + expect(cookie).to be_present token2 = SessionPersistenceToken.find_by_pseudonym_credentials(CGI.unescape(cookie)) - token2.should be_present - token2.should_not == token - token2.pseudonym.should == @p + expect(token2).to be_present + expect(token2).not_to eq token + expect(token2.pseudonym).to eq @p reset! https! # check that the new token is valid too get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{cookie}" - response.should be_success + expect(response).to be_success s2 = cookies['_normandy_session'] - s2.should be_present - s2.should_not == s1 + expect(s2).to be_present + expect(s2).not_to eq s1 end it "should generate and return a token when remember_me is checked" do @@ -234,15 +234,15 @@ describe "security" do "pseudonym_session[remember_me]" => "1" assert_response 302 cookie = cookies['pseudonym_credentials'] - cookie.should be_present + expect(cookie).to be_present token = SessionPersistenceToken.find_by_pseudonym_credentials(CGI.unescape(cookie)) - token.should be_present - token.pseudonym.should == @p + expect(token).to be_present + expect(token.pseudonym).to eq @p # verify that the session is now persisting via the session cookie, not # using and re-generating a one-time-use pseudonym_credentials token on each request get "/" - cookies['pseudonym_credentials'].should == cookie + expect(cookies['pseudonym_credentials']).to eq cookie end it "should destroy the token both user agent and server side on logout" do @@ -252,13 +252,13 @@ describe "security" do "pseudonym_session[remember_me]" => "1" }.to change(SessionPersistenceToken, :count).by(1) c = cookies['pseudonym_credentials'] - c.should be_present + expect(c).to be_present expect { delete "/logout" }.to change(SessionPersistenceToken, :count).by(-1) - cookies['pseudonym_credentials'].should_not be_present - SessionPersistenceToken.find_by_pseudonym_credentials(CGI.unescape(c)).should be_nil + expect(cookies['pseudonym_credentials']).not_to be_present + expect(SessionPersistenceToken.find_by_pseudonym_credentials(CGI.unescape(c))).to be_nil end it "should allow multiple remember_me tokens for the same user" do @@ -274,25 +274,25 @@ describe "security" do "pseudonym_session[password]" => "asdfasdf", "pseudonym_session[remember_me]" => "1" c2 = s2.cookies['pseudonym_credentials'] - c1.should_not == c2 + expect(c1).not_to eq c2 s3 = open_session s3.https! s3.get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{c1}" - s3.response.should be_success + expect(s3.response).to be_success s3.delete "/logout" # make sure c2 can still work s4 = open_session s4.https! s4.get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{c2}" - s4.response.should be_success + expect(s4.response).to be_success end it "should not login if the pseudonym is deleted" do token = SessionPersistenceToken.generate(@p) @p.destroy get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.pseudonym_credentials}" - response.should redirect_to("https://www.example.com/login") + expect(response).to redirect_to("https://www.example.com/login") end it "should not login if the pseudonym.persistence_token gets changed (pw change)" do @@ -302,9 +302,9 @@ describe "security" do @p.password = @p.password_confirmation = 'newpass' @p.save! pers2 = @p.persistence_token - pers1.should_not == pers2 + expect(pers1).not_to eq pers2 get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{creds}" - response.should redirect_to("https://www.example.com/login") + expect(response).to redirect_to("https://www.example.com/login") end context "sharding" do @@ -317,9 +317,9 @@ describe "security" do end token = SessionPersistenceToken.generate(@pseudonym) get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.pseudonym_credentials}" - response.should be_success - cookies['_normandy_session'].should be_present - session[:used_remember_me_token].should be_true + expect(response).to be_success + expect(cookies['_normandy_session']).to be_present + expect(session[:used_remember_me_token]).to be_truthy end end end @@ -343,33 +343,33 @@ describe "security" do it "should be limited for the same ip" do bad_login("5.5.5.5") - response.body.should match(/Incorrect username/) + expect(response.body).to match(/Incorrect username/) bad_login("5.5.5.5") - response.body.should match(/Too many failed login attempts/) + expect(response.body).to match(/Too many failed login attempts/) # should still fail post_via_redirect "/login", { "pseudonym_session[unique_id]" => "nobody@example.com", "pseudonym_session[password]" => "asdfasdf" }, { "REMOTE_ADDR" => "5.5.5.5" } - response.body.should match(/Too many failed login attempts/) + expect(response.body).to match(/Too many failed login attempts/) end it "should have a higher limit for other ips" do bad_login("5.5.5.5") - response.body.should match(/Incorrect username/) + expect(response.body).to match(/Incorrect username/) bad_login("5.5.5.6") # different IP, so allowed - response.body.should match(/Incorrect username/) + expect(response.body).to match(/Incorrect username/) bad_login("5.5.5.7") # different IP, but too many total failures - response.body.should match(/Too many failed login attempts/) + expect(response.body).to match(/Too many failed login attempts/) # should still fail post_via_redirect "/login", { "pseudonym_session[unique_id]" => "nobody@example.com", "pseudonym_session[password]" => "asdfasdf" }, { "REMOTE_ADDR" => "5.5.5.7" } - response.body.should match(/Too many failed login attempts/) + expect(response.body).to match(/Too many failed login attempts/) end it "should not block other users with the same ip" do bad_login("5.5.5.5") - response.body.should match(/Incorrect username/) + expect(response.body).to match(/Incorrect username/) # schools like to NAT hundreds of people to the same IP, so we don't # ever block the IP address as a whole @@ -377,7 +377,7 @@ describe "security" do post_via_redirect "/login", { "pseudonym_session[unique_id]" => "second@example.com", "pseudonym_session[password]" => "12341234" }, { "REMOTE_ADDR" => "5.5.5.5" } - request.fullpath.should eql("/?login_success=1") + expect(request.fullpath).to eql("/?login_success=1") end it "should apply limitations correctly for cross-account logins" do @@ -386,16 +386,16 @@ describe "security" do @pseudonym.account = account @pseudonym.save! bad_login("5.5.5.5") - response.body.should match(/Incorrect username/) + expect(response.body).to match(/Incorrect username/) bad_login("5.5.5.6") # different IP, so allowed - response.body.should match(/Incorrect username/) + expect(response.body).to match(/Incorrect username/) bad_login("5.5.5.7") # different IP, but too many total failures - response.body.should match(/Too many failed login attempts/) + expect(response.body).to match(/Too many failed login attempts/) # should still fail post_via_redirect "/login", { "pseudonym_session[unique_id]" => "nobody@example.com", "pseudonym_session[password]" => "asdfasdf" }, { "REMOTE_ADDR" => "5.5.5.5" } - response.body.should match(/Too many failed login attempts/) + expect(response.body).to match(/Too many failed login attempts/) end end end @@ -419,16 +419,16 @@ describe "security" do user_session(@student) post "/courses/#{@course.id}/user_lists.json", :user_list => "A1234567, A345678" - response.should_not be_success + expect(response).not_to be_success user_session(@teacher) post "/courses/#{@course.id}/user_lists.json", :user_list => "A1234567, A345678" assert_response :success - json_parse.should == { + expect(json_parse).to eq({ "duplicates" => [], "errored_users" => [{"address" => "A345678", "details" => "not_found", "type" => "pseudonym"}], "users" => [{ "address" => "A1234567", "name" => "test user", "type" => "pseudonym", "user_id" => u.id }] - } + }) end describe "user masquerading" do @@ -451,29 +451,29 @@ describe "security" do get "/?become_user_id=#{@student.id}" assert_response 302 - response.location.should match "/users/#{@student.id}/masquerade$" - session[:masquerade_return_to].should == "/" - session[:become_user_id].should be_nil - assigns['current_user'].id.should == @admin.id - assigns['real_current_user'].should be_nil + expect(response.location).to match "/users/#{@student.id}/masquerade$" + expect(session[:masquerade_return_to]).to eq "/" + expect(session[:become_user_id]).to be_nil + expect(assigns['current_user'].id).to eq @admin.id + expect(assigns['real_current_user']).to be_nil follow_redirect! assert_response 200 - path.should == "/users/#{@student.id}/masquerade" - session[:become_user_id].should be_nil - assigns['current_user'].id.should == @admin.id - assigns['real_current_user'].should be_nil + expect(path).to eq "/users/#{@student.id}/masquerade" + expect(session[:become_user_id]).to be_nil + expect(assigns['current_user'].id).to eq @admin.id + expect(assigns['real_current_user']).to be_nil post "/users/#{@student.id}/masquerade" assert_response 302 - session[:become_user_id].should == @student.id.to_s + expect(session[:become_user_id]).to eq @student.id.to_s get "/" assert_response 200 - session[:become_user_id].should == @student.id.to_s - assigns['current_user'].id.should == @student.id - assigns['current_pseudonym'].should == @student_pseudonym - assigns['real_current_user'].id.should == @admin.id + expect(session[:become_user_id]).to eq @student.id.to_s + expect(assigns['current_user'].id).to eq @student.id + expect(assigns['current_pseudonym']).to eq @student_pseudonym + expect(assigns['real_current_user'].id).to eq @admin.id end it "should not allow as_user_id for normal requests" do @@ -481,9 +481,9 @@ describe "security" do get "/?as_user_id=#{@student.id}" assert_response 200 - session[:become_user_id].should be_nil - assigns['current_user'].id.should == @admin.id - assigns['real_current_user'].should be_nil + expect(session[:become_user_id]).to be_nil + expect(assigns['current_user'].id).to eq @admin.id + expect(assigns['real_current_user']).to be_nil end it "should not allow non-admins to become other people" do @@ -491,14 +491,14 @@ describe "security" do get "/?become_user_id=#{@teacher.id}" assert_response 200 - session[:become_user_id].should be_nil - assigns['current_user'].id.should == @student.id - assigns['real_current_user'].should be_nil + expect(session[:become_user_id]).to be_nil + expect(assigns['current_user'].id).to eq @student.id + expect(assigns['real_current_user']).to be_nil post "/users/#{@teacher.id}/masquerade" assert_response 401 - assigns['current_user'].id.should == @student.id - session[:become_user_id].should be_nil + expect(assigns['current_user'].id).to eq @student.id + expect(session[:become_user_id]).to be_nil end it "should record real user in page_views" do @@ -507,59 +507,59 @@ describe "security" do get "/?become_user_id=#{@student.id}" assert_response 302 - response.location.should match "/users/#{@student.id}/masquerade$" - session[:masquerade_return_to].should == "/" - session[:become_user_id].should be_nil - assigns['current_user'].id.should == @admin.id - assigns['real_current_user'].should be_nil + expect(response.location).to match "/users/#{@student.id}/masquerade$" + expect(session[:masquerade_return_to]).to eq "/" + expect(session[:become_user_id]).to be_nil + expect(assigns['current_user'].id).to eq @admin.id + expect(assigns['real_current_user']).to be_nil follow_redirect! assert_response 200 - path.should == "/users/#{@student.id}/masquerade" - session[:become_user_id].should be_nil - assigns['current_user'].id.should == @admin.id - assigns['real_current_user'].should be_nil - PageView.last.user_id.should == @admin.id - PageView.last.real_user_id.should be_nil + expect(path).to eq "/users/#{@student.id}/masquerade" + expect(session[:become_user_id]).to be_nil + expect(assigns['current_user'].id).to eq @admin.id + expect(assigns['real_current_user']).to be_nil + expect(PageView.last.user_id).to eq @admin.id + expect(PageView.last.real_user_id).to be_nil post "/users/#{@student.id}/masquerade" assert_response 302 - session[:become_user_id].should == @student.id.to_s + expect(session[:become_user_id]).to eq @student.id.to_s get "/" assert_response 200 - session[:become_user_id].should == @student.id.to_s - assigns['current_user'].id.should == @student.id - assigns['real_current_user'].id.should == @admin.id - PageView.last.user_id.should == @student.id - PageView.last.real_user_id.should == @admin.id + expect(session[:become_user_id]).to eq @student.id.to_s + expect(assigns['current_user'].id).to eq @student.id + expect(assigns['real_current_user'].id).to eq @admin.id + expect(PageView.last.user_id).to eq @student.id + expect(PageView.last.real_user_id).to eq @admin.id end it "should remember the destination with an intervening auth" do token = SessionPersistenceToken.generate(@admin.pseudonyms.first) get "/", {}, "HTTP_COOKIE" => "pseudonym_credentials=#{token.pseudonym_credentials}" - response.should be_success - cookies['_normandy_session'].should be_present - session[:used_remember_me_token].should be_true + expect(response).to be_success + expect(cookies['_normandy_session']).to be_present + expect(session[:used_remember_me_token]).to be_truthy # accessing sensitive areas of canvas require a fresh login get "/conversations?become_user_id=#{@student.id}" - response.should redirect_to user_masquerade_url(@student) + expect(response).to redirect_to user_masquerade_url(@student) follow_redirect! - response.should redirect_to login_url - flash[:warning].should_not be_empty + expect(response).to redirect_to login_url + expect(flash[:warning]).not_to be_empty post "/login", :pseudonym_session => { :unique_id => @admin.pseudonyms.first.unique_id, :password => 'password' } - response.should redirect_to user_masquerade_url(@student) - session[:used_remember_me_token].should_not be_true + expect(response).to redirect_to user_masquerade_url(@student) + expect(session[:used_remember_me_token]).not_to be_truthy post "/users/#{@student.id}/masquerade" - response.should redirect_to conversations_url + expect(response).to redirect_to conversations_url follow_redirect! - response.should be_success - session[:become_user_id].should == @student.id.to_s + expect(response).to be_success + expect(session[:become_user_id]).to eq @student.id.to_s end end @@ -567,13 +567,13 @@ describe "security" do HostUrl.stubs(:is_file_host?).returns(true) HostUrl.stubs(:default_host).returns('test.host') get "http://files-test.host/login" - response.should be_redirect + expect(response).to be_redirect uri = URI.parse response['Location'] - uri.host.should == 'test.host' + expect(uri.host).to eq 'test.host' HostUrl.stubs(:is_file_host?).returns(false) get "http://test.host/login" - response.should be_success + expect(response).to be_success end describe "admin permissions" do @@ -597,8 +597,8 @@ describe "security" do describe "site admin" do it "role_overrides" do get "/accounts/#{Account.site_admin.id}/settings" - response.should be_success - response.body.should_not match /Permissions/ + expect(response).to be_success + expect(response.body).not_to match /Permissions/ get "/accounts/#{Account.site_admin.id}/role_overrides" assert_status(401) @@ -606,11 +606,11 @@ describe "security" do add_permission :manage_role_overrides get "/accounts/#{Account.site_admin.id}/role_overrides" - response.should be_success + expect(response).to be_success get "/accounts/#{Account.site_admin.id}/settings" - response.should be_success - response.body.should match /Permissions/ + expect(response).to be_success + expect(response.body).to match /Permissions/ end end @@ -622,25 +622,25 @@ describe "security" do assert_status(401) get "/accounts/#{Account.default.id}/settings" - response.should be_success - response.body.should_not match /Find A User/ + expect(response).to be_success + expect(response.body).not_to match /Find A User/ get "/accounts/#{Account.default.id}/statistics" - response.should be_success - response.body.should_not match /Recently Logged-In Users/ + expect(response).to be_success + expect(response.body).not_to match /Recently Logged-In Users/ add_permission :read_roster get "/accounts/#{Account.default.id}/users" - response.should be_success + expect(response).to be_success get "/accounts/#{Account.default.id}/settings" - response.should be_success - response.body.should match /Find A User/ + expect(response).to be_success + expect(response.body).to match /Find A User/ get "/accounts/#{Account.default.id}/statistics" - response.should be_success - response.body.should match /Recently Logged-In Users/ + expect(response).to be_success + expect(response.body).to match /Recently Logged-In Users/ end it "read_course_list" do @@ -648,30 +648,30 @@ describe "security" do course get "/accounts/#{Account.default.id}" - response.should be_redirect + expect(response).to be_redirect get "/accounts/#{Account.default.id}/settings" - response.should be_success - response.body.should_not match /Course Filtering/ - response.body.should_not match /Find a Course/ + expect(response).to be_success + expect(response.body).not_to match /Course Filtering/ + expect(response.body).not_to match /Find a Course/ get "/accounts/#{Account.default.id}/statistics" - response.should be_success - response.body.should_not match /Recently Started Courses/ - response.body.should_not match /Recently Ended Courses/ + expect(response).to be_success + expect(response.body).not_to match /Recently Started Courses/ + expect(response.body).not_to match /Recently Ended Courses/ add_permission :read_course_list get "/accounts/#{Account.default.id}" - response.should be_success - response.body.should match /Courses/ - response.body.should match /Course Filtering/ - response.body.should match /Find a Course/ + expect(response).to be_success + expect(response.body).to match /Courses/ + expect(response.body).to match /Course Filtering/ + expect(response.body).to match /Find a Course/ get "/accounts/#{Account.default.id}/statistics" - response.should be_success - response.body.should match /Recently Started Courses/ - response.body.should match /Recently Ended Courses/ + expect(response).to be_success + expect(response.body).to match /Recently Started Courses/ + expect(response.body).to match /Recently Ended Courses/ end it "view_statistics" do @@ -679,17 +679,17 @@ describe "security" do assert_status(401) get "/accounts/#{Account.default.id}/settings" - response.should be_success - response.body.should_not match /Statistics/ + expect(response).to be_success + expect(response.body).not_to match /Statistics/ add_permission :view_statistics get "/accounts/#{Account.default.id}/statistics" - response.should be_success + expect(response).to be_success get "/accounts/#{Account.default.id}/settings" - response.should be_success - response.body.should match /Statistics/ + expect(response).to be_success + expect(response.body).to match /Statistics/ end it "manage_user_notes" do @@ -703,8 +703,8 @@ describe "security" do assert_status(401) get "/accounts/#{Account.default.id}/settings" - response.should be_success - response.body.should_not match /Faculty Journal/ + expect(response).to be_success + expect(response.body).not_to match /Faculty Journal/ get "/users/#{@student.id}/user_notes" assert_status(401) @@ -721,33 +721,33 @@ describe "security" do add_permission :manage_user_notes get "/accounts/#{Account.default.id}/user_notes" - response.should be_success + expect(response).to be_success get "/accounts/#{Account.default.id}/settings" - response.should be_success - response.body.should match /Faculty Journal/ + expect(response).to be_success + expect(response.body).to match /Faculty Journal/ get "/users/#{@student.id}/user_notes" - response.should be_success + expect(response).to be_success post "/users/#{@student.id}/user_notes.json" - response.should be_success + expect(response).to be_success get "/users/#{@student.id}/user_notes/#{@user_note.id}.json" - response.should be_success + expect(response).to be_success delete "/users/#{@student.id}/user_notes/#{@user_note.id}.json" - response.should be_success + expect(response).to be_success end it "view_jobs" do get "/jobs" - response.should be_redirect + expect(response).to be_redirect add_permission :view_jobs get "/jobs" - response.should be_success + expect(response).to be_success end end @@ -759,26 +759,26 @@ describe "security" do it 'read_as_admin' do get "/courses/#{@course.id}" - response.should be_redirect + expect(response).to be_redirect get "/courses/#{@course.id}/details" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.edit_course_link').should be_empty - html.css('#tab-users').should be_empty - html.css('#tab-navigation').should be_empty + expect(html.css('.edit_course_link')).to be_empty + expect(html.css('#tab-users')).to be_empty + expect(html.css('#tab-navigation')).to be_empty @course.enroll_teacher(@admin).accept! @admin.reload get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/details" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.edit_course_link').should_not be_empty - html.css('#tab-navigation').should_not be_empty + expect(html.css('.edit_course_link')).not_to be_empty + expect(html.css('#tab-navigation')).not_to be_empty end it 'read_roster' do @@ -792,28 +792,28 @@ describe "security" do assert_status(401) get "/courses/#{@course.id}/details" - response.should be_success - response.body.should_not match /People/ + expect(response).to be_success + expect(response.body).not_to match /People/ html = Nokogiri::HTML(response.body) - html.css('#tab-users').should be_empty + expect(html.css('#tab-users')).to be_empty add_permission :read_roster get "/courses/#{@course.id}/users" - response.should be_success - response.body.should match /View User Groups/ - response.body.should match /View Prior Enrollments/ - response.body.should_not match /Manage Users/ + expect(response).to be_success + expect(response.body).to match /View User Groups/ + expect(response.body).to match /View Prior Enrollments/ + expect(response.body).not_to match /Manage Users/ get "/courses/#{@course.id}/users/prior" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/groups" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/details" - response.should be_success - response.body.should match /People/ + expect(response).to be_success + expect(response.body).to match /People/ end it "manage_students" do @@ -827,25 +827,25 @@ describe "security" do assert_status(401) get "/courses/#{@course.id}/details" - response.should be_success - response.body.should_not match /People/ + expect(response).to be_success + expect(response.body).not_to match /People/ add_permission :manage_students get "/courses/#{@course.id}/users" - response.should be_success - response.body.should_not match /View User Groups/ - response.body.should match /View Prior Enrollments/ + expect(response).to be_success + expect(response.body).not_to match /View User Groups/ + expect(response.body).to match /View Prior Enrollments/ get "/courses/#{@course.id}/users/prior" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/groups" assert_status(401) get "/courses/#{@course.id}/details" - response.should be_success - response.body.should match /People/ + expect(response).to be_success + expect(response.body).to match /People/ @course.tab_configuration = [ { :id => Course::TAB_PEOPLE, :hidden => true } ] @course.save! @@ -853,8 +853,8 @@ describe "security" do # Should still be able to see People tab even if disabled, because we can # manage stuff in it get "/courses/#{@course.id}/details" - response.should be_success - response.body.should match /People/ + expect(response).to be_success + expect(response.body).to match /People/ end it 'view_all_grades' do @@ -867,10 +867,10 @@ describe "security" do add_permission :view_all_grades get "/courses/#{@course.id}/grades" - response.should be_redirect + expect(response).to be_redirect get "/courses/#{@course.id}/gradebook" - response.should be_success + expect(response).to be_success end it 'read_course_content' do @@ -880,7 +880,7 @@ describe "security" do @course.attachments.create!(:uploaded_data => default_uploaded_data) get "/courses/#{@course.id}" - response.should be_redirect + expect(response).to be_redirect get "/courses/#{@course.id}/assignments" assert_status(401) @@ -889,9 +889,9 @@ describe "security" do assert_status(401) get "/courses/#{@course.id}/wiki" - response.should be_redirect + expect(response).to be_redirect follow_redirect! - response.should be_redirect + expect(response).to be_redirect get "/courses/#{@course.id}/quizzes" assert_status(401) @@ -909,73 +909,73 @@ describe "security" do assert_status(401) get "/courses/#{@course.id}/details" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.section .assignments').should be_empty - html.css('.section .syllabus').should be_empty - html.css('.section .pages').should be_empty - html.css('.section .quizzes').should be_empty - html.css('.section .discussions').should be_empty - html.css('.section .files').should be_empty - response.body.should_not match /Copy this Course/ - response.body.should_not match /Import Content into this Course/ - response.body.should_not match /Export this Course/ + expect(html.css('.section .assignments')).to be_empty + expect(html.css('.section .syllabus')).to be_empty + expect(html.css('.section .pages')).to be_empty + expect(html.css('.section .quizzes')).to be_empty + expect(html.css('.section .discussions')).to be_empty + expect(html.css('.section .files')).to be_empty + expect(response.body).not_to match /Copy this Course/ + expect(response.body).not_to match /Import Content into this Course/ + expect(response.body).not_to match /Export this Course/ add_permission :read_course_content add_permission :read_roster add_permission :read_forum get "/courses/#{@course.id}" - response.should be_success - response.body.should match /People/ + expect(response).to be_success + expect(response.body).to match /People/ @course.tab_configuration = [ { :id => Course::TAB_PEOPLE, :hidden => true } ] @course.save! get "/courses/#{@course.id}/assignments" - response.should be_success - response.body.should_not match /People/ + expect(response).to be_success + expect(response.body).not_to match /People/ get "/courses/#{@course.id}/assignments/syllabus" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/wiki" - response.should be_redirect + expect(response).to be_redirect follow_redirect! - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/quizzes" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/discussion_topics" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/files" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/copy" assert_status(401) get "/courses/#{@course.id}/content_exports" - response.should be_success + expect(response).to be_success get "/courses/#{@course.id}/details" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.section .assignments').should_not be_empty - html.css('.section .syllabus').should_not be_empty - html.css('.section .pages').should_not be_empty - html.css('.section .quizzes').should_not be_empty - html.css('.section .discussions').should_not be_empty - html.css('.section .files').should_not be_empty - response.body.should_not match /Copy this Course/ - response.body.should_not match /Import Content into this Course/ - response.body.should match /Export Course Content/ - response.body.should_not match /Delete this Course/ - response.body.should_not match /End this Course/ - html.css('#course_account_id').should be_empty - html.css('#course_enrollment_term_id').should be_empty + expect(html.css('.section .assignments')).not_to be_empty + expect(html.css('.section .syllabus')).not_to be_empty + expect(html.css('.section .pages')).not_to be_empty + expect(html.css('.section .quizzes')).not_to be_empty + expect(html.css('.section .discussions')).not_to be_empty + expect(html.css('.section .files')).not_to be_empty + expect(response.body).not_to match /Copy this Course/ + expect(response.body).not_to match /Import Content into this Course/ + expect(response.body).to match /Export Course Content/ + expect(response.body).not_to match /Delete this Course/ + expect(response.body).not_to match /End this Course/ + expect(html.css('#course_account_id')).to be_empty + expect(html.css('#course_enrollment_term_id')).to be_empty delete "/courses/#{@course.id}" assert_status(401) @@ -986,28 +986,28 @@ describe "security" do add_permission :manage_courses get "/courses/#{@course.id}/details" - response.should be_success - response.body.should match /Copy this Course/ - response.body.should_not match /Import Content into this Course/ - response.body.should match /Export Course Content/ - response.body.should match /Delete this Course/ + expect(response).to be_success + expect(response.body).to match /Copy this Course/ + expect(response.body).not_to match /Import Content into this Course/ + expect(response.body).to match /Export Course Content/ + expect(response.body).to match /Delete this Course/ html = Nokogiri::HTML(response.body) - html.css('#course_account_id').should_not be_empty - html.css('#course_enrollment_term_id').should_not be_empty + expect(html.css('#course_account_id')).not_to be_empty + expect(html.css('#course_enrollment_term_id')).not_to be_empty get "/courses/#{@course.id}/copy" - response.should be_success + expect(response).to be_success delete "/courses/#{@course.id}", :event => 'delete' - response.should be_redirect + expect(response).to be_redirect - @course.reload.should be_deleted + expect(@course.reload).to be_deleted end it 'manage_content' do get "/courses/#{@course.id}/details" - response.should be_success - response.body.should_not match /Import Content into this Course/ + expect(response).to be_success + expect(response.body).not_to match /Import Content into this Course/ get "/courses/#{@course.id}/content_migrations" assert_status(401) @@ -1015,11 +1015,11 @@ describe "security" do add_permission :manage_content get "/courses/#{@course.id}/details" - response.should be_success - response.body.should match /Import Content into this Course/ + expect(response).to be_success + expect(response.body).to match /Import Content into this Course/ get "/courses/#{@course.id}/content_migrations" - response.should be_success + expect(response).to be_success end it 'read_reports' do @@ -1027,8 +1027,8 @@ describe "security" do add_permission :read_roster get "/courses/#{@course.id}/users/#{@student.id}" - response.should be_success - response.body.should_not match "Access Report" + expect(response).to be_success + expect(response.body).not_to match "Access Report" get "/courses/#{@course.id}/users/#{@student.id}/usage" assert_status(401) @@ -1036,11 +1036,11 @@ describe "security" do add_permission :read_reports get "/courses/#{@course.id}/users/#{@student.id}" - response.should be_success - response.body.should match "Access Report" + expect(response).to be_success + expect(response.body).to match "Access Report" get "/courses/#{@course.id}/users/#{@student.id}/usage" - response.should be_success + expect(response).to be_success end it 'manage_sections' do @@ -1048,14 +1048,14 @@ describe "security" do remove_permission(:manage_sections, 'TeacherEnrollment') get "/courses/#{@course.id}/settings" - response.should be_success - response.body.should_not match 'Add Section' + expect(response).to be_success + expect(response.body).not_to match 'Add Section' post "/courses/#{@course.id}/sections" assert_status(401) get "/courses/#{@course.id}/sections/#{@course.default_section.id}" - response.should be_success + expect(response).to be_success put "/courses/#{@course.id}/sections/#{@course.default_section.id}" assert_status(401) @@ -1066,8 +1066,8 @@ describe "security" do remove_permission(:change_course_state, 'TeacherEnrollment') get "/courses/#{@course.id}/settings" - response.should be_success - response.body.should_not match 'End this Course' + expect(response).to be_success + expect(response.body).not_to match 'End this Course' delete "/courses/#{@course.id}", :event => 'conclude' assert_status(401) @@ -1083,7 +1083,7 @@ describe "security" do end get "/courses/#{@course.id}/users/#{@student.id}" - response.should be_success + expect(response).to be_success get "/users/#{@student.id}" assert_status(401) @@ -1092,7 +1092,7 @@ describe "security" do user_session(admin) get "/users/#{@student.id}" - response.should be_success + expect(response).to be_success end end end diff --git a/spec/integration/sessions_timeout_spec.rb b/spec/integration/sessions_timeout_spec.rb index 7a6ad194980..6b8c5bc6e5c 100644 --- a/spec/integration/sessions_timeout_spec.rb +++ b/spec/integration/sessions_timeout_spec.rb @@ -33,25 +33,25 @@ describe "Session Timeout" do it "should time out after 40 minutes of inactivity" do now = Time.now get "/" - response.should be_success + expect(response).to be_success Time.stubs(:now).returns(now + 40.minutes) get "/" - response.should redirect_to "http://www.example.com/login" + expect(response).to redirect_to "http://www.example.com/login" end it "should not time out if the user remains active" do now = Time.now get "/" - response.should be_success + expect(response).to be_success Time.stubs(:now).returns(now + 20.minutes) get "/" - response.should be_success + expect(response).to be_success Time.stubs(:now).returns(now + 40.minutes) get "/" - response.should be_success + expect(response).to be_success end end end diff --git a/spec/integration/student_interactions_spec.rb b/spec/integration/student_interactions_spec.rb index ea656cab928..4e686e66e8d 100644 --- a/spec/integration/student_interactions_spec.rb +++ b/spec/integration/student_interactions_spec.rb @@ -44,37 +44,37 @@ describe "student interactions links" do it "should show the student link on the student's page" do get "/courses/#{@course.id}/users/#{@student.id}" - response.should be_success - response.body.should match(/Interactions with You/) + expect(response).to be_success + expect(response.body).to match(/Interactions with You/) end it "should show the teacher link on the teacher's page" do get "/courses/#{@course.id}/users/#{@teacher.id}" - response.should be_success - response.body.should match(/Student Interactions Report/) + expect(response).to be_success + expect(response.body).to match(/Student Interactions Report/) end it "should show mail link for teachers" do get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.message_student_link').should_not be_nil + expect(html.css('.message_student_link')).not_to be_nil end it "should recalculate grades on the first page load" do Enrollment.expects(:recompute_final_score).twice # once for the course, once for the student ('s course) enable_cache do get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}" - response.should be_success + expect(response).to be_success get "/users/#{@teacher.id}/teacher_activity/student/#{@student.id}" - response.should be_success + expect(response).to be_success get "/users/#{@teacher.id}/teacher_activity/student/#{@student.id}" - response.should be_success + expect(response).to be_success get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}" - response.should be_success + expect(response).to be_success end end @@ -83,9 +83,9 @@ describe "student interactions links" do Account.site_admin.account_users.create!(user: @user) user_session(@user) get "/users/#{@teacher.id}/teacher_activity/course/#{@course.id}" - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) - html.css('.message_student_link').should be_empty + expect(html.css('.message_student_link')).to be_empty end end diff --git a/spec/integration/syllabus_spec.rb b/spec/integration/syllabus_spec.rb index e0da754a7b4..34582fefa25 100644 --- a/spec/integration/syllabus_spec.rb +++ b/spec/integration/syllabus_spec.rb @@ -26,10 +26,10 @@ describe "syllabus" do get "/courses/#{@course.id}/assignments/syllabus" - response.should be_success + expect(response).to be_success page = Nokogiri::HTML(response.body) - page.css('#identity a[href="/login"]').should_not be_nil - page.at_css('#syllabusContainer').should_not be_nil + expect(page.css('#identity a[href="/login"]')).not_to be_nil + expect(page.at_css('#syllabusContainer')).not_to be_nil end it "should allow access to public courses" do @@ -49,8 +49,8 @@ describe "syllabus" do get "/courses/#{@course.id}" - response.should be_success + expect(response).to be_success page = Nokogiri::HTML(response.body) - page.at_css('#course_syllabus').text.should include(syllabus_body) + expect(page.at_css('#course_syllabus').text).to include(syllabus_body) end end diff --git a/spec/integration/user_content_spec.rb b/spec/integration/user_content_spec.rb index 83fde9df669..bf55635d0ff 100644 --- a/spec/integration/user_content_spec.rb +++ b/spec/integration/user_content_spec.rb @@ -29,12 +29,12 @@ describe "User Content" do snippet = Base64.encode64 obj_data sig = Canvas::Security.hmac_sha1(snippet) post "http://files.example.com/object_snippet", :object_data => snippet, :s => sig - response.should be_success - response.body.should be_include(obj_data) + expect(response).to be_success + expect(response.body).to be_include(obj_data) post "http://canvas.example.com/object_snippet", :object_data => snippet, :s => sig assert_status(400) - response.body.should be_blank + expect(response.body).to be_blank end it "should allow object_snippet if there is no safefiles domain configured" do @@ -45,8 +45,8 @@ describe "User Content" do snippet = Base64.encode64 obj_data sig = Canvas::Security.hmac_sha1(snippet) post "http://files.example.com/object_snippet", :object_data => snippet, :s => sig - response.should be_success - response.body.should be_include(obj_data) + expect(response).to be_success + expect(response.body).to be_include(obj_data) end end end diff --git a/spec/integration/users_controller_spec.rb b/spec/integration/users_controller_spec.rb index a79a9024628..29c641d6f74 100644 --- a/spec/integration/users_controller_spec.rb +++ b/spec/integration/users_controller_spec.rb @@ -36,28 +36,28 @@ describe UsersController do it "should count conversations as interaction" do get user_student_teacher_activity_url(@teacher, @e1.user) - Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text.should match(/never/) + expect(Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text).to match(/never/) @conversation = Conversation.initiate([@e1.user, @teacher], false) @conversation.add_message(@teacher, "hello") get user_student_teacher_activity_url(@teacher, @e1.user) - Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text.should match(/less than 1 day/) + expect(Nokogiri::HTML(response.body).at_css('table.report tbody tr:first td:nth(2)').text).to match(/less than 1 day/) end it "should only include students the teacher can view" do get user_course_teacher_activity_url(@teacher, @course) - response.should be_success - response.body.should match(/studentname1/) - response.body.should_not match(/studentname2/) + expect(response).to be_success + expect(response.body).to match(/studentname1/) + expect(response.body).not_to match(/studentname2/) end it "should show user notes if enabled" do get user_course_teacher_activity_url(@teacher, @course) - response.body.should_not match(/journal entry/i) + expect(response.body).not_to match(/journal entry/i) @course.root_account.update_attribute(:enable_user_notes, true) get user_course_teacher_activity_url(@teacher, @course) - response.body.should match(/journal entry/i) + expect(response.body).to match(/journal entry/i) end it "should show individual user info across courses" do @@ -66,18 +66,18 @@ describe UsersController do @course2.update_attribute(:name, 'coursename2') student_in_course(:course => @course2, :user => @e1.user) get user_student_teacher_activity_url(@teacher, @e1.user) - response.should be_success - response.body.should match(/studentname1/) - response.body.should_not match(/studentname2/) - response.body.should match(/coursename1/) + expect(response).to be_success + expect(response.body).to match(/studentname1/) + expect(response.body).not_to match(/studentname2/) + expect(response.body).to match(/coursename1/) # teacher not in course2 - response.body.should_not match(/coursename2/) + expect(response.body).not_to match(/coursename2/) # now put teacher in course2 @course2.enroll_teacher(@teacher).accept! get user_student_teacher_activity_url(@teacher, @e1.user) - response.should be_success - response.body.should match(/coursename1/) - response.body.should match(/coursename2/) + expect(response).to be_success + expect(response.body).to match(/coursename1/) + expect(response.body).to match(/coursename2/) end it "should be available for concluded courses/enrollments" do @@ -89,24 +89,24 @@ describe UsersController do @e1.conclude get user_student_teacher_activity_url(@teacher, @e1.user) - response.should be_success - response.body.should match(/studentname1/) + expect(response).to be_success + expect(response.body).to match(/studentname1/) get user_course_teacher_activity_url(@teacher, @course) - response.should be_success - response.body.should match(/studentname1/) + expect(response).to be_success + expect(response.body).to match(/studentname1/) end it "should show concluded students to active teachers" do @e1.conclude get user_student_teacher_activity_url(@teacher, @e1.user) - response.should be_success - response.body.should match(/studentname1/) + expect(response).to be_success + expect(response.body).to match(/studentname1/) get user_course_teacher_activity_url(@teacher, @course) - response.should be_success - response.body.should match(/studentname1/) + expect(response).to be_success + expect(response.body).to match(/studentname1/) end end @@ -119,8 +119,8 @@ describe UsersController do Account.default.account_users.create!(user: @user) user_session(@user, @pseudonym) get account_users_url(Account.default) - response.should be_success - response.body.should match /Olds, JT.*St\. Clair, John/m + expect(response).to be_success + expect(response.body).to match /Olds, JT.*St\. Clair, John/m end it "should not show any student view students at the account level" do @@ -132,8 +132,8 @@ describe UsersController do get account_users_url Account.default.id body = Nokogiri::HTML(response.body) - body.css("#user_#{@fake_student.id}").should be_empty - body.at_css('.users').text.should_not match(/Test Student/) + expect(body.css("#user_#{@fake_student.id}")).to be_empty + expect(body.at_css('.users').text).not_to match(/Test Student/) end end @@ -145,7 +145,7 @@ describe UsersController do course student_in_course(:course => @course) get "/users/#{@student.id}" - response.should be_success + expect(response).to be_success course(:account => account_model) student_in_course(:course => @course) @@ -162,7 +162,7 @@ describe UsersController do user_session(@user) get "/users/#{@student.id}" - response.should be_success + expect(response).to be_success end it "should show course user to account users that have the read_roster permission" do @@ -174,7 +174,7 @@ describe UsersController do user_session(@user) get "/courses/#{@course.id}/users/#{@student.id}" - response.should be_success + expect(response).to be_success end end @@ -199,33 +199,33 @@ describe UsersController do disable_avatars! enable_cache do get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}" - response.should redirect_to "http://someschool.instructure.com/images/no_pic.gif" + expect(response).to redirect_to "http://someschool.instructure.com/images/no_pic.gif" get "https://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}" - response.should redirect_to "https://otherschool.instructure.com/images/no_pic.gif" + expect(response).to redirect_to "https://otherschool.instructure.com/images/no_pic.gif" end end it "should maintain protocol and domain name in gravatar redirect fallback" do enable_cache do get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}" - response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}" + expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}" get "https://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}" - response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/images/messages/avatar-50.png")}" + expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/images/messages/avatar-50.png")}" end end it "should return different urls for different fallbacks" do enable_cache do get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}" - response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}" + expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}" get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=#{CGI.escape("/my/custom/fallback/url.png")}" - response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/my/custom/fallback/url.png")}" + expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/my/custom/fallback/url.png")}" get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=#{CGI.escape("https://test.domain/another/custom/fallback/url.png")}" - response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://test.domain/another/custom/fallback/url.png")}" + expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://test.domain/another/custom/fallback/url.png")}" end end @@ -235,23 +235,23 @@ describe UsersController do orig_size = data.size get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}" - response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}" + expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("http://someschool.instructure.com/images/messages/avatar-50.png")}" get "https://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=/my/custom/fallback/url.png" - response.should redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/my/custom/fallback/url.png")}" + expect(response).to redirect_to "https://secure.gravatar.com/avatar/000?s=50&d=#{CGI::escape("https://otherschool.instructure.com/my/custom/fallback/url.png")}" diff = data.select{|k,v|k =~ /avatar_img/}.size - orig_size - diff.should > 0 + expect(diff).to be > 0 @user.update_attribute(:avatar_image, {'type' => 'attachment', 'url' => '/images/thumbnails/foo.gif'}) - data.select{|k,v|k =~ /avatar_img/}.size.should == orig_size + expect(data.select{|k,v|k =~ /avatar_img/}.size).to eq orig_size get "http://someschool.instructure.com/images/users/#{User.avatar_key(@user.id)}" - response.should redirect_to "http://someschool.instructure.com/images/thumbnails/foo.gif" + expect(response).to redirect_to "http://someschool.instructure.com/images/thumbnails/foo.gif" get "http://otherschool.instructure.com/images/users/#{User.avatar_key(@user.id)}?fallback=#{CGI::escape("https://test.domain/my/custom/fallback/url.png")}" - response.should redirect_to "http://otherschool.instructure.com/images/thumbnails/foo.gif" - data.select{|k,v|k =~ /avatar_img/}.size.should == orig_size + diff + expect(response).to redirect_to "http://otherschool.instructure.com/images/thumbnails/foo.gif" + expect(data.select{|k,v|k =~ /avatar_img/}.size).to eq orig_size + diff end end end @@ -266,9 +266,9 @@ describe UsersController do get grades_url student_grades = Nokogiri::HTML(response.body).css('.student_grades tr') - student_grades.length.should == 2 - student_grades.text.should match /#{@first_course.name}/ - student_grades.text.should match /#{@course.name}/ + expect(student_grades.length).to eq 2 + expect(student_grades.text).to match /#{@first_course.name}/ + expect(student_grades.text).to match /#{@course.name}/ end end @@ -281,21 +281,21 @@ describe UsersController do user_session(@admin) get user_admin_merge_url(@user, :pending_user_id => @admin.id) - response.should be_success - assigns['pending_other_user'].should == @admin - assigns['other_user'].should be_nil + expect(response).to be_success + expect(assigns['pending_other_user']).to eq @admin + expect(assigns['other_user']).to be_nil get user_admin_merge_url(@user, :new_user_id => @admin.id) - response.should be_success - assigns['pending_other_user'].should be_nil - assigns['other_user'].should == @admin + expect(response).to be_success + expect(assigns['pending_other_user']).to be_nil + expect(assigns['other_user']).to eq @admin post user_merge_url(@user, :new_user_id => @admin.id) - response.should redirect_to(user_profile_url(@admin)) + expect(response).to redirect_to(user_profile_url(@admin)) - @user.reload.should be_deleted - @admin.reload.should be_registered - @admin.pseudonyms.count.should == 2 + expect(@user.reload).to be_deleted + expect(@admin.reload).to be_registered + expect(@admin.pseudonyms.count).to eq 2 end end end diff --git a/spec/integration/varied_due_dates_spec.rb b/spec/integration/varied_due_dates_spec.rb index 5d6c686074f..9ebca081058 100644 --- a/spec/integration/varied_due_dates_spec.rb +++ b/spec/integration/varied_due_dates_spec.rb @@ -25,21 +25,21 @@ describe "varied due dates" do def assert_coming_up_due_date(response, expected) doc = Nokogiri::HTML(response.body) - doc.at_css("#right-side .coming_up .event a .tooltip_text").text.should include( + expect(doc.at_css("#right-side .coming_up .event a .tooltip_text").text).to include( expected.is_a?(String) ? expected : datetime_string(expected) ) end def assert_todo_due_date(response, expected) doc = Nokogiri::HTML(response.body) - doc.at_css("#right-side .to-do-list").text.should include( + expect(doc.at_css("#right-side .to-do-list").text).to include( expected.is_a?(String) ? expected : datetime_string(expected) ) end def assert_recent_feedback_due_date(response, expected) doc = Nokogiri::HTML(response.body) - doc.at_css("#right-side .recent_feedback .event a .tooltip_text").text.should include( + expect(doc.at_css("#right-side .recent_feedback .event a .tooltip_text").text).to include( expected.is_a?(String) ? expected : datetime_string(expected) ) end @@ -214,7 +214,7 @@ describe "varied due dates" do context "with overrides" do it "shows multiple due dates" do get course_assignments_path(@course) - response.body.should include multiple_due_dates + expect(response.body).to include multiple_due_dates end end @@ -222,7 +222,7 @@ describe "varied due dates" do it "shows the course due date" do AssignmentOverride.delete_all get course_assignments_path(@course) - response.body.should include formatted_date(@course_due_date) + expect(response.body).to include formatted_date(@course_due_date) end end end diff --git a/spec/integration/wiki_page_spec.rb b/spec/integration/wiki_page_spec.rb index 9c34897fc55..093fb64115d 100644 --- a/spec/integration/wiki_page_spec.rb +++ b/spec/integration/wiki_page_spec.rb @@ -34,7 +34,7 @@ describe WikiPagesController do :body => "this is the content of the wikipage body asdfasdf" @wiki_page.destroy get course_wiki_page_url(@course, @wiki_page) - response.body.should_not include(@wiki_page.body) + expect(response.body).not_to include(@wiki_page.body) end it "should link correctly in the breadcrumbs for group wikis" do @@ -45,13 +45,13 @@ describe WikiPagesController do def test_page(url) get url - response.should be_success + expect(response).to be_success html = Nokogiri::HTML(response.body) html.css('#breadcrumbs a').each do |link| href = link.attr('href') next if href == "/" - href.should =~ %r{/groups/#{@group.id}} + expect(href).to match %r{/groups/#{@group.id}} end end @@ -76,34 +76,34 @@ describe WikiPagesController do @course.wiki.has_no_front_page = true @course.wiki.save! get @base_url + "wiki" - response.should redirect_to(course_pages_url(@course)) + expect(response).to redirect_to(course_pages_url(@course)) end it "should forward /wiki to /pages/front-page" do @front.save! @front.set_as_front_page! get @base_url + "wiki" - response.should redirect_to(course_named_page_url(@course, "front-page")) + expect(response).to redirect_to(course_named_page_url(@course, "front-page")) end it "should forward /wiki/name to /pages/name" do get @base_url + "wiki/a-page" - response.should redirect_to(course_named_page_url(@course, "a-page")) + expect(response).to redirect_to(course_named_page_url(@course, "a-page")) end it "should forward module_item_id parameter" do get @base_url + "wiki/a-page?module_item_id=123" - response.should redirect_to(course_named_page_url(@course, "a-page") + "?module_item_id=123") + expect(response).to redirect_to(course_named_page_url(@course, "a-page") + "?module_item_id=123") end it "should forward /wiki/name/revisions to /pages/name/revisions" do get @base_url + "wiki/a-page/revisions" - response.should redirect_to(course_named_page_revisions_url(@course, "a-page")) + expect(response).to redirect_to(course_named_page_revisions_url(@course, "a-page")) end it "should forward /wiki/name/revisions/revision to /pages/name/revisions" do get @base_url + "wiki/a-page/revisions/42" - response.should redirect_to(course_named_page_revisions_url(@course, "a-page")) + expect(response).to redirect_to(course_named_page_revisions_url(@course, "a-page")) end end