Skip to content

Building better descriptions with when and while contexts in addition to with #9

@joeldrapper

Description

@joeldrapper

I’d like my test description to say something like this and I’m struggling to fit it into the describe / with blocks:

Phlex::Component#render when rendering another component with a text content block it produces the correct output

I think we could achieve this by adding a when context method in addition to with.

describe Phlex::Component do
  describe "#render" do
    when "rendering another component"
      let(:another_component) { ... }
      
      with "a text content block" do
        let(:example) { ... }
        
        it "produces the correct output" do
          expect(output).to be == "..."
        end
      end
    end
  end
end

I think we should consider adding while while we're at it. For example, we might want a test that's described:

Phlex::Component#render when rendering another component with a text content block while in production it produces the correct output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions