prashantsahni
prashantsahni

Reputation: 2197

RSpec, Capybara, and Selenium with Rails 4

I have upgraded my application from Rails 3.2 to Rails 4. I am using RSpec, Capybara, and selenium-webdriver.

All my test cases were running with Rails 3.2, but as soon as I upgraded Rails, my integration tests stopped running. All the controller and model tests run fine.

Here is my code

require 'spec_helper'

describe "Describe your business to the system (Sunny Day Scenario)", :js => true do

  before do
    FactoryGirl.create(:feature_industry)
    FactoryGirl.create(:feature_synonym)
    visit simulation_path
  end

  it "Fill out the intro page form" do
    attributes = saucey_cranberry
    click_start_test_button(true)
    expect(page).to  have_content "See what a business loan through CAN Capital can do:"
    fill_in "reported_business_industry_selected", with: "food"
    sleep(2)
    page.execute_script(%Q[$(".dropdown_list_sic:first").trigger('mouseenter').click();])
    fill_in "desired_funding_amount", with: attributes[:desired_funding_amount]
    fill_in "funding_reason", with: attributes[:funding_reason]
    fill_in "get_reported_business_name", with: attributes[:reported_business_name]
    fill_in "reported_monthly_income", with: attributes.fetch(:reported_monthly_income)
    select(attributes[:time_in_business], from: 'time_in_business')
    click_button 'Get Started'
    page.current_path.should eq('/enroll/business-loan-calculator')
    #have_content 'Enter your gross monthly sales'
  end
end

When I run my integration tests, Selenium runs them inside the Mozilla browser and executes all the steps successfully. When it reaches the line page.current_path.should eq('/enroll/business-loan-calculator') or if i put page.should have_content('some content...'), these statements do not execute. The browser closes automatically (which it should), but I do not see whether the tests pass or fail.

Upvotes: 0

Views: 652

Answers (1)

user3883450
user3883450

Reputation: 9

Check if your previous statements are passing

fill_in "reported_monthly_income", with: attributes.fetch(:reported_monthly_income)
select(attributes[:time_in_business], from: 'time_in_business')
click_button 'Get Started'

If its not passing then the things ahead wont work.

Upvotes: 0

Related Questions