Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) CodesController admin pages #create posts a new code post
- Failure/Error:
- post :create, params: {
- code: {
- created_at: Date.today,
- title: "Code things",
- content: "The content of the code post",
- user_id: user.id
- }
- }
- ActionController::UrlGenerationError:
- No route matches {:action=>"create", :code=>{:created_at=>Fri, 20 Oct 2017, :title=>"Code things", :content=>"The content of the code post", :user_id=>1}, :controller=>"codes"}
- 2) CodesController admin pages #edit edits a code post
- Failure/Error: get :edit, params: { id: code }
- ActionController::UrlGenerationError:
- No route matches {:action=>"edit", :controller=>"codes", :id=>#<Code id: 1, title: "Code post title", content: "Coding speak that not everyone can understand...", created_at: "2017-10-20 00:00:00", updated_at: "2017-10-21 06:05:27", user_id: 2>}
- 3) CodesController admin pages #update updates a code post
- Failure/Error: put :update, params: { id: code, code: code2 }
- ActionController::UrlGenerationError:
- No route matches {:action=>"update", :code=>{:title=>"Updated title", :content=>"Updated content"}, :controller=>"codes", :id=>#<Code id: 1, title: "Code post title", content: "Coding speak that not everyone can understand...", created_at: "2017-10-20 00:00:00", updated_at: "2017-10-21 06:05:27", user_id: 2>}
- RSpec.describe User::CodesController, type: :controller do
- let!(:user) { User.create(email: "user@example.com", password: "password") }
- let!(:code) { FactoryGirl.create(:code) }
- before do
- sign_in_as user
- expect(response).to have_http_status(:success)
- end
- describe "admin pages" do
- render_views
- context "#create" do
- it "posts a new code post" do
- post :create, params: {
- code: {
- created_at: Date.today,
- title: "Code things",
- content: "The content of the code post",
- user_id: user.id
- }
- }
- expect(response).to redirect_to user_codes_path
- expect(flash[:success]).to eq "Post created successfully."
- end
- end
- context "#edit" do
- it "edits a code post" do
- get :edit, params: { id: code }
- expect(response).to render_template :edit
- end
- end
- context "#update" do
- let(:code2) do
- { title: "Updated title", content: "Updated content" }
- end
- it "updates a code post" do
- put :update, params: { id: code, code: code2 }
- code.reload
- expect(response).to redirect_to user_code_path(code)
- expect(code.title).to eq code2[:title]
- expect(code.content).to eq code2[:content]
- expect(flash[:success]).to eq "Post updated successfully."
- end
- end
- end
- end
- FactoryGirl.define do
- factory :code do
- created_at Date.today
- title "Code post title"
- content "Coding speak that not everyone can understand..."
- association :user, factory: :user
- end
- factory :life do
- created_at Date.today
- title "Life post title"
- content "The world moves in mysterious ways; whether we want it to..."
- association :user, factory: :user
- end
- end
- rspec ./spec/controllers/user/codes_controller_spec.rb[1:1:1:1,1:1:2:1,1:1:3:1,1:1:4:1,1:1:5:1] ./spec/controllers/user/lives_controller_spec.rb[1:1:1,1:1:2] ./spec/features/admin_create_posts_spec.rb[1:1,1:2,1:3,1:4] ./spec/features/admin_edit_post_spec.rb[1:1,1:2,1:3] ./spec/features/clearance/user_signs_out_spec.rb[1:1] ./spec/features/clearance/visitor_resets_password_spec.rb[1:1,1:2,1:3,1:4,1:5,1:6] ./spec/features/clearance/visitor_signs_in_spec.rb[1:1,1:2,1:3,1:4,1:5,1:6,1:7,1:8] ./spec/features/clearance/visitor_signs_up_spec.rb[1:1,1:2,1:3,1:4,1:5,1:6,1:7,1:8] ./spec/features/clearance/visitor_updates_password_spec.rb[1:1,1:2,1:3] ./spec/features/homepage_spec.rb[1:1,1:2] ./spec/features/login_users_spec.rb[1:1,1:2] ./spec/features/logout_user_spec.rb[1:1] ./spec/features/showing_all_posts_spec.rb[1:1,1:2] ./spec/helpers/codes_helper_spec.rb[1:1] ./spec/helpers/lives_helper_spec.rb[1:1] ./spec/helpers/user/codes_helper_spec.rb[1:1] ./spec/helpers/user/lives_helper_spec.rb[1:1] ./spec/helpers/users_helper_spec.rb[1:1] ./spec/helpers/welcome_helper_spec.rb[1:1] ./spec/models/code_spec.rb[1:1] ./spec/models/life_spec.rb[1:1]
Add Comment
Please, Sign In to add comment