[rspec-users] Problems when programmatically defining examples

Jake Benilov benilov at gmail.com
Sat Oct 18 12:13:03 EDT 2008


Hi,

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:

Launching the runner:

                example_groups =
test_expectation.example_groups_for(system_state)

                @output = StringIO.new
                options = Spec::Runner::OptionParser.parse(["--format",
"RAutotest::Runner::Formatter"], @output, @output)
                example_groups.each {|example_group|
options.add_example_group(example_group) }

                Spec::Runner::CommandLine.run(options)

Building the example groups:

                    examples =
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?

Thanks in advance,
Jake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081018/cd7db7f7/attachment.html>


More information about the rspec-users mailing list