Skip to content

Fix tests in local environment#1416

Merged
josepjaume merged 4 commits intodecidim:masterfrom
deivid-rodriguez:fix_tests_in_local_environment
May 31, 2017
Merged

Fix tests in local environment#1416
josepjaume merged 4 commits intodecidim:masterfrom
deivid-rodriguez:fix_tests_in_local_environment

Conversation

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

@deivid-rodriguez deivid-rodriguez commented May 30, 2017

🎩 What? Why?

After #1392 I started getting a bunch of failures like the following when running the tests:

     Failure/Error: <%= stylesheet_link_tag "decidim/email" %>
     
     ActionView::Template::Error:
       unknown filter type: nil
     # /home/deivid/.gem/ruby/2.4.1/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:296:in `compile_match_filter'
     # /home/deivid/.gem/ruby/2.4.1/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:129:in `block in find'
     # /home/deivid/.gem/ruby/2.4.1/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:129:in `map'
     # /home/deivid/.gem/ruby/2.4.1/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:129:in `find'

(... a huge stacktrace redacted ...)

     # /home/deivid/Code/decidim/decidim-dev/lib/decidim/dev/test/rspec_support/database_cleaner.rb:10:in `block (2 levels) in <top (required)>'
     # /home/deivid/Code/decidim/decidim-dev/lib/decidim/dev/test/rspec_support/i18n.rb:13:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # TypeError:
     #   unknown filter type: nil
     #   /home/deivid/.gem/ruby/2.4.1/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:296:in `compile_match_filter'

I investigated and the reason is that since assets are now pre-compiled on first access, by that time the dummy feature has already been registered. And since it doesn't provide an icon, a nil asset is added for precompilation here, and things blow up.

I fixed this by adding an icon to the dummy feature in f17035c.

After fixing it, I started getting the following failure on the first test being run:

F.

Failures:

  1) User groups when the user group is not verified the user can check its status on his account page
     Failure/Error: visit decidim.own_user_groups_path
     
     Capybara::Poltergeist::StatusFailError:
       Request to 'http://1.lvh.me:46345/own_user_groups' failed to reach server, check DNS and/or server status
     # /home/deivid/.gem/ruby/2.4.1/gems/poltergeist-1.14.0/lib/capybara/poltergeist/browser.rb:376:in `command'
     # /home/deivid/.gem/ruby/2.4.1/gems/poltergeist-1.14.0/lib/capybara/poltergeist/browser.rb:35:in `visit'
     # /home/deivid/.gem/ruby/2.4.1/gems/poltergeist-1.14.0/lib/capybara/poltergeist/driver.rb:97:in `visit'
     # ./spec/features/user_groups_spec.rb:18:in `block (3 levels) in <top (required)>'
     # /home/deivid/Code/decidim/decidim-dev/lib/decidim/dev/test/rspec_support/database_cleaner.rb:11:in `block (3 levels) in <top (required)>'
     # /home/deivid/.gem/ruby/2.4.1/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/base.rb:16:in `cleaning'
     # /home/deivid/.gem/ruby/2.4.1/gems/database_cleaner-1.5.3/lib/database_cleaner/base.rb:98:in `cleaning'
     # /home/deivid/.gem/ruby/2.4.1/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:86:in `block (2 levels) in cleaning'
     # /home/deivid/.gem/ruby/2.4.1/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:87:in `cleaning'
     # /home/deivid/Code/decidim/decidim-dev/lib/decidim/dev/test/rspec_support/database_cleaner.rb:10:in `block (2 levels) in <top (required)>'
     # /home/deivid/Code/decidim/decidim-dev/lib/decidim/dev/test/rspec_support/i18n.rb:13:in `block (2 levels) in <top (required)>'

Finished in 51.18 seconds (files took 3.28 seconds to load)
2 examples, 1 failure

Failed examples:

rspec ./spec/features/user_groups_spec.rb:17 # User groups when the user group is not verified the user can check its status on his account page

This is because asset precompilation takes a while and poltergeist times out. I fixed that by specifying a high timeout to give asset precompilation time enough to happen successfully (e4b8763).

I also removed asset precompilation in CI before tests since I didn't see any reason to have tests behave differently depending on the environment (2dae166).

📌 Related Issues

None.

📋 Subtasks

None.

📷 Screenshots (optional)

None.

👻 GIF

ping

Otherwise a nil asset is registered and causes precompilation to fail
with this error:

```
Failure/Error: <%= stylesheet_link_tag    'application', media: 'all' %>

ActionView::Template::Error:
  unknown filter type: nil
```

It didn't happen previously because assets were precompiled _before_
tests, and thus before the dummy feature with missing icon was
registered. That's also why it doesn't happen in CI.
Since assets are now precompiled on first access, the first test might
actually timeout. Let's make sure that doesn't happen.
@codecov
Copy link
Copy Markdown

codecov bot commented May 30, 2017

Codecov Report

Merging #1416 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1416   +/-   ##
=======================================
  Coverage   95.42%   95.42%           
=======================================
  Files         428      428           
  Lines        7365     7365           
=======================================
  Hits         7028     7028           
  Misses        337      337

@oriolgual
Copy link
Copy Markdown
Contributor

Nice work @deivid-rodriguez!

@josepjaume
Copy link
Copy Markdown
Contributor

@deivid-rodriguez I'm so sorry, didn't see this happening on my local environment. Thanks again, sorry I caused this :(

@josepjaume josepjaume merged commit 9e636a8 into decidim:master May 31, 2017
@deivid-rodriguez deivid-rodriguez deleted the fix_tests_in_local_environment branch May 31, 2017 11:51
@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

No problem! :)

@deivid-rodriguez deivid-rodriguez mentioned this pull request May 31, 2017
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants