Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Upgrade from 'feature' to 'system' test #3568
Conversation
| @@ -94,3 +102,5 @@ | |||
|
|
|||
| Kernel.srand config.seed | |||
| end | |||
|
|
|||
houndci-bot
Mar 25, 2020
Layout/TrailingBlankLines: 2 trailing blank lines detected.
Layout/TrailingBlankLines: 2 trailing blank lines detected.
| config.before(:each, type: :system) do | ||
| driven_by :rack_test | ||
| end | ||
|
|
houndci-bot
Mar 25, 2020
Layout/TrailingWhitespace: Trailing whitespace detected.
Layout/TrailingWhitespace: Trailing whitespace detected.
| ActionView::Base.raise_on_missing_translations = true | ||
|
|
||
| Capybara.default_max_wait_time = ENV['DEFAULT_MAX_WAIT_TIME'].to_f if ENV['DEFAULT_MAX_WAIT_TIME'].present? | ||
|
|
||
| ActiveJob::Base.queue_adapter = :test | ||
|
|
||
|
|
houndci-bot
Mar 25, 2020
Layout/EmptyLines: Extra blank line detected.
Layout/EmptyLines: Extra blank line detected.
02af214
to
3368775
| @@ -93,4 +101,4 @@ | |||
| config.order = :random | |||
|
|
|||
| Kernel.srand config.seed | |||
| end | |||
| end | |||
houndci-bot
Mar 25, 2020
Layout/TrailingBlankLines: Final newline missing.
Layout/TrailingBlankLines: Final newline missing.
3368775
to
6f31382
| @@ -44,6 +44,7 @@ | |||
| Capybara.exact = true | |||
|
|
|||
| require "selenium/webdriver" | |||
| Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym | |||
coorasse
Mar 26, 2020
Contributor
why is this line necessary? isn't
config.before(:each, type: :system, js: true) do
driven_by :selenium_chrome_headless
end
already taking care of defining the driver?
why is this line necessary? isn't
config.before(:each, type: :system, js: true) do
driven_by :selenium_chrome_headless
end
already taking care of defining the driver?
gonzar11
Mar 30, 2020
•
Author
Rails uses as default :selenium . If I don't define Capybara.javascript_driver, rails will assume that we use :selenium. In my case it fails because I didn't have geckodriver( Mozilla driver used with selenium).
Then with config.before(:each, type: :system, js: true) we redefine capybara Capybara javascript driver.
Rails uses as default :selenium . If I don't define Capybara.javascript_driver, rails will assume that we use :selenium. In my case it fails because I didn't have geckodriver( Mozilla driver used with selenium).
Then with config.before(:each, type: :system, js: true) we redefine capybara Capybara javascript driver.
kennyadsl
Apr 3, 2020
•
Member
That's odd. I checked the branch locally and tried commenting this line and all the driven_by below and the result is the same. I think that for some reason it's just using the default ignoring the driven_by calls.
That's odd. I checked the branch locally and tried commenting this line and all the driven_by below and the result is the same. I think that for some reason it's just using the default ignoring the driven_by calls.
gonzar11
Apr 8, 2020
Author
I've tried to print which driver is being used. Please add this line puts Capybara.current_driver in both config.before(:each, type: :system) and config.before(:each, type: :system, js: true) before and after using driven_by. You will see the difference between use and don's use driven_by
I've tried to print which driver is being used. Please add this line puts Capybara.current_driver in both config.before(:each, type: :system) and config.before(:each, type: :system, js: true) before and after using driven_by. You will see the difference between use and don's use driven_by
kennyadsl
Apr 20, 2020
Member
Ok thanks, I'm giving it a try
Ok thanks, I'm giving it a try
kennyadsl
Apr 20, 2020
Member
if I comment out
# Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
no matter what Capybara.current_driver prints, it is opening Firefox to run specs so it's definitely not headless.
I think there's some misconfiguration happening but I couldn't get exactly where yet.
I've also tried with this syntax, which seems to be the default to make exactly the same thing that we do with our custom driver:
driven_by :selenium, using: :headless_chrome, screen_size: [1920, 1080]
but it still opens firefox to run specs. 😢
if I comment out
# Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_symno matter what Capybara.current_driver prints, it is opening Firefox to run specs so it's definitely not headless.
I think there's some misconfiguration happening but I couldn't get exactly where yet.
I've also tried with this syntax, which seems to be the default to make exactly the same thing that we do with our custom driver:
driven_by :selenium, using: :headless_chrome, screen_size: [1920, 1080]but it still opens firefox to run specs.
blocknotes
May 25, 2020
•
Contributor
@gonzar11, I worked on a similar PR in a Solidus extension (solidus_starter_frontend) and I would like to add my thoughts.
Capybara.javascript_driver = ... is not necessary; Rails testing guide (but for Minitest) says that default Capybara driver settings should be changed via driven_by;
- in my PR I choose to have 2 different variables (
CAPYBARA_DRIVER/CAPYBARA_JS_DRIVER), it can be useful sometimes;
- I made some tests in this PR commenting out the
Capybara.javascript_driver = ... line in spec_helper.rb; running a JS spec with CAPYBARA_DRIVER=selenium_chrome bin/rspec backend/spec/system/admin/configuration/payment_methods_spec.rb:36 first opens a Firefox empty window then a Chrome window with the specified test.
As a test, if I comment out the following lines, I see that it works as expected:
if RSpec.current_example.metadata[:js] && page.driver.browser.respond_to?(:url_blacklist)
page.driver.browser.url_blacklist = ['http://fonts.googleapis.com']
end
@gonzar11, I worked on a similar PR in a Solidus extension (solidus_starter_frontend) and I would like to add my thoughts.
Capybara.javascript_driver = ...is not necessary; Rails testing guide (but for Minitest) says that default Capybara driver settings should be changed viadriven_by;- in my PR I choose to have 2 different variables (
CAPYBARA_DRIVER/CAPYBARA_JS_DRIVER), it can be useful sometimes; - I made some tests in this PR commenting out the
Capybara.javascript_driver = ...line in spec_helper.rb; running a JS spec withCAPYBARA_DRIVER=selenium_chrome bin/rspec backend/spec/system/admin/configuration/payment_methods_spec.rb:36first opens a Firefox empty window then a Chrome window with the specified test.
As a test, if I comment out the following lines, I see that it works as expected:
if RSpec.current_example.metadata[:js] && page.driver.browser.respond_to?(:url_blacklist)
page.driver.browser.url_blacklist = ['http://fonts.googleapis.com']
end6f31382
to
004b9c7
| end | ||
|
|
||
| config.before(:each, type: :system, js: true) do | ||
| driven_by (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym |
houndci-bot
Mar 30, 2020
Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
| end | ||
|
|
||
| config.before(:each, type: :system, js: true) do | ||
| driven_by (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym |
houndci-bot
Mar 30, 2020
Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
| @@ -44,6 +44,7 @@ | |||
| Capybara.exact = true | |||
|
|
|||
| require "selenium/webdriver" | |||
| Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym | |||
blocknotes
May 25, 2020
•
Contributor
@gonzar11, I worked on a similar PR in a Solidus extension (solidus_starter_frontend) and I would like to add my thoughts.
Capybara.javascript_driver = ... is not necessary; Rails testing guide (but for Minitest) says that default Capybara driver settings should be changed via driven_by;
- in my PR I choose to have 2 different variables (
CAPYBARA_DRIVER/CAPYBARA_JS_DRIVER), it can be useful sometimes;
- I made some tests in this PR commenting out the
Capybara.javascript_driver = ... line in spec_helper.rb; running a JS spec with CAPYBARA_DRIVER=selenium_chrome bin/rspec backend/spec/system/admin/configuration/payment_methods_spec.rb:36 first opens a Firefox empty window then a Chrome window with the specified test.
As a test, if I comment out the following lines, I see that it works as expected:
if RSpec.current_example.metadata[:js] && page.driver.browser.respond_to?(:url_blacklist)
page.driver.browser.url_blacklist = ['http://fonts.googleapis.com']
end
@gonzar11, I worked on a similar PR in a Solidus extension (solidus_starter_frontend) and I would like to add my thoughts.
Capybara.javascript_driver = ...is not necessary; Rails testing guide (but for Minitest) says that default Capybara driver settings should be changed viadriven_by;- in my PR I choose to have 2 different variables (
CAPYBARA_DRIVER/CAPYBARA_JS_DRIVER), it can be useful sometimes; - I made some tests in this PR commenting out the
Capybara.javascript_driver = ...line in spec_helper.rb; running a JS spec withCAPYBARA_DRIVER=selenium_chrome bin/rspec backend/spec/system/admin/configuration/payment_methods_spec.rb:36first opens a Firefox empty window then a Chrome window with the specified test.
As a test, if I comment out the following lines, I see that it works as expected:
if RSpec.current_example.metadata[:js] && page.driver.browser.respond_to?(:url_blacklist)
page.driver.browser.url_blacklist = ['http://fonts.googleapis.com']
end
Description
I couldn't remove database cleaner because some specs on backends started to fail. Then I realized that it used just to truncate the database before starting run all specs. This is because some migrations are filling the database.
It closes #3564
Checklist: