Sha256: 9d97b959f75b22cd68af904ec7dd0a283ed943f123ac21973cf723d8790fde71
Contents?: true
Size: 1.81 KB
Versions: 17
Compression:
Stored size: 1.81 KB
Contents
require 'spec_helper' module RailsBestPractices module Reviews describe NotUseTimeAgoInWordsReview do let(:runner) { Core::Runner.new(reviews: NotUseTimeAgoInWordsReview.new) } describe "time_ago_in_words" do it "should not use in views" do content =<<-EOF <%= time_ago_in_words(post.created_at) %> EOF runner.review('app/views/posts/show.html.erb', content) runner.should have(1).errors runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - not use time_ago_in_words" end it "should not use in helpers" do content =<<-EOF def timeago content_tag(:p, time_ago_in_words(post.created_at)) end EOF runner.review('app/helpers/posts_helper.rb', content) runner.should have(1).errors runner.errors[0].to_s.should == "app/helpers/posts_helper.rb:2 - not use time_ago_in_words" end end describe "distance_of_time_in_words_to_now" do it "should not use in views" do content =<<-EOF <%= distance_of_time_in_words_to_now(post.created_at) %> EOF runner.review('app/views/posts/show.html.erb', content) runner.should have(1).errors runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - not use time_ago_in_words" end it "should not use in helpers" do content =<<-EOF def timeago content_tag(:p, distance_of_time_in_words_to_now(post.created_at)) end EOF runner.review('app/helpers/posts_helper.rb', content) runner.should have(1).errors runner.errors[0].to_s.should == "app/helpers/posts_helper.rb:2 - not use time_ago_in_words" end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems