-
-
Notifications
You must be signed in to change notification settings - Fork 760
Add support for passing parameters and a block through include_examples #503
Conversation
I think this is a good idea, but we should do it for |
Sure, I will take a look at that and see what I can come up with. |
I didn't even know @dchelimsky: what are the semantics of If As for allowing customization via parameters and a block for |
I went ahead and added this support in the hopes that Myron is mis-remembering and there is no reason to not make this change :). In the current implementation |
@myronmarston - After a bit more thought, I think passing params to describe CheckingAccoung do
include_examples "account" do
let(:account) { CheckingAccount.new }
end
it "does something special" do
account # refers to the account defined by let(:account)
end
end
describe CheckingAccoung do
let(:account) { CheckingAccount.new }
include_examples "account"
it "does something special" do
account # refers to the account defined by let(:account)
end
end This strikes me as a recipe for confusion. What do you think about structuring it such that |
I agree that adding the block doesn't make any sense, I removed that support in my latest commit. I didn't add anything to raise an error if a block is provided, what do you think about that? The way it is now someone could provide a block thinking that |
An error or a warning suggesting the user should use |
I added a warning message for both cases if a block is provided. |
Great work. Thanks! |
Add support for passing parameters and a block through include_examples and include_context
The
it_should_behave_like
andit_behaves_like
methods of pulling in shared examples both allow you to pass parameters and a customization block. In my case I preferred theinclude_examples
method instead of those alternatives but it did not support passing parameters or a block. This change adds that support along with tests for it.