This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further unit test work, adding specs for classes without specs.
- Loading branch information
1 parent
2c9d630
commit d69e46b
Showing
7 changed files
with
179 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'spec_helper' | ||
require 'shanty/task_env' | ||
|
||
# All classes referenced belong to the shanty project | ||
module Shanty | ||
RSpec.describe(TaskEnv) do | ||
include_context('graph') | ||
subject { TaskEnv.new(env) } | ||
|
||
describe('#env') do | ||
it('returns the env passed to the constructor') do | ||
expect(subject.env).to eql(env) | ||
end | ||
end | ||
|
||
describe('#graph') do | ||
let(:discoverer) { Discoverer.new(env) } | ||
let(:mutator) { Mutator.new(env, graph) } | ||
|
||
it('discovers all the projects') do | ||
expect(Discoverer).to receive(:new).with(env).and_return(discoverer) | ||
expect(discoverer).to receive(:discover_all).and_return([]) | ||
|
||
subject.graph | ||
end | ||
|
||
it('mutates all the projects in the graph') do | ||
allow(Discoverer).to receive(:new).with(env).and_return(discoverer) | ||
allow(discoverer).to receive(:discover_all).and_return([]) | ||
|
||
expect(Mutator).to receive(:new).with(env, instance_of(Graph)).and_return(mutator) | ||
expect(mutator).to receive(:apply_mutations) | ||
|
||
subject.graph | ||
end | ||
|
||
it('returns a graph') do | ||
expect(subject.graph).to be_a(Graph) | ||
end | ||
end | ||
|
||
describe('delegations') do | ||
it('delegates missing methods to the env') do | ||
expect(env).to receive(:environment) | ||
|
||
subject.environment | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
require 'spec_helper' | ||
require 'shanty/task_set' | ||
require_fixture 'test_task_set' | ||
|
||
# All classes referenced belong to the shanty project | ||
module Shanty | ||
RSpec.describe(TaskSet) do | ||
after do | ||
TaskSet.instance_variable_set(:@partial_task, nil) | ||
end | ||
|
||
describe('.inherited') do | ||
let(:task_set) { Class.new(TestTaskSet) } | ||
|
||
it('adds the inheriting task set to the array of registered task sets') do | ||
TaskSet.inherited(task_set) | ||
|
||
expect(TaskSet.instance_variable_get(:@task_sets)).to include(task_set) | ||
end | ||
end | ||
|
||
describe('.task_sets') do | ||
it('returns the registered task sets') do | ||
expect(TaskSet.task_sets).to include(TestTaskSet) | ||
end | ||
end | ||
|
||
describe('.tasks') do | ||
it('returns the registered tasks') do | ||
expect(TestTaskSet.tasks).to include(:foo) | ||
end | ||
end | ||
|
||
describe('.partial_task') do | ||
it('returns a partial task') do | ||
expect(TestTaskSet.partial_task).to eql(klass: TestTaskSet, options: {}, params: {}) | ||
end | ||
end | ||
|
||
describe('.desc') do | ||
it('sets the syntax field of the current partial task') do | ||
TaskSet.desc('foo', 'bar') | ||
|
||
expect(TaskSet.instance_variable_get(:@partial_task)).to include(syntax: 'foo') | ||
end | ||
|
||
it('sets the desc field of the current partial task') do | ||
TaskSet.desc('foo', 'bar') | ||
|
||
expect(TaskSet.instance_variable_get(:@partial_task)).to include(desc: 'bar') | ||
end | ||
end | ||
|
||
describe('.param') do | ||
it('sets the given param with the given options in the current partial task') do | ||
TaskSet.param('foo', bar: 'lux') | ||
|
||
expect(TaskSet.instance_variable_get(:@partial_task)[:params]).to include('foo' => { bar: 'lux' }) | ||
end | ||
end | ||
|
||
describe('.option') do | ||
it('sets the given option with the given attrs in the current partial task') do | ||
TaskSet.option('foo', bar: 'lux') | ||
|
||
expect(TaskSet.instance_variable_get(:@partial_task)[:options]).to include('foo' => { bar: 'lux' }) | ||
end | ||
end | ||
|
||
describe('.method_added') do | ||
it('adds the partial task to the list of tasks with the name of the method that was added') do | ||
TaskSet.method_added(:woowoo) | ||
|
||
expect(TaskSet.instance_variable_get(:@tasks)).to include(:woowoo) | ||
end | ||
|
||
it('resets the partial task') do | ||
TaskSet.method_added(:weewah) | ||
|
||
expect(TaskSet.instance_variable_get(:@partial_task)).to be_nil | ||
end | ||
end | ||
end | ||
end |