On 25 Aug 2008, at 17:53, Nick Hoffman wrote:
At the moment, my plan is to spec out the following possibilities.
A property is invalid if its address:
1) doesn't begin with a digit;
2) is shorter than 2 characters;
3) is longer than 128 characters;
Personally I think that if those three points are your
specification then your RSpec should match that.
So:
* it "should not begin with a digit",
* it "should not be shorter than 2 characters",
* it "should not be longer than 128 characters" and
* it "should allow valid addresses" (this is for clarity, so you
have an example of a valid address in your documentation).
If your regex allows or disallows more or less than those four
clauses then your specification does not match your implementation.
So this is interesting, because my approach seems to be more like this:
describe "when the address does not begin with a digit" do
it "should be invalid" do ... end
end
describe "when the address is less than two characters long" do
it "should be invalid" do ... end
end
describe "when the address is more than two characters long" do
describe "and the address is less than 128 characters long" do
it "should be valid" do ... end
end
describe "and the address is more than 128 characters long" do
it "should be invalid" do ... end
end
end
Is anyone else using ExampleGroups like this? Or is it just me?!
cheers,
Matt
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users