S Ahmed
2011-May-05 18:28 UTC
[rspec-users] api (class/method) renaming, will a simple controller test verify this?
I want my tests to fail if I rename a method in my /lib folder in a rails
app.
Say I have a class like:
/lib
/lib/formatter.rb
class Formatter
def self.do_transforms(text)
text
end
end
And say I reference this in my HomeController''s index action:
def index
text = params[:text]
text = Formatter.do_transforms(text)
end
Now if I was to rename the method from do_transforms to perform_transforms,
what is the minimum test I would neeed to do on my HomeController to get it
to fail b/c of the rename?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20110505/63ad9167/attachment-0001.html>
Mike Mazur
2011-May-05 22:16 UTC
[rspec-users] api (class/method) renaming, will a simple controller test verify this?
Hi, On Fri, May 6, 2011 at 02:28, S Ahmed <sahmed1020 at gmail.com> wrote:> I want my tests to fail if I rename a method in my /lib folder in a rails > app. > > Say I have a class like: > > /lib > /lib/formatter.rb > > class Formatter > ?? def self.do_transforms(text) > ????? text > ?? end > end > > > And say I reference this in my HomeController''s index action: > > > def index > > ??? text = params[:text] > > ??? text = Formatter.do_transforms(text) > > > end > > > Now if I was to rename the method from do_transforms to perform_transforms, > what is the minimum test I would neeed to do on my HomeController to get it > to fail b/c of the rename?The simplest test that would cover your specific case would probably be: describe HomeController do describe "GET ''index''" do it "succeeds" do get :index response.should be_success end end end If the method has been renamed, the index action will throw a NoMethodError and that spec will fail. Mike