Commit 7a167a09 authored by charlie-ablett's avatar charlie-ablett

Description method, sets finished_at even if the step finishes in error.

parent 24c54c44
PATH
remote: .
specs:
ink_step (0.1.3)
ink_step (0.1.5)
awesome_print
httparty
rubyzip
......
......@@ -33,11 +33,12 @@ module InkStep
get_input_files
log_as_step "Using version #{version}"
perform_step(options: options)
@finished_at = Time.now
log_as_step "Finished at #{@finished_at.utc.strftime("%Y-%m-%d %H:%M:%S UTC")}"
rescue => e
raise_and_log_error(e)
ensure
@finished_at = Time.now
log_as_step "Finished at #{@finished_at.utc.strftime("%Y-%m-%d %H:%M:%S UTC")}"
log_as_step "Errors: #{@errors}"
if @errors.any?
return
else
......@@ -66,7 +67,12 @@ module InkStep
def version
return InkStep::VERSION if self.class.name == "InkStep::Base"
raise NotImplementedError.new("You need to provide a Version method in your step (#{self.class.name}) that points to your gem version (see RotThirteen example)")
raise NotImplementedError.new("You need to provide a Version method in your step (#{self.class.name}) that points to your gem version (see CokoDemoSteps example)")
end
def description
return "A basic step that returns the files you provide unchanged" if self.class.name == "InkStep::Base"
raise NotImplementedError.new("You need to provide a Description method in your step (#{self.class.name}) that returns a string - a brief summary of what your step does (see CokoDemoSteps example)")
end
protected
......
......@@ -23,6 +23,10 @@ module InkStep
def version
InkStep::VERSION
end
def description
"A validator that returns the result you tell it to."
end
end
end
end
\ No newline at end of file
module InkStep
VERSION = '0.1.4'
VERSION = '0.1.5'
end
\ No newline at end of file
......@@ -24,7 +24,7 @@ describe InkStep::Base do
context "if the input file directory doesn't exist" do
it 'throws an error' do
expect(subject).to receive(:raise_and_log_error).with(RuntimeError)
expect(subject).to receive(:ap).with(/Cannot find source directory/).once
expect(subject).to receive(:ap).with(/Cannot find source directory/)
subject.execute
end
......@@ -39,7 +39,7 @@ describe InkStep::Base do
context 'and it is empty' do
it 'throws an error' do
expect(subject).to receive(:raise_and_log_error).with(RuntimeError)
expect(subject).to receive(:ap).with(/Source directory (.*) is empty/).once
expect(subject).to receive(:ap).with(/Source directory (.*) is empty/)
subject.execute
end
......@@ -110,7 +110,7 @@ describe InkStep::Base do
end
describe '#version' do
context "if BasicStep is being used (for some reason? it doesn't do anything really :P)" do
context "if InkStep::Base is being used (for some reason? it doesn't do anything really :P)" do
specify do
expect(subject.version).to eq InkStep::VERSION
end
......@@ -121,13 +121,33 @@ describe InkStep::Base do
expect{IncompleteStepClass.new.version}.to raise_error(NotImplementedError)
end
end
context "hat does not implement the Version method" do
context "that does not implement the Version method" do
specify do
expect(CorrectlyImplementedStepClass.new.version).to eq "1.3"
end
end
end
end
describe '#description' do
context "if InkStep::Base is being used (for some reason? it doesn't do anything really :P)" do
specify do
expect(subject.description).to eq "A basic step that returns the files you provide unchanged"
end
end
context "for a subclass" do
context "that does not implement the Version method" do
it 'throws an error' do
expect{IncompleteStepClass.new.description}.to raise_error(NotImplementedError)
end
end
context "that does not implement the Version method" do
specify do
expect(CorrectlyImplementedStepClass.new.description).to eq "it's a secret"
end
end
end
end
end
class IncompleteStepClass < InkStep::Base
......@@ -141,6 +161,10 @@ class CorrectlyImplementedStepClass < InkStep::Base
end
def description
"it's a secret"
end
def version
"1.3"
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment