4

I'm using Turnip and Ruby on Rails. I have scenarios with and without using javascript. I want to use the transaction DatabaseCleaner strategy for the non-javascript scenarios and the truncation strategy for scenarios marked by @javascript, @selenium and etc.

I'm using following solution for Rspec Features

config.around(:each, :js => true) do |ex|
  DatabaseCleaner.strategy = :truncation
  ex.run
  DatabaseCleaner.strategy = :transaction
end

But it doesn't work in Turnip case. What is the best way to make it works as I expected? Or in other words how to specify turnip scenario marked by @javascript (or @selenium and etc) tag in config.before?

petRUShka
  • 9,812
  • 12
  • 61
  • 95

1 Answers1

5

By inspecting the code of Turnip I yield such config options

 config.around(:each, type: :feature, javascript: true) do |example|
   DatabaseCleaner.strategy = :truncation
   example.run
   DatabaseCleaner.strategy = :transaction
 end

In this case strategy is set to truncation when scenario is tagged by @javascript tag like following:

  @javascript
  Scenario: Viewing users
    Given the following users:

But in my soultion when you want to use for example Selenium in one scenario you should not replace @javascrtipt tag by @selenium tag but add @selenium tag after @javascript tag like following

  @javascript @selenium
  Scenario: Viewing users
    Given the following users:
petRUShka
  • 9,812
  • 12
  • 61
  • 95