Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Es können unterschiedliche Formatter verwendet werden

  • Loading branch information...
commit 4d50103a38391a74c6fd0e86fad556f228e11045 1 parent d35f4d3
@senny senny authored
View
4 lib/garaio-changelog/changelog.rb
@@ -1,6 +1,7 @@
require 'garaio-changelog/repository'
require 'garaio-changelog/pipeline'
require 'garaio-changelog/formatters/plain'
+require 'garaio-changelog/formatters/console'
class Changelog
@@ -14,7 +15,8 @@ def write_to(output, options = {})
@pipeline = Pipeline.default
processed_commits = @pipeline.call(repository_commits)
- formatter = Formatters::Plain.new
+ format = options.fetch(:format) { :plain }
+ formatter = Formatters.const_get(format.to_s.capitalize).new
formatter.write_to(output, processed_commits)
end
View
8 lib/garaio-changelog/formatters/console.rb
@@ -0,0 +1,8 @@
+module Formatters
+ class Console
+
+ def write_to(output, commits)
+ end
+
+ end
+end
View
30 spec/unit/changelog_spec.rb
@@ -4,27 +4,39 @@
describe Changelog do
- it "Erstellt das Changelog für eine Commitrange im Zielrepository" do
- ziel_repository = 'pfad/zu/repo'
- commit_range = 'release..master'
- commits = ['Commits..']
- processed_commits = stub
+ let(:ziel_repository) { 'pfad/zu/repo' }
+ let(:commit_range) { 'release..master' }
+ let(:output) { mock }
+ let(:processed_commits) { stub }
+
+ before do
+ commits = stub
- output = stub
repository = mock
pipeline = mock
- formatter = mock
Repository.should_receive(:new).with(ziel_repository).and_return(repository)
repository.should_receive(:commits).with(commit_range).and_return(commits)
Pipeline.should_receive(:default).and_return(pipeline)
pipeline.should_receive(:call).with(commits).and_return(processed_commits)
+ end
+
+ subject { Changelog.new(ziel_repository, commit_range) }
+
+ it "Der PlainFormatter wird per Default verwendet" do
+ formatter = mock
Formatters::Plain.should_receive(:new).and_return(formatter)
formatter.should_receive(:write_to).with(output, processed_commits)
- changelog = Changelog.new(ziel_repository, commit_range)
+ subject.write_to(output)
+ end
+
+ it 'Der Formatter kann angegeben werden' do
+ formatter = mock
+ Formatters::Console.should_receive(:new).and_return(formatter)
+ formatter.should_receive(:write_to).with(output, processed_commits)
- changelog.write_to(output)
+ subject.write_to(output, :format => :console)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.