Reputation: 33
I Wrote a general testing file which includes a few tests. I want to write a few files that will use those tests, each file will run specific tests (not all of them).
A test example:
class AccountBase
describe "TC_ACCOUNT" do
it "Fill info Fields" do
#test here
end
end
end
Lets call it baseTests.rb. Now I have another file - infoTest.rb . How can I call "Fill info Fields" from within infoTest Thanks.
Upvotes: 0
Views: 924
Reputation: 1163
It sounds like you need Rspec's shared examples: Shared examples on Relish, or in the Rspec API docs
Your example might look something like:
class AccountBase
shared_examples "TC_ACCOUNT" do
it "Fill info Fields" do
#test here
end
end
end
And then you could include the shared examples in your infoTest.rb file with:
include_examples "TC_ACCOUNT"
or:
it_behaves_like "TC_ACCOUNT"
The shared example can then be written to check metadata from the context that includes it or accept parameters to its block that are passed in by the including spec, so as to change its behaviour based on which test file it's being included into.
Upvotes: 2