require 'rails_helper.rb'
feature 'Creating posts' do
scenario 'can create a post' do
visit '/'
click_link 'New Post'
attach_file('Image', "spec/files/images/coffee.jpg")
fill_in 'Caption', with: 'nom nom nom #coffeetime'
click_button 'Create Post'
expect(page).to have_content('#coffeetime')
expect(page).to have_css("img[src*='coffee.jpg']")
end
end
So I am trying to run this rspec test and I keep getting the error
Failure/Error: expect(page).to have_content('#coffeetime') expected to find text "#coffeetime" in "Photogram New Po st" # ./spec/features/creating_posts_spec.rb:10:in `block (2 l evels) in '
I have checked everything I can think of. I am following a tutorial and have triple checked everything. Any help would be greatly appreciated. Below is the controller for Post.
def create
@post = Post.create(post_params)
redirect_to @post
end
def show
@post = Post.find(params[:id])
end
private
def post_params
params.require(:post).permit(:caption, :image)
end
end
Here is the log info:
Started POST "/posts" for 127.0.0.1 at 2017-04-09 19:56:48 -0700
Processing by PostsController#create as HTML
Parameters: {"utf8"=>"✓", "post"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x0055c20c7dc7a0 @tempfile=#<Tempfile:/tmp/RackMultipart20170409-14588-93g7fy.jpg>, @original_filename="coffee.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"coffee.jpg\"\r\nContent-Type: image/jpeg\r\nContent-Length: 186616\r\n">, "caption"=>"nom nom nom #coffeetime"}, "commit"=>"Create Post"}
Command :: file -b --mime '/tmp/24eb05d18318ac2db8b2b959315d10f220170409-14588-ra9l7x.jpg'
[1m[35m (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
Command :: file -b --mime '/tmp/24eb05d18318ac2db8b2b959315d10f220170409-14588-ok0ki4.jpg'
[1m[35m (0.0ms)[0m [1m[31mROLLBACK TO SAVEPOINT active_record_1[0m
[1m[35m (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
Command :: file -b --mime '/tmp/24eb05d18318ac2db8b2b959315d10f220170409-14588-1pbpoah.jpg'
[1m[35m (0.0ms)[0m [1m[31mROLLBACK TO SAVEPOINT active_record_1[0m
Rendering posts/new.html.haml within layouts/application
Rendered posts/new.html.haml within layouts/application (2.5ms)
Completed 200 OK in 15ms (Views: 5.1ms | ActiveRecord: 0.2ms)
[1m[35m (0.1ms)[0m [1m[31mrollback transaction[0m
[1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m