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

Version Path
rails_best_practices-1.14.4 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.14.3 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.14.2 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.14.1 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.14.0 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.13.8 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.13.5 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.13.4 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.13.3 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.13.2 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.13.1 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.13.0 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.12.0 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.11.1 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.11.0 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.10.1 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
rails_best_practices-1.10.0 spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb