Skip to content

GitLab Next

    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Menu
    Projects Groups Snippets
  • Get a free trial
  • Sign up
  • Login
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar

GitLab 15.0 is launching on May 22! This version brings many exciting improvements, but also removes deprecated features and introduces breaking changes that may impact your workflow. To see what is being deprecated and removed, please visit Breaking changes in 15.0 and Deprecations.

  • GitLab.org
  • GitLab FOSSGitLab FOSS
  • Issues
  • #35351
Closed (moved)
(moved)
Open
Created Jul 20, 2017 by Grzegorz Bizon@grzesiek💡Maintainer

Rethink RSpec expectations with after and before hooks

Currently, following test example succeeds:

  context 'test' do
    let(:test) { double }

    it 'expects some message' do
      expect(test).to receive(:xxx)
    end
    
    after do
      test.xxx
    end
  end

It is also possible to set expectations in a before block.

This behavior is a little confusing, and in fact can lead to some problems, when we do a clean up in a after block. Example is https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/23223257 - we expect some messages sent to some object, but we receive more messages since we trigger a clean up in after block.

It does not seem right according to how I understand before and after semantics, but I might be wrong.

Does it warrant an issue in upstream project? 🤔

What do you think @rymai @rspeicher?

Assignee
Assign to
Time tracking