Cannot run elastic search in circleci to make my rspec for elasticsearch to pass?

1k views Asked by At

i have configured my project in github with circleci. I am using searchkick for elastic search. my code to reindex looks like this:

IN spec_helper.rb
RSpec.configure do |config|
  ....
 config.before :each do
   Location.reindex
 end
...
end

My app/models/location.rb looks like this

class Location < ActiveRecord::Base
   ...
   searchkick word_start: [:location_name], autocomplete: [:location_name]
   ...
end

My app/models/search.rb looks like this

class Search < ActiveRecord::Base
   ...
   def self.location_auto_complete(search_term)
     location_ids = Organization.locations.map(&:id)
     Location.search(search_term, fields: [{location_name: :word_start}, :from, :search_id], where: {id: location_ids}) 
   end
end

My /spec/models/search_spec.rb looks like this

 require 'rails_helper'
 describe Search, type: :model do
  before :each do

   @location = create(:location,location_name: 'kathmandu')
   @location.reindex
   Location.searchkick_index.refresh
  end
describe '.location_auto_complete(search_term)' do
it 'return location search result for the location search term' do
   expect(Search.location_auto_complete('kathmandu')).to match_array(@location)
end

end

My /myapp/config/circle.yml looks like this i followed : https://circleci.com/docs/installing-elasticsearch :

database:
  override:
# replace CircleCI's generated database.yml
- cp config/database.yml.ci config/database.yml
- bundle exec rake db:drop db:create db:migrate
machine:
  services:
   - elasticsearch

dependencies:
  post:
     - wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.0.1.tar.gz
     - tar -xvf elasticsearch-1.0.1.tar.gz
     - elasticsearch-1.0.1/bin/elasticsearch: {background: true}

 dependencies:
    cache_directories:
     - elasticsearch-1.0.1 # relative to the build directory
    post:
     - if [[ ! -e elasticsearch-1.0.1 ]]; then wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.0.1.tar.gz && tar -xvf elasticsearch-1.0.1.tar.gz; fi
   - elasticsearch-1.0.1/bin/elasticsearch: {background: true}

When i run rspec in my laptop it works fine while i push to github(which is integrated with circleci)i, status is failed. It also says:

 We didn't find a circle.yml for this build. You can specify deployment or override our inferred test steps from a circle.yml checked in to your repo's root directory.More information in our docs.
1

There are 1 answers

1
Andy Waite On BEST ANSWER

The error message says circle.yml should be in the repo's root directory, but you have it the config directory.