Error running continuous integration test - Travis-CI

Asked

Viewed 223 times

2

For learning purposes I am using the services of Travis-CI to carry out the integration tests continues on a personal project. When running the test locally all pass, no errors. However, when running in Travis-CI there is this return.

https://travis-ci.org/luizpicolo/website-ruby-rspec-mongodb/builds/19042099

Well, the error is very clear, saying that you are not finding the data and so the error return.

To do so, I created some Factories to test my models. They are inserted into the database during the process.

FactoryGirl.define do
  factory :article do 
    title "Title for Test"
    description ""
    body "Body for Test"
    position_image_highlighted "none"
  end

  factory :tag do
    name "Name for Test"
  end

  factory :slide do
    title   "Title for Test"
    link    "Link for test"
    image   "Image way for test"
  end
end

However, and apparently, this does not happen in Travis-CI. Someone has already been through this and can give a solution.

1 answer

2


Though you set the Factory, looking for your spec I don’t think you’re creating the object before the test.

Is it possible that your test failed Travisci simply because the tests ran in a different order than when it ran locally, so it also gave a different result? It is important to bear in mind that rspec purposely runs the specs in a random order, and the tests should be as atomic and independent as possible to avoid problems with this aspect.

To create the object, you must use the method let to define the article you will access - you can read more about this method (and the variant let!) here.

For example:

describe ArticleController
  let(:article) { FactoryGirl.create(:article) }

  # ... código aqui ...
  get :show, :title => article.title
  # ...
end
  • 1

    My perfect friend reply. Thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.