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 Nick Hoffman wrote: > On 2008-08-29, at 05:06, Joseph Wilk wrote: >>> Each method generates specs depending on its arguments >> >> How does each method generate the specs? >> * Using script/generate rspec... >> or >> * File handling and writing your own? >> >> -- >> Joseph Wilk >> http://www.joesniff.co.uk > > Hi again Joseph. Each method generates the specs by calling RSpec's > #describe and #it methods, like this: > > def check_model_attributes_when_nil(model, ... > ... > columns_to_check.each do |attribute| > describe model, "with '#{attribute}' set to nil" do > ... > it "should be invalid" do > @model_instance.should_not be_valid > end > ... > end > end -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users