Rspec does not create poltergeist database records

I have terrible problems getting Poltergeist and RSpec to play together.

I wrote the following test:

  it "allows the trainer to view a runner" do
    visit '/'
    all(:xpath,'//a[@id="get-started"]').first.click
    fill_in :name, with: "New Admin"
    fill_in :email, with: "admin@test.org"
    fill_in :password, with: "letmein"
    fill_in :password_confirmation, with: "letmein"
    all(:xpath,'//input[@id="get-started-submit"]').first.click
    @runner_1 = FactoryGirl.create(:runner, name: "Axel", email: "axel@test.org")
    visit '/runners/axel'
    debugger

In fact, what is stated above is registering the “new administrator” with the password “letmein” and then trying to view the runner’s profile page for “Axel”.

If the debugger breaks, I see that @ runner_1 (Axel) was created:

Runner.friendly.find('axel')

>> #<Runner id: 2, email: "axel.manzano@hotmail.fr",........>

However, when trying to visit '/ runners / axel', the Poltergeist reports:

ActiveRecord::RecordNotFound

This is not a problem with routes, or anything like that.

Having studied this error a little further, in fact, it seems that anything created in the test file is not actually installed in the environment available to Poltergeist.

I can’t understand why. Any help was greatly appreciated.

+4
1

, " " rspec. , , , .

/ , . Poltergeist , , , rspec ( rspec).

capybara. , rspec-rails - DatabaseCleaner reset .

, , , , - tranasactions .

+4

All Articles