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

undefined method `html_tag' while testing with rspec and spork #20

Closed
amuino opened this issue Aug 15, 2012 · 5 comments
Closed

undefined method `html_tag' while testing with rspec and spork #20

amuino opened this issue Aug 15, 2012 · 5 comments

Comments

@amuino
Copy link

amuino commented Aug 15, 2012

I'm using html_tag fine in development, staging and test environments, but it raises an error when using rspec with spork to test the controllers and render_views is used.

  ActionView::Template::Error:
       undefined method `html_tag' for #<#<Class:0x007fbdbd769440>:0x007fbdbb895d20>

I have the gem declared outside of any scope, so it is available for the test environment.

It works fine when used outside of spork (rspec --no-drb spec/whatever_spec.rb)

I've tried to manually add the helpers on the prefork and each_run blocks without any effect.

Any suggestions or workarounds?

@sporkd
Copy link
Owner

sporkd commented Aug 20, 2012

I'm not totally sure what's going on with that. I'm using spork on projects and am not having any issues. But I'm posting my Gemfile and spec_helper in case it helps:

gem 'html5-rails'

group :assets do
  gem 'compass-rails'
  gem 'compass-h5bp'
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'therubyracer', :platforms => :ruby
  gem 'uglifier', '>= 1.0.3'
end

spec_helper.rb:

require 'rubygems'
require 'spork'

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'

  RSpec.configure do |config|
    config.use_transactional_fixtures = true
    config.infer_base_class_for_anonymous_controllers = false
    config.mock_with :rspec
  end
end

Spork.each_run do
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
end

@joegatt
Copy link

joegatt commented Sep 26, 2012

@amuino did you ever solve this? I'm having the same issue. If I temporarily replace the html_tag with %html, then it throws an error on google_account_id. Outside of Spork, tests work fine.

@amuino
Copy link
Author

amuino commented Sep 26, 2012

No, not solved. I tried a few things but couldn't make it work.

@joegatt
Copy link

joegatt commented Jan 8, 2013

@amuino - In case you're still dealing with this, I finally realised that this was being caused by a spork issue sporkrb/spork#109 . Applying the workaround mentioned here - sporkrb/spork#140 - solved it for me.

@amuino
Copy link
Author

amuino commented Jan 8, 2013

@joegatt thanks, solved the errors for me.

I'm closing this issue since the cause seems to be spork itself.

@amuino amuino closed this as completed Jan 8, 2013
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

3 participants