Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred in an after hook #9

Open
bismark64 opened this issue Aug 26, 2013 · 7 comments
Open

An error occurred in an after hook #9

bismark64 opened this issue Aug 26, 2013 · 7 comments

Comments

@bismark64
Copy link

Hi, I haven't much experience testing sunspot.. :(
Once installed the gem and set the configuration I ran rspec and got this error message:

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
Sunspot server is starting...
Sunspot server took 2.03 seconds to start

An error occurred in an after hook
  NoMethodError: undefined method `original_path_set' for nil:NilClass
  occurred at gems/rspec-rails-2.14.0/lib/rspec/rails/view_rendering.rb:121:in `block (2 levels) in <module:ViewRendering>'

What that means? I suspect that's something related with the configuration of rspec.. but I don't know what it is..

@krisleech
Copy link
Collaborator

Do you get the same error when you run a single spec which does not use Sunspot/Solr?

@bismark64
Copy link
Author

Nop.. when the spec didn't use Sunspot, it run well.. Anyway I restarted the system and it seems to work well now!
I'm using Rails 4, Rspec-rails 2.14.0, sunspot_rails branch: "Rails4"..
As I said, now it's working well.. so I'd take a look just to know if there is some inconsistency/bug..
For example in the wiki the spec_helper has this code:

config.before :each, :solr => true do
  Sunspot::Rails::Tester.start_original_sunspot_session
  Sunspot.session = $original_sunspot_session
  Sunspot.remove_all!
end

That code crashed the test, I suppose this is caused by 'Sunspot.remove_all!' since it deletes the index of the objects being created in the tests, so Sunspot doesn't find them.. when I removed that line it worked.

@krisleech
Copy link
Collaborator

Ummm, I don't have a Rails 4 project which uses Sunspot in order to reproduce this.

The odd thing is the error seems to have something to do with rspec view_rendering, which would indicate its not anything to do with sunspot-rails-tester, however if removing the Sunspot.remove_all! line fixes it then it would suggest there might be an issue. Or it could be something to do with the Rails 4 branch of sunspot.

I couldn't tell from your previous message is it working now or are you still getting the error?

@bismark64
Copy link
Author

Excuse me, i've bombarded you..
There are two sides on my "issue":
1. The original after hook error, which now doesn't happen more..
2. The call to Sunspot.remove_all! in the config created new errors.
I could make the specs pass removing Sunspot.remove_all! in the config..

@krisleech
Copy link
Collaborator

Understood, what is the new error for Sunspot.remove_all!?

Without that line the specs may pass but I think you might find that the Solr index is not deleted between specs.

I think if the Solr index returns a hit but a matching record does not exist in the database it automtically handles this and ignores the hit. This might come back to bite you later. As the index will be out of sync with whats in the database. Always best to remove all state between specs.

@bismark64
Copy link
Author

Actually it's not an error, the sunspot search simply doesn't perform..

Instead of put that line in a before(:each) I've putted it in a after(:all), and it worked well for me..

@krisleech
Copy link
Collaborator

I couldn't find a Rails 4 branch of Sunspot, can you show me what the 'sunspot' line looks like in your Gemfile.

If the search just doesn't perform its an issue with sunspot itself, not sunspot-rails-tester, however you should be able to put Sunspot.remove_all! in the before(:each) hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants