Skip to content

Commit

Permalink
travis test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Brewster committed Feb 3, 2015
1 parent 0ec18a1 commit 7531818
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/new/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def version
S.ay New.new_object[:version], :color => :green, :indent => 1
end

desc 'test', 'Run task tests'
desc 'test', 'Run task tests from sources'
option :watch, :type => :boolean, :aliases => ['-w'], :desc => 'Watch local tasks for changes and run tests'
option :source, :type => :string, :aliases => ['-s'], :desc => 'Source name'
option :task, :type => :string, :aliases => ['-t'], :desc => 'Task name'
Expand Down
4 changes: 2 additions & 2 deletions lib/new/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def self.tasks; @@tasks; end
# when custom task is required, add the class to the global hash to initialize later
#
def self.inherited subclass
# create name from task file name
# e.g. foo_task.rb => `foo`
# create symbolized name from task file name
# e.g. foo_task.rb => :foo
task_name = caller.first.match(/([^\/]*)_task\.rb.*$/)[1].to_sym
@@tasks[task_name] = subclass
end
Expand Down
23 changes: 10 additions & 13 deletions spec/lib/new/task_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
describe New::Task do
describe.skip New::Task do
before do
allow(New::Task).to receive(:require)
allow(New::Task).to receive(:system)
@task = New::Task.load root('spec', 'fixtures', 'task', 'task_task.rb')
end

after do
allow(New::Task).to receive(:require).and_call_original
allow(New::Task).to receive(:system).and_call_original
end

describe.skip '.load' do
it 'should require the task' do
expect(New::Task).to receive(:require).with root('spec', 'fixtures', 'task', 'task_task')
end
it 'should require the task' do
expect(New::Task).to have_received(:require).with root('spec', 'fixtures', 'task', 'task_task')
end

it 'should install gems' do
expect(New::Task).to receive(:system).with "bundle install --gemfile=#{root('spec', 'fixtures', 'task', 'Gemfile')}"
end
it 'should install gems' do
expect(New::Task).to have_received(:system).with "bundle install --gemfile=#{root('spec', 'fixtures', 'task', 'Gemfile')}"
end

context '.inherited' do
it 'should add task to global array' do
puts New::Task.class_var(:tasks).inspect
expect(New::Task.class_var(:tasks)[:task]).to eq New::TaskTask
end
it 'should add task to global array' do
expect(New::Task.class_var(:tasks)[:task]).to eq New::TaskTask
end
end

0 comments on commit 7531818

Please sign in to comment.