ActiveRecord::StatementInvalid: PG::ConnectionBad: PQsocket() can't get socket descriptor: BEGIN
<p>I'm new in watir and I'm trying to use watir to test my rails app. I have next code:</p>

<pre><code>require 'watir_helper'
require 'spec_helper'

RSpec.feature 'Questions hub', type: :request do
  let!(:user) { create(:user, email: 'test1@example.com', name: 'John', last_name: 'Stivens') }
  let!(:question) { create(:question, created_at: 'August 25, 2016', user: user) }

  describe 'Comments feature' do
    context 'When user signed in' do
      def sign_in_user
        goto new_user_session_path
        text_field(name: 'user[email]').set('test1@example.com')
        text_field(name: 'user[password]').set('12345678')
        button(name: 'commit').click
      end

      def visit_question_page_and_post_answer
        goto question_path(question)
        textarea(id: 'answer_content').set('Lorem Ipsum')
        button(name: 'commit').click
      end

      def add_comment_to_answer
        link(text: 'comments (0)').click
        link(text: 'Add Comment').when_present.click
        textarea(name: 'comment[content]').set('MyComment')
        button(name: 'commit').click
      end

      before do
        sign_in_user
        visit_question_page_and_post_answer
      end

      it "Check comments count when it's empty" do
        text.include? 'comments (0)'
      end

      it "Add comment to question's answer" do
        add_comment_to_answer

        text.include? 'MyComment'
        text.include? 'comments (1)'
      end

      it 'Comment has link to user profile' do
        add_comment_to_answer
        div(class: 'user-name-w').link(text: 'John Stivens').click # problem happens here
      end
    end
  end
end
</code></pre>

<p>And when I have next line in the code:</p>

<pre><code>div(class: 'user-name-w').link(text: 'John Stivens').click
</code></pre>

<p>this test fails with error:</p>

<pre><code>ActiveRecord::StatementInvalid: PG::ConnectionBad: PQsocket() can't get socket descriptor: BEGIN
</code></pre>

<p>But if to conmment 2 previous tests, the third test (where problem happens) will pass.</p>