Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions lib/next_rails/gem_info.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
begin
require "action_view"
rescue LoadError
puts "ActionView not available"
end

module NextRails
class GemInfo
if defined?(ActionView)
include ActionView::Helpers::DateHelper
end

class NullGemInfo < GemInfo
def initialize; end

Expand Down Expand Up @@ -52,11 +42,7 @@ def initialize(gem_specification)
end

def age
if respond_to?(:time_ago_in_words)
"#{time_ago_in_words(created_at)} ago"
else
created_at.strftime("%b %e, %Y")
end
created_at.strftime("%b %e, %Y")
end

def sourced_from_git?
Expand Down
18 changes: 3 additions & 15 deletions spec/ten_years_rails/gem_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,10 @@
end
end

context "when ActionView is available" do
it "returns a time ago" do
expect(subject.age).to eq("about 12 hours ago")
end
end

context "when ActionView is not available" do
let(:result) { now.strftime("%b %e, %Y") }
let(:result) { now.strftime("%b %e, %Y") }

before do
subject.instance_eval('undef :time_ago_in_words')
end

it "returns a date" do
expect(subject.age).to eq(result)
end
it "returns a date" do
expect(subject.age).to eq(result)
end
end
end