Skip to content

Fix randomly failing test spec/features/users_spec.rb #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2017
Merged

Conversation

nalabjp
Copy link
Member

@nalabjp nalabjp commented Nov 23, 2017

fix #200

明確な原因まではわからなかったが、Scrivito::Workspace.currentの状態が変わることがあるようで、
それによりObjが見つからないケースが有る模様。(WorkspaceとObjの関係性の理解が足りていない😇)

letを使うと--seed 49001が手元で通るようになるので、spec実行時はScrivtio::Workspace.currentが意図したものが取れているような感じ。

~/ghq/github.com/nalabjp/coderdojo.jp fix-user-spec
$ git rev-parse HEAD
17b538a0448b668a8fcde51c0209deecb026a161
~/ghq/github.com/nalabjp/coderdojo.jp fix-user-spec
$ bundle exec rspec spec/ --seed 49001

Randomized with seed 49001
................................................

Top 10 slowest examples (11.04 seconds, 92.9% of total time):
  Sotechsha GET /sotechsha/num Quizzes should be permalink
    2.32 seconds ./spec/features/sotechsha_spec.rb:7
  Sotechshas Quizzes should be permalink Quizzes should be permalink
    2.15 seconds ./spec/requests/sotechshas_spec.rb:6
  Users log in with invalid information should not text "道場情報まとめ"
    2.07 seconds ./spec/features/users_spec.rb:24
  Users log in with invalid information should text "ログイン"
    1.33 seconds ./spec/features/users_spec.rb:23
  Users log in with valid information should text "道場情報まとめ"
    1.3 seconds ./spec/features/users_spec.rb:33
  NewsPages GET /news/2016/12/12/new-backend Blog post should be rendered
    0.43522 seconds ./spec/requests/news_pages_spec.rb:5
  SessionsController GET #create param unmatch
    0.38812 seconds ./spec/controllers/sessions_controller_spec.rb:10
  Sotechshas GET /sotechsha/gazou Gazoulink should be permalink
    0.35926 seconds ./spec/requests/sotechshas_spec.rb:15
  News GET /news/2016/12/12/new-backend Title should be formatted
    0.3502 seconds ./spec/features/news_spec.rb:6
  Sotechsha GET /sotechsha/1 Datetime should be formatted
    0.3476 seconds ./spec/features/sotechsha_spec.rb:26

Top 10 slowest example groups:
  Users
    1.56 seconds average (4.69 seconds / 3 examples) ./spec/features/users_spec.rb:5
  Sotechshas
    1.25 seconds average (2.51 seconds / 2 examples) ./spec/requests/sotechshas_spec.rb:3
  Sotechsha
    0.99368 seconds average (2.98 seconds / 3 examples) ./spec/features/sotechsha_spec.rb:4
  NewsPages
    0.43557 seconds average (0.43557 seconds / 1 example) ./spec/requests/news_pages_spec.rb:3
  News
    0.35053 seconds average (0.35053 seconds / 1 example) ./spec/features/news_spec.rb:4
  Statistics::Aggregation
    0.13068 seconds average (0.13068 seconds / 1 example) ./spec/lib/statistics/aggregation_spec.rb:4
  SessionsController
    0.10376 seconds average (0.41503 seconds / 4 examples) ./spec/controllers/sessions_controller_spec.rb:3
  Top
    0.04013 seconds average (0.04013 seconds / 1 example) ./spec/features/top_spec.rb:3
  SotechshaOverviewPageController
    0.03893 seconds average (0.03893 seconds / 1 example) ./spec/controllers/sotechsha_overview_page_controller_spec.rb:3
  DocsController
    0.03785 seconds average (0.11356 seconds / 3 examples) ./spec/controllers/docs_controller_spec.rb:3

Finished in 11.89 seconds (files took 6.45 seconds to load)
48 examples, 0 failures

Randomized with seed 49001

@nalabjp nalabjp changed the title Use let instead of let! Fix randomly failing test spec/features/users_spec.rb Nov 23, 2017
@yasulab
Copy link
Member

yasulab commented Nov 24, 2017

PRありがとうございます!マージしますね :)

@yasulab yasulab merged commit 4b0b6fd into master Nov 24, 2017
@nalabjp nalabjp deleted the fix-user-spec branch November 24, 2017 04:22
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.

テストをランダム化したらコケるテストがある
3 participants