[rspec-users] How to spec the existence of specs

Nick Hoffman nick at deadorange.com
Sat Sep 6 17:50:58 EDT 2008


On 2008-08-31, at 15:40, Joseph Wilk wrote:
> I've been giving this some thought, I've not had the chance to test it
> out yet,
> but here are my examples:
> --
> it "should add a 'it' test" do
>  example_group = Class.new(Spec::Example::ExampleGroup)
>  example_group.should_receive(:it).with(...) ...
>
>  example.class_eval do
>    describe_model_attribute(model, attribute, valid_values,
> invalid_values)
>  end
>
> end
>
> describe "valid model"
>  it "should generate a spec which will pass" do
>    example_group = Class.new(Spec::Example::ExampleGroup) do
>      describe_model_attribute(model, attribute, valid_values,
> invalid_values)
>    end
>    example_group.run.should be_true
>  end
> end
> --
>
> So this means the scope of 'it' and 'describe' are against  
> ExampleGroup.
> Giving you something to mock against to check 'it'/'describe'.
>
> Invoking run on the ExampleGroup class will run the specs you  
> generate,
> and then you can check if they succeed/fail. An alternative to  
> checking
> the output could be to test that the model has the relevant methods
> invoked on it.
>
> I hope that helps
> --
> Joseph Wilk
> http://www.joesniff.co.uk

Hi Joseph. I just realised that I hadn't responded to this email of  
yours. Thanks for thinking about it and showing me how you'd take a  
stab at it. I'm going to give it another shot in the next few days.  
When I do, I'll post my results.

Cheers,
Nick


More information about the rspec-users mailing list