Skip to content
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

let?() method not working when assignment is not in the final context #2

Open
ptrela opened this issue Jan 14, 2021 · 0 comments
Open
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ptrela
Copy link

ptrela commented Jan 14, 2021

When let(:year) is inside context1, assertion can't find its value (2021).
When we move it to the context2 - it will work.

# frozen_string_literal: true

require 'spec_helper'

describe Cars::ModelService do
  subject(:service) { described_class.call(**parameters) }

  let(:parameters) { { year: let?(:year, nil) } }

  context 'context1' do
    let(:year) { '2021' }

    context 'context2' do
      it 'returns array with one object' do
        expect(service.car_list.count).to eq 1
      end
    end
  end
end

@whitemerry whitemerry self-assigned this Jan 14, 2021
@whitemerry whitemerry added the bug Something isn't working label Jan 14, 2021
@whitemerry whitemerry added this to the 0.1.1 milestone Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants