title: Why does an rspec feature spec with javascript not do test teardown?
body: <p>I have several non-javascript specs that use the ui to create and edit records.
  When I run these specs the test database records are automatically removed for me by the rspec teardown for each test.</p>
  
  <p>However the test below which is the first one to have <code>:js =&gt; true</code> for some ajax stuff isn't doing tear down of the records afterwards and then tests start to break because the database is no longer empty correctly when they start.  The link and the group rows still exist in the test database.</p>
  
  <pre><code># spec/features/verifying_link_spec.rb 
  require 'spec_helper'
  
  describe "verification", :js =&gt; true, :type =&gt; :feature do
  
    before :all do
      User.create(:username =&gt; 'r@google.com', :password =&gt; 'esceptio')
    end 
  
    before :each do
      visit '/ladmin/login'
      fill_in 'username', :with =&gt; 'r@google.com'
      fill_in 'password', :with =&gt; 'esceptio'
      find('input[value="Login"]').click
    end 
  
    it "lets me verify a link" do
      find('div#side div a', text: 'New Group').click
      fill_in 'group[group_name]', with: 'Group Add'
      click_button 'Save'
      find('div#side div a', text: 'New Link').click
      fill_in 'link[url_address]', with: 'http://www.a.com/newtest9876link'
      fill_in 'link[alt_text]', with: 'abcd9876'
      click_button 'Save'
      this_year=Time.now.strftime('%Y')
      l=Link.first
      l.update_attribute(:verified_date, nil)
      expect(Link.count).to eq 1
      visit links_path
      find('a', text: "verify")
      click_link("verify", match: :first)
      sleep(3)
      expect(page).to have_content(this_year)
    end 
  
  end
  </code></pre>
  
  <p>Right now I am using a workaround solution of using the ui to delete the records (below) but this should not be necessary</p>
  
  <pre><code>    # added at bottom of spec
      click_link('Details')
      click_link('Delete')
      page.driver.browser.switch_to.alert.accept
      click_link('Groups')
      click_link('Delete')
      page.driver.browser.switch_to.alert.accept
  </code></pre>
  
  <p>None of my other unit tests or feature tests (except this one with js) have this problem.  They all create records that get removed automatically.</p>