Error performing continuous integration test - Travis-CI

2

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

link

Well, the error is quite clear, saying that it is not finding the data and so the error returns.

To do so, I created some Factories to test my models. They are inserted into the bank 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, apparently this does not happen in Travis-CI. Someone has already gone through this and can give a solution.

    
asked by anonymous 17.02.2014 / 18:57

1 answer

2

Although you have set the factory, looking for yours spec it seems to me that you are not creating the object before the test.

Is it possible that your test failed in TravisCI simply because the tests ran in a different order than when it ran locally, thereby also giving a different result? It is important to note 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.

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

For example:

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

  # ... código aqui ...
  get :show, :title => article.title
  # ...
end
    
19.02.2014 / 01:14