> -----Original Message----- > From: rspec-users-boun...@rubyforge.org [mailto:rspec-users- > boun...@rubyforge.org] On Behalf Of David Chelimsky > Sent: Friday, April 10, 2009 3:10 AM > To: rspec-users > Subject: Re: [rspec-users] Eliminating duplication from tests > > Can you please post specific examples of the use of these so we don't > have to talk in generalities?
Sure, here is something I just wrote. def assert_route_recognition path, controller, methods describe "route recognition" do [:get, :post, :put, :delete].each do |method| if methods.include? method it "should generate the params" + " {:controller => '#{controller}', :action => '#{methods[method]}'}" + " when the request method is #{method.to_s.upcase}" do params_from(method, path).should == { :controller => controller, :action => methods[method] } end else it "should not accept the #{method} method" do lambda { params_from(method, path) }.should raise_error(ActionController::MethodNotAllowed) end end end end end # assert_route_recognition > Of course your "testing" is progressing towards something more > "test-like." You're calling it "testing" so you're probably thinking > of it as "testing." You're using words like "ensure" instead of > "specify" and you've even named your expectations "assert_xxx" instead > of "expect_xxx." Interesting. I'm just used to thinking that way I guess. What is wrong with ensure instead of specify? And I've never seen that convention with the expect prefix. Can you provide an example? Thank you very much for the help. Brandon _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users