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

And doesn't give good output #31

Open
hoguej opened this issue Aug 31, 2013 · 3 comments
Open

And doesn't give good output #31

hoguej opened this issue Aug 31, 2013 · 3 comments

Comments

@hoguej
Copy link

hoguej commented Aug 31, 2013

When you use Then,Then,Then

You get an output line that is either red or green for each one.

When you use Then,And,And, you only get output for the first line, with the whole test succeeding or failing. You get more detail later on, but it'd be nice to have fast tests and verbose output for each test.

Should And spit out a red/green pass status? (asking before I attempt to submit a patch that would be rejected.) Is there a good reason that it doesn't do this already?

@jimweirich
Copy link
Owner

Then blocks are essentially translated into RSpec "it" blocks. Each block runs independently of the other blocks and is not effected by the success and failure of any other block.

Using:

Then { a.should == b }
And { c.should == d }

is essentially equivalent to:

it "..." do
  a.should == b
  c.should == d
end

in order to take advantage of the common setup. However, the downside is that the first assertion to fail causes any following assertions to not be run.

This is pretty fundamental to the structure of RSpec and I'm not aware of any easy way around this without delving deep into RSpec internals.

However, I'd be interested hearing possible solutions or patches in this area.

@ronen
Copy link
Contributor

ronen commented Jan 9, 2015

Hey @searls -- in case it's useful:

In rspec/rspec-core#756, @tovodeverett posted code for a nullipotent_tests block that lets you group a bunch of it blocks so that they share the same before(:each) setup

before(:each) { some_time_consuming_setup }
nullipotent_tests do
  it { should be_kind_of(SomeClass) }
  it { should == foo }
  . . .
end

but still pass/fail/report as separate tests. He originally did it for rspec 2, and recently updated it for rspec 3.

Maybe his approach could be used to translate

Then { a.should == b }
And { c.should == d }

into the equivalent of

nullipotent_tests do
  it { a.should == b }
  it { c.should == d }
end

I haven't grokked how either nullipotent_tests nor rspec-given do their magic, so I have no idea if they are or could be compatible. (Or maybe @tovodeverett could release his code as a separate rspec extension gem, which rspec-given could depend on and use?)

@ronen
Copy link
Contributor

ronen commented Jan 9, 2015

Opened this as an issue in the new repo: rspec-given#4

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

No branches or pull requests

3 participants