spec/resource_spec.rb in survey-gizmo-ruby-6.2.10 vs spec/resource_spec.rb in survey-gizmo-ruby-6.2.11

- old
+ new

@@ -20,19 +20,19 @@ } it '#reload' do stub_request(:get, /#{@base}/).to_return(json_response(true, get_attributes)) obj = described_class.new(get_attributes.merge(update_attributes)) - obj.attributes.reject { |k, v| v.blank? }.should == get_attributes.merge(update_attributes) + expect(obj.attributes.reject { |k, v| v.blank? }).to eq(get_attributes.merge(update_attributes)) obj.reload - obj.attributes.reject { |k, v| v.blank? }.should == get_attributes + expect(obj.attributes.reject { |k, v| v.blank? }).to eq(get_attributes) end it 'should raise an error if params are missing' do - lambda { + expect(lambda { SurveyGizmoSpec::ResourceTest.destroy(test_id: 5) - }.should raise_error(SurveyGizmo::URLError, 'Missing RESTful parameters in request: `:id`') + }).to raise_error(SurveyGizmo::URLError, 'Missing RESTful parameters in request: `:id`') end it_should_behave_like 'an API object' it_should_behave_like 'an object with errors' @@ -71,12 +71,12 @@ it 'should determine if there are new results' do stub_request(:get, /#{@base}\/survey\/1\/surveyresponse/).to_return(json_response(true, [])) survey = described_class.new(id: 1) - expect(survey.server_has_new_results_since?(Time.now)).to be_false - a_request(:get, /#{@base}\/survey\/1\/surveyresponse/).should have_been_made + expect(survey.server_has_new_results_since?(Time.now)).to be_falsey + expect(a_request(:get, /#{@base}\/survey\/1\/surveyresponse/)).to have_been_made end end describe SurveyGizmo::API::Question do let(:base_params) { {survey_id: 1234, page_id: 1} } @@ -98,17 +98,17 @@ it 'should handle the title hash returned from the API' do expect(described_class.new('title' => {'English' => 'Some title'}).title).to eq('Some title') end it 'should handle the _subtype key' do - described_class.new(:_subtype => 'radio').type.should == 'radio' + expect(described_class.new(:_subtype => 'radio').type).to eq('radio') end it 'should find the survey' do stub_request(:get, /#{@base}\/survey\/1234/).to_return(json_response(true, get_attributes)) described_class.new(base_params).survey - a_request(:get, /#{@base}\/survey\/1234/).should have_been_made + expect(a_request(:get, /#{@base}\/survey\/1234/)).to have_been_made end context 'options' do let(:survey_id) { 15 } let(:question_id) { 23 } @@ -137,21 +137,21 @@ stub_request(:get, /#{@base}\/survey\/#{survey_id}\/surveyquestion\/#{question_id}/).to_return(json_response(true, body_data)) end it 'correctly parses options out of question data' do question = described_class.first(survey_id: survey_id, id: question_id) - expect(question.options.all? { |o| o.question_id == question_id && o.survey_id == survey_id }).to be_true + expect(question.options.all? { |o| o.question_id == question_id && o.survey_id == survey_id }).to be_truthy expect(question.options.map { |o| o.id }).to eq([10014, 10015]) - a_request(:get, /#{@base}\/.*surveyoption/).should_not have_been_made + expect(a_request(:get, /#{@base}\/.*surveyoption/)).to_not have_been_made end it 'correctly parses sub question options' do question = described_class.new(survey_id: survey_id, id: question_id + 1, parent_question_id: question_id) expect(question.parent_question.id).to eq(described_class.new(body_data).id) - expect(question.options.all? { |o| o.question_id == question.id && o.survey_id == survey_id }).to be_true + expect(question.options.all? { |o| o.question_id == question.id && o.survey_id == survey_id }).to be_truthy expect(question.options.map { |o| o.id }).to eq([10014, 10015]) - a_request(:get, /#{@base}\/survey\/#{survey_id}\/surveyquestion\/#{question_id}/).should have_been_made + expect(a_request(:get, /#{@base}\/survey\/#{survey_id}\/surveyquestion\/#{question_id}/)).to have_been_made end end end context 'subquestions' do @@ -166,12 +166,14 @@ it 'should have 2 subquestions and they should have the right parent question' do stub_request(:get, /#{@base}/).to_return(json_response(true, get_attributes)) expect(question_with_subquestions.sub_questions.size).to eq(2) question_with_subquestions.sub_questions.first.parent_question - a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{parent_id}/).should have_been_made - skus.each { |sku| a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{sku}/).should have_been_made } + expect(a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{parent_id}/)).to have_been_made + skus.each do |sku| + expect(a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{sku}/)).to have_been_made + end end context 'and shortname' do let(:sku) { 6 } let(:question_with_subquestions) { described_class.new(id: parent_id, survey_id: 1234, sub_question_skus: [["0", sku], ["foo", 8]]) } @@ -179,11 +181,11 @@ it 'should have 2 subquestions and they should have the right parent question' do stub_request(:get, /#{@base}/).to_return(json_response(true, get_attributes)) expect(question_with_subquestions.sub_questions.size).to eq(2) question_with_subquestions.sub_questions.first.parent_question - a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{parent_id}/).should have_been_made - a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{sku}/).should have_been_made + expect(a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{parent_id}/)).to have_been_made + expect(a_request(:get, /#{@base}\/survey\/1234\/surveyquestion\/#{sku}/)).to have_been_made end end end end