BenU
BenU

Reputation: 2317

Rails 3.2 Debugging rspec, capybara using launchy, save_and_open_page not working

I'm trying to use launchy to tell why my specs aren't working but save_and_open_page fails to open a browser and only results in the following error message when I run my specs:

Sorry, you need to install launchy (gem install launchy) and make sure it's available to open pages with save_and_open_page.

I've run bundle install and bundle show launchy yields:

/Users/benjaminunger/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/launchy-2.2.0

My Gemfile:

group :development, :test do 
  gem "rspec-rails", "~> 2.13.0"
  gem 'guard-rspec', '0.5.5'
  gem 'growl', '1.0.3'
  gem 'ruby_gntp', "0.3.4"
  gem 'faker', '1.0.1'
end

group :development do
  gem 'annotate', '~> 2.4.1.beta'
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'rb-fsevent', '0.4.3.1', :require => false
  gem 'guard-spork', '0.3.2'
  gem 'spork', '0.9.2'
  gem 'factory_girl_rails', '1.4.0'
  gem "database_cleaner", "~> 0.9.1"
  gem "launchy", "~> 2.2.0"
end

Partial Spec file:

  describe "clicking on 'Unapproved Users' link" do

    before(:all)  { User.delete_all } 
    before(:all) { 8.times { FactoryGirl.create(:not_approved) } }
    let(:unapproved) { FactoryGirl.create(:not_approved) }
    let(:admin) { FactoryGirl.create(:admin) }
    after(:all)  { User.delete_all }


    before do
      valid_signin(admin)
      visit root_path
      click_link "Unapproved Users"
      save_and_open_page
    end

    it { should have_selector('h1',    text: 'Unapproved Users') }
    it { should have_selector('title', text: 'Unapproved Users') }
    it { should have_link('approve', href: approve_user_path(User.first.id)) }
.
.
.

Anyone have any ideas? Much thanks in advance.

Upvotes: 1

Views: 2572

Answers (2)

Pysis
Pysis

Reputation: 1596

For me I was just not accustomed to using Bundler.

I had done a manual gem install (with RVM present and set-up on my system), but I neglected to add it to the Gemfile. When running the Cucumber tests, it probably created a context from that file that did not include Launchy.

When adding it there, the step worked.

Upvotes: 0

BenU
BenU

Reputation: 2317

I'm embarrassed to say that I needed to stop and restart spork. Perhaps this question will help someone else with the same situation.

Upvotes: 5

Related Questions