require 'spec_helper'

describe 'Customer leave a comment for fixxpert' do
  it 'should fail with empty comment' do
    fixxpert = create :fixxpert
    customer = create :customer

    login_as_user customer
    click_link 'Fixxpert'
    click_link 'Find a fixxpert'
    click_link "show_fixxpert_#{fixxpert.id}"

    click_button 'post_comment'
    page.should have_content "Can't create the comment"
  end

  it 'should create the comment' do
    fixxpert = create :fixxpert
    customer = create :customer

    login_as_user customer
    click_link 'Fixxpert'
    click_link 'Find a fixxpert'
    click_link "show_fixxpert_#{fixxpert.id}"

    fill_in 'comment_text', with: 'Comment content'
    click_button 'post_comment'
    page.should have_content 'Comment created'

    within '#comments' do
      page.should have_content 'Comment content'
    end

  end

end
