From 435cb4aed9888fdcda0b11bf3a32956a54bcc3ea Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 6 Nov 2013 10:39:19 +1100 Subject: [PATCH] remove annoying scaffold-generated tests --- .../plant_parts_controller_spec.rb | 159 ------------------ 1 file changed, 159 deletions(-) diff --git a/spec/controllers/plant_parts_controller_spec.rb b/spec/controllers/plant_parts_controller_spec.rb index 1d8c1a6ec..9aefaa953 100644 --- a/spec/controllers/plant_parts_controller_spec.rb +++ b/spec/controllers/plant_parts_controller_spec.rb @@ -1,164 +1,5 @@ require 'spec_helper' -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to specify the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. -# -# Compared to earlier versions of this generator, there is very limited use of -# stubs and message expectations in this spec. Stubs are only used when there -# is no simpler way to get a handle on the object needed for the example. -# Message expectations are only used when there is no simpler way to specify -# that an instance is receiving a specific message. - describe PlantPartsController do - # This should return the minimal set of attributes required to create a valid - # PlantPart. As you add validations to PlantPart, be sure to - # update the return value of this method accordingly. - def valid_attributes - { "name" => "MyString" } - end - - # This should return the minimal set of values that should be in the session - # in order to pass any filters (e.g. authentication) defined in - # PlantPartsController. Be sure to keep this updated too. - def valid_session - {} - end - - describe "GET index" do - it "assigns all plant_parts as @plant_parts" do - plant_part = PlantPart.create! valid_attributes - get :index, {}, valid_session - assigns(:plant_parts).should eq([plant_part]) - end - end - - describe "GET show" do - it "assigns the requested plant_part as @plant_part" do - plant_part = PlantPart.create! valid_attributes - get :show, {:id => plant_part.to_param}, valid_session - assigns(:plant_part).should eq(plant_part) - end - end - - describe "GET new" do - it "assigns a new plant_part as @plant_part" do - get :new, {}, valid_session - assigns(:plant_part).should be_a_new(PlantPart) - end - end - - describe "GET edit" do - it "assigns the requested plant_part as @plant_part" do - plant_part = PlantPart.create! valid_attributes - get :edit, {:id => plant_part.to_param}, valid_session - assigns(:plant_part).should eq(plant_part) - end - end - - describe "POST create" do - describe "with valid params" do - it "creates a new PlantPart" do - expect { - post :create, {:plant_part => valid_attributes}, valid_session - }.to change(PlantPart, :count).by(1) - end - - it "assigns a newly created plant_part as @plant_part" do - post :create, {:plant_part => valid_attributes}, valid_session - assigns(:plant_part).should be_a(PlantPart) - assigns(:plant_part).should be_persisted - end - - it "redirects to the created plant_part" do - post :create, {:plant_part => valid_attributes}, valid_session - response.should redirect_to(PlantPart.last) - end - end - - describe "with invalid params" do - it "assigns a newly created but unsaved plant_part as @plant_part" do - # Trigger the behavior that occurs when invalid params are submitted - PlantPart.any_instance.stub(:save).and_return(false) - post :create, {:plant_part => { "name" => "invalid value" }}, valid_session - assigns(:plant_part).should be_a_new(PlantPart) - end - - it "re-renders the 'new' template" do - # Trigger the behavior that occurs when invalid params are submitted - PlantPart.any_instance.stub(:save).and_return(false) - post :create, {:plant_part => { "name" => "invalid value" }}, valid_session - response.should render_template("new") - end - end - end - - describe "PUT update" do - describe "with valid params" do - it "updates the requested plant_part" do - plant_part = PlantPart.create! valid_attributes - # Assuming there are no other plant_parts in the database, this - # specifies that the PlantPart created on the previous line - # receives the :update_attributes message with whatever params are - # submitted in the request. - PlantPart.any_instance.should_receive(:update_attributes).with({ "name" => "MyString" }) - put :update, {:id => plant_part.to_param, :plant_part => { "name" => "MyString" }}, valid_session - end - - it "assigns the requested plant_part as @plant_part" do - plant_part = PlantPart.create! valid_attributes - put :update, {:id => plant_part.to_param, :plant_part => valid_attributes}, valid_session - assigns(:plant_part).should eq(plant_part) - end - - it "redirects to the plant_part" do - plant_part = PlantPart.create! valid_attributes - put :update, {:id => plant_part.to_param, :plant_part => valid_attributes}, valid_session - response.should redirect_to(plant_part) - end - end - - describe "with invalid params" do - it "assigns the plant_part as @plant_part" do - plant_part = PlantPart.create! valid_attributes - # Trigger the behavior that occurs when invalid params are submitted - PlantPart.any_instance.stub(:save).and_return(false) - put :update, {:id => plant_part.to_param, :plant_part => { "name" => "invalid value" }}, valid_session - assigns(:plant_part).should eq(plant_part) - end - - it "re-renders the 'edit' template" do - plant_part = PlantPart.create! valid_attributes - # Trigger the behavior that occurs when invalid params are submitted - PlantPart.any_instance.stub(:save).and_return(false) - put :update, {:id => plant_part.to_param, :plant_part => { "name" => "invalid value" }}, valid_session - response.should render_template("edit") - end - end - end - - describe "DELETE destroy" do - it "destroys the requested plant_part" do - plant_part = PlantPart.create! valid_attributes - expect { - delete :destroy, {:id => plant_part.to_param}, valid_session - }.to change(PlantPart, :count).by(-1) - end - - it "redirects to the plant_parts list" do - plant_part = PlantPart.create! valid_attributes - delete :destroy, {:id => plant_part.to_param}, valid_session - response.should redirect_to(plant_parts_url) - end - end - end