0

I have the following test that works in Rack::Test but not using Selenium. I.e. if I add , js: true to the describe block, I get an error message in Firefox saying that it couldn't find the License with id=(the id of @l)

describe "should hide allocation rule # for pdf & clickthrough licenses" do

  it "reads current state and shows/hides fields appropriately" do                                     
    @l = FactoryGirl.create(:license:,
                          way: License::CLICK_WAY)                                                                                      
    visit edit_admin_license_path(@l)                                                                                           
  end
end

Why? I must be missing something. I can verify with Sequel Pro that the record is not getting saved when using js: true.

I need this spec to run in Selenium because I have javascript to test.

Ivan -Oats- Storck
  • 4,096
  • 3
  • 30
  • 39
  • Try checking `log/test.log` and verify that the correct actions are being reached. You could also add `save_and_open_page` after `visit` to show the page in a browser. – zetetic Aug 07 '12 at 23:15
  • Might have something to do with your database strategy, could you include `spec_helper.rb`? – Chris Salzberg Aug 07 '12 at 23:43

1 Answers1

0

The simple solution was to turn transactional fixtures off.

Why does my Cucumber test fail when run with Selenium?

in spec/spec_helper.rb:

RSpec.configure do |config|
  config.use_transactional_fixtures = false

  config.before :each do
    if Capybara.current_driver == :rack_test
      DatabaseCleaner.strategy = :transaction
    else
      DatabaseCleaner.strategy = :truncation
    end
    DatabaseCleaner.start
  end

  config.after do
    DatabaseCleaner.clean
  end
end

and in the Gemfile, test section

gem 'database_cleaner'
Community
  • 1
  • 1
Ivan -Oats- Storck
  • 4,096
  • 3
  • 30
  • 39