jimweirich / rspec-given

Given/When/Then keywords for RSpec Specifications
https://github.com/jimweirich/rspec-given
MIT License
653 stars 61 forks source link

Step descriptions #34

Closed david closed 11 years ago

david commented 11 years ago

Hey Jim, thanks for your work on rspec-given, I've been using it as my main (unit) specification tool.

I'm wondering if it could be used for more than that, though.

I'm specifically thinking of something like this:

Given :me, "I'm signed up" do
  sign_up(create(:user)) #=> #<User ...>
end

When :dashboard, "I sign in" do
  sign_in(me) #=> #<Dashboard ...>
end

Then "I should see the dashboard" do
  dashboard.visible?
end

This would probably allow me to remove cucumber from my workflow. Would you be open to extend rspec-given so it could do this? Do you think it makes sense? If you do, I can try to provide a patch for it.

jimweirich commented 11 years ago

Part of the goals of RSpec-Given is to eliminate a lot of the redundant comments that pervade our specs. Consider rewriting your spec like this:

  Given(:me) { a_signed_up_user }
  When(:dashboard) { sign_in(me) }
  Then { dashboard.visible? }

I don't think that loses any clarity by omitting the string based comments.

david commented 11 years ago

Jim, thanks for your reply. I understand where you're coming from, and I agree. The only problem is that the code you proposed can be read by programmers only, and I was hoping to be able to generate readable enough output (using a formatter) that I could show to non-technical people without having to resort to cucumber.

But I agree. Maybe that's outside the scope of this project. I'll close this and will go back to the drawing board. :)