Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:21:30+00:00 2026-06-15T08:21:30+00:00

I’ve tried the answers to these questions: 1 , 2 . The first one

  • 0

I’ve tried the answers to these questions: 1, 2. The first one indicates it might be a caching issue (and suggests running rake tmp:clear). The second one suggests forcing ENV['RAILS_ENV'] = 'test' in spec_helper.rb since rake is run in ‘development’. I’ve also tried removing the vcr gem completely, but this has no effect either.

This comment gives more details on how the problem might be due to a dirty environment (since rake starts in ‘development’, but rspec is run in ‘test’).

The spec in question uses capybara and capybara-webkit. It passes when run via bundle exec rake spec:requests but fails when it’s run in the suite via bundle exec rake. The html that capybara sees is different in both cases, and when run in the suite it doesn’t see the element #movie_imdb_id.

I’m using gem versions rspec (2.11.0), capybara (1.1.3), and capybara-webkit (0.12.1).

Rspec message:

Failures:

  1) Imdb credits get credits should have a credits table
     Failure/Error: wait_until { page.find('#movie_imdb_id').visible? }
     Capybara::ElementNotFound:
       Unable to find css "#movie_imdb_id"
     # (eval):2:in `find'
     # ./spec/requests/imdb_credits_spec.rb:9:in `block (3 levels) in <top (required)>'
     # ./spec/requests/imdb_credits_spec.rb:9:in `block (2 levels) in <top (required)>'

spec_helper.rb:

ENV["RAILS_ENV"] = 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'database_cleaner'
require 'paper_trail'
require 'factory_girl'
require 'vcr'
require 'imdb_patch'
require 'capybara/rails'
# require 'capybara/rspec'
require 'capybara/webkit'

ENV['APP_DOMAIN'] = 'www.example.com'
ENV['DOMAIN'] = 'example.com'

# Require the fanatic and food factories
require Fanatic::Engine.config.root + 'spec/factories'
Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f}

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  config.include Warden::Test::Helpers
  config.include PostsHelper
  config.include SpecHelpers

  Capybara.javascript_driver = :webkit

  # ## Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  #config.fixture_path = "#{::Rails.root}/spec/fixtures"

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = false

  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
    PaperTrail.enabled = false
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    Rails.cache.clear
    DatabaseCleaner.clean
    Warden.test_reset!
  end

  # If true, the base class of anonymous controllers will be inferred
  # automatically. This will be the default behavior in future versions of
  # rspec-rails.
  config.infer_base_class_for_anonymous_controllers = false

  config.include FactoryGirl::Syntax::Methods
end

VCR.configure do |c|
  c.ignore_localhost = true
  c.hook_into :fakeweb
  c.cassette_library_dir = Rails.root.join('spec/fixtures/vcr_cassettes')
end

spec/requests/imdb_credits_spec.rb:

require 'spec_helper'

describe 'Imdb credits', :js => true do
  before(:each) do
    login_as_admin

    visit '/admin/movie/new'
    Rails.logger.debug page.html.to_yaml
    wait_until { page.find('#movie_imdb_id').visible? }

    fill_in 'Title',   :with => 'Batman'
    fill_in 'Imdb id', :with => '0096895'

    VCR.use_cassette('imdb_get', :match_requests_on => [get_matcher]) do
      click_button 'Fetch Imdb credits'
      wait_until { page.find('table#imdb_credits').visible? }
    end
  end

  describe 'get credits' do

    it 'should have a credits table' do
      page.should have_selector('table#imdb_credits')
    end

  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:21:31+00:00Added an answer on June 15, 2026 at 8:21 am

    The problem was actually the gem rails_admin and how it was interacting with rake. It was fixed by adding the following to spec_helper.rb:

    ENV['SKIP_RAILS_ADMIN_INITIALIZER'] = 'false'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.