dining_charges

This commit is contained in:
Nweni
2017-08-11 13:34:30 +06:30
parent 14384745ad
commit b0ad2049c5
26 changed files with 428 additions and 1 deletions

View File

@@ -0,0 +1,141 @@
require 'rails_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.
#
# Also compared to earlier versions of this generator, there are no longer any
# expectations of assigns and templates rendered. These features have been
# removed from Rails core in Rails 5, but can be added back in via the
# `rails-controller-testing` gem.
RSpec.describe DiningChargesController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# DiningCharge. As you add validations to DiningCharge, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# 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
# DiningChargesController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "returns a success response" do
dining_charge = DiningCharge.create! valid_attributes
get :index, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #show" do
it "returns a success response" do
dining_charge = DiningCharge.create! valid_attributes
get :show, params: {id: dining_charge.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "GET #new" do
it "returns a success response" do
get :new, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #edit" do
it "returns a success response" do
dining_charge = DiningCharge.create! valid_attributes
get :edit, params: {id: dining_charge.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new DiningCharge" do
expect {
post :create, params: {dining_charge: valid_attributes}, session: valid_session
}.to change(DiningCharge, :count).by(1)
end
it "redirects to the created dining_charge" do
post :create, params: {dining_charge: valid_attributes}, session: valid_session
expect(response).to redirect_to(DiningCharge.last)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'new' template)" do
post :create, params: {dining_charge: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested dining_charge" do
dining_charge = DiningCharge.create! valid_attributes
put :update, params: {id: dining_charge.to_param, dining_charge: new_attributes}, session: valid_session
dining_charge.reload
skip("Add assertions for updated state")
end
it "redirects to the dining_charge" do
dining_charge = DiningCharge.create! valid_attributes
put :update, params: {id: dining_charge.to_param, dining_charge: valid_attributes}, session: valid_session
expect(response).to redirect_to(dining_charge)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'edit' template)" do
dining_charge = DiningCharge.create! valid_attributes
put :update, params: {id: dining_charge.to_param, dining_charge: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "DELETE #destroy" do
it "destroys the requested dining_charge" do
dining_charge = DiningCharge.create! valid_attributes
expect {
delete :destroy, params: {id: dining_charge.to_param}, session: valid_session
}.to change(DiningCharge, :count).by(-1)
end
it "redirects to the dining_charges list" do
dining_charge = DiningCharge.create! valid_attributes
delete :destroy, params: {id: dining_charge.to_param}, session: valid_session
expect(response).to redirect_to(dining_charges_url)
end
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the DiningChargesHelper. For example:
#
# describe DiningChargesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe DiningChargesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe DiningCharge, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "DiningCharges", type: :request do
describe "GET /dining_charges" do
it "works! (now write some real specs)" do
get dining_charges_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,39 @@
require "rails_helper"
RSpec.describe DiningChargesController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/dining_charges").to route_to("dining_charges#index")
end
it "routes to #new" do
expect(:get => "/dining_charges/new").to route_to("dining_charges#new")
end
it "routes to #show" do
expect(:get => "/dining_charges/1").to route_to("dining_charges#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/dining_charges/1/edit").to route_to("dining_charges#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/dining_charges").to route_to("dining_charges#create")
end
it "routes to #update via PUT" do
expect(:put => "/dining_charges/1").to route_to("dining_charges#update", :id => "1")
end
it "routes to #update via PATCH" do
expect(:patch => "/dining_charges/1").to route_to("dining_charges#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/dining_charges/1").to route_to("dining_charges#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "dining_charges/edit", type: :view do
before(:each) do
@dining_charge = assign(:dining_charge, DiningCharge.create!())
end
it "renders the edit dining_charge form" do
render
assert_select "form[action=?][method=?]", dining_charge_path(@dining_charge), "post" do
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "dining_charges/index", type: :view do
before(:each) do
assign(:dining_charges, [
DiningCharge.create!(),
DiningCharge.create!()
])
end
it "renders a list of dining_charges" do
render
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "dining_charges/new", type: :view do
before(:each) do
assign(:dining_charge, DiningCharge.new())
end
it "renders new dining_charge form" do
render
assert_select "form[action=?][method=?]", dining_charges_path, "post" do
end
end
end

View File

@@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.describe "dining_charges/show", type: :view do
before(:each) do
@dining_charge = assign(:dining_charge, DiningCharge.create!())
end
it "renders attributes in <p>" do
render
end
end