Skip to content

Commit

Permalink
Test Whatsnew::NewsFile
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanitoFatas committed Oct 26, 2015
1 parent b7d76f8 commit 9083539
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
26 changes: 21 additions & 5 deletions lib/whatsnew/news_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@

module Whatsnew
class NewsFile
attr_reader :file_name, :content, :file_url
def initialize(news)
@news = news
end

def file_name
news.name
end

def file_url
news_html_url
end

def initialize(file_name, content: nil, file_url: nil)
@file_name = file_name
@content = content
@file_url = file_url
def content
"See #{file_url}."
end

def read
"What's New:\n" "See #{file_name}: #{file_url}."
end

private

attr_reader :news

def news_html_url
news.html_url
end
end
end
32 changes: 32 additions & 0 deletions spec/whatsnew/news_file_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
RSpec.describe Whatsnew::NewsFile do
let(:content) do
sawyer_contents.find do |resource|
resource.name =~ %r{(CHANGE|CHANGES|CHANGELOG|NEWS|HISTORY)}i.freeze
end
end
let(:news_file) { Whatsnew::NewsFile.new(content) }

describe "#file_name" do
it "works" do
expect(news_file.file_name).to eq "History.rdoc"
end
end

describe "#file_url" do
it "works" do
expect(news_file.file_url).to eq "https://github.com/seattlerb/minitest/blob/master/History.rdoc"
end
end

describe "#content" do
it "works" do
expect(news_file.content).to eq "See https://github.com/seattlerb/minitest/blob/master/History.rdoc."
end
end

describe "#read" do
it "works" do
expect(news_file.read).to eq "What's New:\nSee History.rdoc: https://github.com/seattlerb/minitest/blob/master/History.rdoc."
end
end
end

0 comments on commit 9083539

Please sign in to comment.