AutoCommit Mon Aug 31 17:03:03 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-08-31 17:03:03 +02:00
parent 93dbdedf53
commit 589597509a
4 changed files with 36 additions and 16 deletions

View File

@@ -65,6 +65,10 @@ describe FetprofilesController, :type => :controller do
subject(:action) { get :show, {:id => @fetprofile.to_param}}
it_behaves_like "it is success"
it_behaves_like "it assigns object"
it "renders the 'show' template" do
expect(action).to render_template("show")
end
end
describe "GET new" do
@@ -104,22 +108,30 @@ describe FetprofilesController, :type => :controller do
end
describe "POST create" do
subject(:action){post :create, {:fetprofile => FactoryGirl.build(:fetprofile).attributes.slice(:vorname, :nachname,:desc)}}
subject(:action){post :create, {:fetprofile => FactoryGirl.attributes_for(:fetprofile)},:format=>:html}
login_fet_user
describe "with valid params" do
# login_fet_user
it "uses valid params" do
expect(Fetprofile.new({:vorname => "sdfsdf", :nachname=>"sdfefw",:desc=>"sdfsdfe"}).save).to be true
end
# before(:each) do
# Fetprofile.any_instance.stub(:save).and_return(true)
# end
it "creates a new Fetprofile" do
expect{action}.to change(Fetprofile, :count).by(1)
end
it "assigns a newly created fetprofile as @fetprofile" do
action
expect(assigns(:fetprofile)).to be_a(Fetprofile)
assigns(:fetprofile).should be_persisted
expect(assigns(:fetprofile)).to be_persisted
end
it "redirects to the created fetprofile" do
expect(action).to redirect_to(Fetprofile.last)
expect(action).to redirect_to action: "show"
end
end
@@ -129,6 +141,7 @@ describe FetprofilesController, :type => :controller do
it "assigns a newly created but unsaved fetprofile as @fetprofile" do
action
assigns(:fetprofile).should be_a_new(Fetprofile)
expect(assigns(:fetprofile)).not_to be_persisted
end
it "re-renders the 'new' template" do
expect(action).to render_template("new")
@@ -148,6 +161,12 @@ describe FetprofilesController, :type => :controller do
it "updates the requested fetprofile" do
expect { action }.to change{Fetprofile.find(@fetprofile.id).vorname}#.to("neuerName")
end
it "assigns a created fetprofile as @fetprofile" do
action
expect(assigns(:fetprofile)).to be_a(Fetprofile)
expect(assigns(:fetprofile)).to be_persisted
end
it "redirects to the fetprofile" do
expect(action).to redirect_to(@fetprofile)
end