Rails Paths

Capsule Coding
3 min readOct 4, 2020
new post
ensures that the form route works with the /new action (FAILED - 1)
Failures:1) new post ensures that the form route works with the /new action
Failure/Error: visit new_post_path

NameError:
undefined local variable or method `new_post_path' for #<RSpec::ExampleGroups::NewPost:0x00007fc40eb275a8>
Did you mean? new_polymorphic_path
# ./spec/features/post_spec.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.00152 seconds (files took 1.56 seconds to load)
1 example, 1 failure
Failed examples:rspec ./spec/features/post_spec.rb:4 # new post ensures that the form route works with the /new actionFailure number 1 tells us that

> Failure/Error: visit new_post_path<.

This is the error, we have no way to visit the new_post_path. So in this error that is what we see.

> undefined local variable or method `new_post_path’ for #<

this is telling us that we have an undefined variable for or method for the new post path for our route.

>rspec ./spec/features/post_spec.rb:4 # new post ensures that the form route works with the /new action<

our spec is telling us that the new post path ensures that the route form works with /new or :new *BELOW*

new post
ensures that the form route works with the /new action (FAILED - 1)
Failures:1) new post ensures that the form route works with the /new action
Failure/Error: visit new_post_path

AbstractController::ActionNotFound:
The action 'new' could not be found for PostsControllerOnce we add in the /new post path we run our code to check again we get

> Failure/Error: visit new_post_path< >AbstractController::ActionNotFound:
The action ‘new’ could not be found for PostsController<

This is telling us we need to update our PostsController So lets add a new action to our PostsController!

def new
end

ABOVE

this gives our route a connection with our controller and complete that test.

Capsules-MacBook-Pro:rails-form_tag-readme-onl01-seng-pt-052620 capsule$ LEARNnew post
pass ensures that the form route works with the /new action
fail renders HTML in the /new template (FAILED - 1)
Failures:1) new post renders HTML in the /new template
Failure/Error: expect(page).to have_content('Post Form')
expected to find text "Post Form" in ""
# ./spec/features/post_spec.rb:11:in `block (2 levels) in <top (required)>'
Finished in 0.30258 seconds (files took 1.37 seconds to load)
2 examples, 1 failure
Failed examples:rspec ./spec/features/post_spec.rb:9 # new post renders HTML in the /new template

So now we need to

>renders HTML in the /new template (FAILED — 1)<

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Capsule Coding
Capsule Coding

No responses yet

Write a response