Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

making tests work without cleaning db

  • Loading branch information...
commit ecf657e96d96c97a288a33ee1f668d57f0daf679 1 parent f1c0c20
@elado elado authored
Showing with 13 additions and 6 deletions.
  1. +12 −5 spec/neoid/search_spec.rb
  2. +1 −1  spec/spec_helper.rb
View
17 spec/neoid/search_spec.rb
@@ -18,25 +18,32 @@ class Article < SuperModel::Base
end
end
+ let(:unique) { Time.now.to_f.to_s.gsub('.', '') }
+
it "should index and find node in fulltext" do
- Neoid.db.create_node_index("x_idx", "fulltext", "lucene")
+ index_name = "test_index_#{unique}"
+ Neoid.db.create_node_index(index_name, "fulltext", "lucene")
n = Neography::Node.create(name: "test hello world", year: 2012)
- Neoid.db.add_node_to_index("x_idx", "name", n.name, n)
- Neoid.db.add_node_to_index("x_idx", "year", n.year, n)
+ Neoid.db.add_node_to_index(index_name, "name", n.name, n)
+ Neoid.db.add_node_to_index(index_name, "year", n.year, n)
[
"name:test",
"year:2012",
"name:test AND year:2012"
].each { |q|
- results = Neoid.db.find_node_index("x_idx", q)
+ results = Neoid.db.find_node_index(index_name, q)
results.length.should == 1
Neoid.db.send(:get_id, results).should == n.neo_id
}
end
it "should index item on save" do
+ index_name = "articles_search_index_#{unique}"
+
+ Article.stub!(:neo_search_index_name).and_return(index_name)
+
article = Article.create!(name: "Hello world", body: "Lorem ipsum dolor sit amet", year: 2012)
[
@@ -44,7 +51,7 @@ class Article < SuperModel::Base
"year:2012",
"name:Hello AND year:2012"
].each { |q|
- results = Neoid.db.find_node_index("articles_search_index", q)
+ results = Neoid.db.find_node_index(index_name, q)
results.should_not be_nil
results.length.should == 1
Neoid.db.send(:get_id, results).should == article.neo_node.neo_id
View
2  spec/spec_helper.rb
@@ -23,7 +23,7 @@
config.mock_with :rspec
config.before(:all) do
- Neoid.clean_db(:yes_i_am_sure)
+ Neoid.clean_db(:yes_i_am_sure) unless ENV['TRAVIS']
end
config.before(:each) do

0 comments on commit ecf657e

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