I am trying to code an application that is based on Rspec; I am
programmatically building examples, and launching the runner with a
custom
formatter. Here are the code snippets from my app:
Class.new(Spec::Example::ExampleGroup).describe(“Statistics”) @expectations.map do |expectation|
examples.it examples.description do
actual_stats_counters.should expectation
end
end
examples
This is working fine, except for one problem. When I am writing examples
for
my app (also using rspec), the examples that are generated within my
application (the inner examples, so to say) are being added to the
application’s examples (the outer examples).
This means that if inner expected failures are causing my outer examples
to
fail.
How is it possible for me to verify expected failures without causing my
examples to fail?
application (the inner examples, so to say) are being added to the
application’s examples (the outer examples).
This means that if inner expected failures are causing my outer examples to
fail.
How is it possible for me to verify expected failures without causing my
examples to fail?
If I understand your question correctly, you can do this:
Thanks for your reply; however I probably wasn’t very clear in my
explanation. What I am really trying to do is to create a builder for
example group objects, without automatically adding the example groups
to
the rspec runner when the builder code is invoked.
As an example, when I call the following code:
describe “a group” do
examples =
Class.new(Spec::Example::ExampleGroup).describe(“example”)
examples.it “should not be added to the outer group” do
true.should be_false
end
end
I get:
1)
'example should not be added to the outer group' FAILED
expected false, got true
Finished in 0.027012 seconds
1 example, 1 failure
This is probably expected, but what I really want is that the “examples”
example group is NOT picked up by rspec. I suppose that I need to stay
away
from the “it” and “describe” methods… right?
examples = Class.new(Spec::Example::ExampleGroup).describe("example")
examples.it "should not be added to the outer group" do
true.should be_false
end
end
When you create a subclass of Spec:Example::ExampleGroup, it
automatically gets registered. You want to make sure you unregister it
so rspec’s Runner doesn’t try to run it. Try this:
describe “a group” do
example_group = Class.new(Spec::Example::ExampleGroup)
example_group.unregister
examples = example_group.describe(“example”)
examples.it “should not be added to the outer group” do
true.should be_false
end
end
> On Sat, Oct 18, 2008 at 2:13 PM, Jake B. <[email protected]> wrote:
> > test_expectation.example_groups_for(system_state)
> >
> > for
> If I understand your question correctly, you can do this:
> David
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users