require 'rails_helper.rb'
require 'spec_helper.rb'

feature 'Creating posts' do
  scenario 'can create a post' do
    visit '/'
    click_link 'New Post'
    attach_file('Image', "spec/files/images/espresso.jpg")
    fill_in 'Caption', with: 'nom nom nom #coffeetime'
    click_button 'Publish'
    expect(page).to have_content('#coffeetime')
    expect(page).to have_css("img[src*='espresso.jpg']")
  end
end

require 'rails_helper.rb'
require 'spec_helper.rb'

feature 'Creating posts' do
  scenario 'can create a post' do
    visit '/'
    click_link 'New Post'
    attach_file("post_image", "spec/files/images/espresso.jpg", visible: false)
    fill_in 'Caption', with: 'nom nom nom #coffeetime'
    click_button 'Publish'
    expect(page).to have_content('#coffeetime')
    expect(page).to have_css("img[src*='espresso.jpg']")
  end
end

Fix failing Capybara test for file attachment
Fix failing Capybara test for file attachment

Tutorial called for first argument in test to be 'image' but per a Treehouse tutorial class or id needs to be specificed as Rails will nest it, i.e. 'post' object and image becomes 'post_image.' Otherwise, error is 'file field not found.'
