From b80bd744ad873f6fc43018bc4bfb90677de167bd Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 17 Dec 2012 12:01:45 +0100 Subject: Start of GS5. --- .../nifty/scaffold/templates/tests/rspec/actions/create.rb | 11 +++++++++++ .../nifty/scaffold/templates/tests/rspec/actions/destroy.rb | 6 ++++++ .../nifty/scaffold/templates/tests/rspec/actions/edit.rb | 4 ++++ .../nifty/scaffold/templates/tests/rspec/actions/index.rb | 4 ++++ .../nifty/scaffold/templates/tests/rspec/actions/new.rb | 4 ++++ .../nifty/scaffold/templates/tests/rspec/actions/show.rb | 4 ++++ .../nifty/scaffold/templates/tests/rspec/actions/update.rb | 11 +++++++++++ 7 files changed, 44 insertions(+) create mode 100644 lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb create mode 100644 lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb (limited to 'lib/generators/nifty/scaffold/templates/tests/rspec/actions') diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb new file mode 100644 index 0000000..ef5a906 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb @@ -0,0 +1,11 @@ + it "create action should render new template when model is invalid" do + <%= class_name %>.any_instance.stubs(:valid?).returns(false) + post :create + response.should render_template(:new) + end + + it "create action should redirect when model is valid" do + <%= class_name %>.any_instance.stubs(:valid?).returns(true) + post :create + response.should redirect_to(<%= item_path_for_spec('url') %>) + end diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb new file mode 100644 index 0000000..8372953 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb @@ -0,0 +1,6 @@ + it "destroy action should destroy model and redirect to index action" do + <%= instance_name %> = <%= class_name %>.first + delete :destroy, :id => <%= instance_name %> + response.should redirect_to(<%= items_url %>) + <%= class_name %>.exists?(<%= instance_name %>.id).should be_false + end diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb new file mode 100644 index 0000000..e144904 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb @@ -0,0 +1,4 @@ + it "edit action should render edit template" do + get :edit, :id => <%= class_name %>.first + response.should render_template(:edit) + end diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb new file mode 100644 index 0000000..a40ea16 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb @@ -0,0 +1,4 @@ + it "index action should render index template" do + get :index + response.should render_template(:index) + end diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb new file mode 100644 index 0000000..22e1b40 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb @@ -0,0 +1,4 @@ + it "new action should render new template" do + get :new + response.should render_template(:new) + end diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb new file mode 100644 index 0000000..eaa3d93 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb @@ -0,0 +1,4 @@ + it "show action should render show template" do + get :show, :id => <%= class_name %>.first + response.should render_template(:show) + end diff --git a/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb new file mode 100644 index 0000000..c919962 --- /dev/null +++ b/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb @@ -0,0 +1,11 @@ + it "update action should render edit template when model is invalid" do + <%= class_name %>.any_instance.stubs(:valid?).returns(false) + put :update, :id => <%= class_name %>.first + response.should render_template(:edit) + end + + it "update action should redirect when model is valid" do + <%= class_name %>.any_instance.stubs(:valid?).returns(true) + put :update, :id => <%= class_name %>.first + response.should redirect_to(<%= item_path_for_spec('url') %>) + end -- cgit v1.2.3