spec/resource_spec.rb in survey-gizmo-ruby-0.6.0 vs spec/resource_spec.rb in survey-gizmo-ruby-0.7.0

- old
+ new

@@ -9,11 +9,11 @@ let(:described_class) { SurveyGizmoSpec::ResourceTest } let(:create_attributes){ {:title => 'Spec', :test_id => 5} } let(:get_attributes) { create_attributes.merge(:id => 1) } let(:update_attributes){ {:title => 'Updated'} } - let(:first_params){ {:id => 1} } + let(:first_params){ {:id => 1, :test_id => 5} } let(:uri_paths){ { :get => '/test/1', :create => '/test/5/resource', :update => '/test/5/resource/1', @@ -26,22 +26,24 @@ end it '#reload' do stub_request(:get, /#{@base}/).to_return(json_response(true, get_attributes)) - obj = described_class.new(create_attributes) - obj.attributes.reject{|k,v| v.blank? }.should == create_attributes + obj = described_class.new(get_attributes.merge(update_attributes)) + obj.attributes.reject{|k,v| v.blank? }.should == get_attributes.merge(update_attributes) obj.reload obj.attributes.reject{|k,v| v.blank? }.should == get_attributes end it '#valid?' - - it "should track descendants" do - SurveyGizmo::Resource.descendants.should include(SurveyGizmoSpec::ResourceTest) - end + it "should raise an error if params are missing" do + lambda { + SurveyGizmoSpec::ResourceTest.destroy(:test_id => 5) + }.should raise_error(SurveyGizmo::URLError, 'Missing parameters in request: `:id`') + end + it_should_behave_like 'an API object' it_should_behave_like 'an object with errors' end describe SurveyGizmo::API::Survey do @@ -63,10 +65,10 @@ let(:create_attributes){ {:survey_id => 1234, :page_id => 1, :title => 'Spec Question', :type => 'radio', :properties => {"required" => true, "option_sort" => false} } } let(:get_attributes) { create_attributes.merge(:id => 1) } let(:update_attributes){ {:survey_id => 1234, :page_id => 1, :title => 'Updated'} } - let(:first_params){ {:id => 1, :survey_id => 1234} } + let(:first_params){ {:id => 1, :survey_id => 1234, :page_id => 1} } let(:uri_paths){ { :get => '/survey/1234/surveyquestion/1', :create => '/survey/1234/surveypage/1/surveyquestion', :update => '/survey/1234/surveypage/1/surveyquestion/1', :delete => '/survey/1234/surveypage/1/surveyquestion/1'