Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

making tests work without cleaning db

  • Loading branch information...
commit ecf657e96d96c97a288a33ee1f668d57f0daf679 1 parent f1c0c20
Elad Ossadon elado authored

Showing 2 changed files with 13 additions and 6 deletions. Show diff stats Hide diff stats

  1. +12 5 spec/neoid/search_spec.rb
  2. +1 1  spec/spec_helper.rb
17 spec/neoid/search_spec.rb
@@ -18,25 +18,32 @@ class Article < SuperModel::Base
18 18 end
19 19 end
20 20
  21 + let(:unique) { Time.now.to_f.to_s.gsub('.', '') }
  22 +
21 23 it "should index and find node in fulltext" do
22   - Neoid.db.create_node_index("x_idx", "fulltext", "lucene")
  24 + index_name = "test_index_#{unique}"
  25 + Neoid.db.create_node_index(index_name, "fulltext", "lucene")
23 26
24 27 n = Neography::Node.create(name: "test hello world", year: 2012)
25   - Neoid.db.add_node_to_index("x_idx", "name", n.name, n)
26   - Neoid.db.add_node_to_index("x_idx", "year", n.year, n)
  28 + Neoid.db.add_node_to_index(index_name, "name", n.name, n)
  29 + Neoid.db.add_node_to_index(index_name, "year", n.year, n)
27 30
28 31 [
29 32 "name:test",
30 33 "year:2012",
31 34 "name:test AND year:2012"
32 35 ].each { |q|
33   - results = Neoid.db.find_node_index("x_idx", q)
  36 + results = Neoid.db.find_node_index(index_name, q)
34 37 results.length.should == 1
35 38 Neoid.db.send(:get_id, results).should == n.neo_id
36 39 }
37 40 end
38 41
39 42 it "should index item on save" do
  43 + index_name = "articles_search_index_#{unique}"
  44 +
  45 + Article.stub!(:neo_search_index_name).and_return(index_name)
  46 +
40 47 article = Article.create!(name: "Hello world", body: "Lorem ipsum dolor sit amet", year: 2012)
41 48
42 49 [
@@ -44,7 +51,7 @@ class Article < SuperModel::Base
44 51 "year:2012",
45 52 "name:Hello AND year:2012"
46 53 ].each { |q|
47   - results = Neoid.db.find_node_index("articles_search_index", q)
  54 + results = Neoid.db.find_node_index(index_name, q)
48 55 results.should_not be_nil
49 56 results.length.should == 1
50 57 Neoid.db.send(:get_id, results).should == article.neo_node.neo_id
2  spec/spec_helper.rb
@@ -23,7 +23,7 @@
23 23 config.mock_with :rspec
24 24
25 25 config.before(:all) do
26   - Neoid.clean_db(:yes_i_am_sure)
  26 + Neoid.clean_db(:yes_i_am_sure) unless ENV['TRAVIS']
27 27 end
28 28
29 29 config.before(:each) do

0 comments on commit ecf657e

Please sign in to comment.
Something went wrong with that request. Please try again.