Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #108 from slloyd-hirst/rubocop_improvements
Browse files Browse the repository at this point in the history
Rubocop improvements
  • Loading branch information
stevebelicha committed Apr 21, 2016
2 parents 806d885 + 54a3f32 commit 37eaa83
Show file tree
Hide file tree
Showing 34 changed files with 302 additions and 309 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Metrics/LineLength:
Max: 120
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: ruby
rvm:
- 2.1.0
- 2.1.1
- 2.1.2
- 2.0.0
- 1.9.3
- 2.3.0
- 2.2.3
- rbx-2

matrix:
allow_failures:
- rvm: rbx-2
14 changes: 7 additions & 7 deletions Fudgefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
task_group :spec do
task :rspec, :coverage => 100
task :rspec, coverage: 100
end

task_group :docs do
task :yard, :coverage => 100
task :yard, coverage: 100
end

task_group :codestyle do
task :cane, :max_width => 150
task :cane, max_width: 150
end

task_group :duplication do
task :flay, :exclude => '^\.\/spec\/', :max => 42
task :flay, exclude: '^\.\/spec\/', max: 42
end

task_group :complexity do
task :flog, :exclude => '^\.\/spec\/', :max => 13, :average => 4.1, :methods => true
task :flog, exclude: '^\.\/spec\/', max: 11.6, average: 4.1, methods: true
end

task_group :shout_about_success do
Expand All @@ -35,7 +35,7 @@ task_group :shout_about_success_and_failure do
task_group :shout_about_failure
end

build :default, :about => 'Runs unit tests, and checks test coverage, documentation coverage, and code style and complexity' do
build :default, about: 'Runs unit tests, and checks test coverage, documentation coverage, and code style and complexity' do
task_group :spec
task_group :docs
task_group :codestyle
Expand All @@ -45,7 +45,7 @@ build :default, :about => 'Runs unit tests, and checks test coverage, documentat
task_group :shout_about_success_and_failure
end

build :nodoc, :about => 'Runs unit tests' do
build :nodoc, about: 'Runs unit tests' do
task_group :spec

task_group :shout_about_success_and_failure
Expand Down
4 changes: 2 additions & 2 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
guard 'rspec', :version => 2 do
guard 'rspec', version: 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
watch('spec/spec_helper.rb') { 'spec' }
end
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :default => :fudge
task default: :fudge

# Test Fudge using Fudge
task :fudge do
Expand Down
1 change: 0 additions & 1 deletion bin/fudge
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ rescue Fudge::Exceptions::Base => e
puts e.message
exit 1
end

18 changes: 9 additions & 9 deletions fudge.gemspec
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path('../lib', __FILE__)
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'fudge/version'

Gem::Specification.new do |s|
s.name = 'fudge'
s.version = Fudge::VERSION
s.authors = %q{Sage One team}
s.email = %q{[email protected]}
s.homepage = %q{http://github.com/Sage/fudge}
s.summary = %q{Fudge CI Server}
s.description = %q{Fudge Continuous Integration Server}
s.authors = 'Sage One team'
s.email = '[email protected]'
s.homepage = 'http://github.com/Sage/fudge'
s.summary = 'Fudge CI Server'
s.description = 'Fudge Continuous Integration Server'
s.license = 'MIT'

s.files = Dir['lib/**/*']
s.test_files = Dir['spec/**/*.rb']
s.executables = %w{fudge}
s.require_paths = %w{lib}
s.executables = %w(fudge)
s.require_paths = %w(lib)

s.add_dependency 'thor'
s.add_dependency 'json'
s.add_development_dependency 'redcarpet'
s.add_development_dependency 'rspec', '>= 3.0.0'
s.add_development_dependency 'guard-rspec'
s.add_development_dependency 'rb-fsevent' #guard dependency
s.add_development_dependency 'rb-fsevent' # guard dependency
s.add_development_dependency 'yard'
s.add_development_dependency 'cane'
s.add_development_dependency 'flog'
Expand Down
25 changes: 12 additions & 13 deletions spec/lib/fudge/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,43 @@
describe Fudge::Build do
it { is_expected.to be_a Fudge::Tasks::CompositeTask }

describe "#run" do

context "when provided an output" do
describe '#run' do
context 'when provided an output' do
let(:stdout) { StringIO.new }
let(:formatter) { Fudge::Formatters::Simple.new(stdout) }

it "prints messages to the formatter instead of default" do
subject.run :formatter => formatter
it 'prints messages to the formatter instead of default' do
subject.run formatter: formatter

expect(stdout.string).to be_empty
end

context "when there are callback hooks" do
context 'when there are callback hooks' do
let(:hook) { double(:Hook) }

before :each do
subject.callbacks = true
subject.success_hooks << hook
end

it "passesformatter down to the hook run" do
expect(hook).to receive(:run).with(:formatter =>formatter).and_return(true)
subject.run :formatter => formatter
it 'passesformatter down to the hook run' do
expect(hook).to receive(:run).with(formatter: formatter).and_return(true)
subject.run formatter: formatter
end
end

context "when the `time` flag is set" do
context 'when the `time` flag is set' do
before do
subject.callbacks = true
allow(subject).to receive(:run_callbacks).and_return(true)
subject.time = true
end

it "should print out the time of the build" do
it 'should print out the time of the build' do
expect(subject).to receive(:message) do |message|
expect(message).to match /Finished in \d+.\d\d seconds./
expect(message).to match(/Finished in \d+.\d\d seconds./)
end
subject.run :formatter => formatter
subject.run formatter: formatter
end
end
end
Expand Down
59 changes: 29 additions & 30 deletions spec/lib/fudge/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def self.name
:another_dummy
end

def run(options={})
def run(_options = {})
self.class.ran = true
end
end
Expand All @@ -18,7 +18,7 @@ def run(options={})
AnotherDummyTask.ran = false
end

describe ".build" do
describe '.build' do
before :each do
contents = <<-RUBY
build :default do
Expand All @@ -33,29 +33,29 @@ def run(options={})
allow(File).to receive(:open) { |&block| block.yield file }
end

context "when not given a build name" do
it "runs the default build" do
context 'when not given a build name' do
it 'runs the default build' do
subject.build 'default'
expect(DummyTask.ran).to be_truthy
end
end

context "when given a build name" do
it "runs the only the named build" do
context 'when given a build name' do
it 'runs the only the named build' do
subject.build 'other'
expect(DummyTask.ran).to be_falsey
expect(AnotherDummyTask.ran).to be_truthy
end
end
end

describe ".init" do
let (:file_state) { { exists: false, content: '' } }
let (:override_file_state) do
->(exists, content) {
describe '.init' do
let(:file_state) { { exists: false, content: '' } }
let(:override_file_state) do
lambda do |exists, content|
file_state[:exists] = exists
file_state[:content] = content
}
end
end

before :each do
Expand All @@ -74,50 +74,50 @@ def run(options={})
allow(subject).to receive(:shell).and_return(shell)
end

context "when a Fudgefile does not exist in the current directory" do
it "creates a new FudgeFile" do
context 'when a Fudgefile does not exist in the current directory' do
it 'creates a new FudgeFile' do
expect(File).not_to be_exists('Fudgefile')

subject.init

expect(File).to be_exists('Fudgefile')
end

it "writes a default build into the new Fudgefile" do
it 'writes a default build into the new Fudgefile' do
subject.init

File.open('Fudgefile', 'r') do |f|
expect(f.read).to eql "build :default do\n task :rspec\nend"
end
end

it "outputs a success message" do
it 'outputs a success message' do
subject.init
expect(@output).to eq 'Fudgefile created.'
end
end

context "when a Fudgefile already exists in the current directory" do
context 'when a Fudgefile already exists in the current directory' do
before :each do
override_file_state.(true, 'foo')
override_file_state.call(true, 'foo')
end

it "does not modify the existing Fudgefile" do
it 'does not modify the existing Fudgefile' do
expect(File).to be_exists('Fudgefile')

subject.init

expect(File.open('Fudgefile') { |f| f.read }).to eql 'foo'
expect(File.open('Fudgefile', &:read)).to eql 'foo'
end

it "outputs a failure message" do
it 'outputs a failure message' do
subject.init
expect(@output).to eq 'Fudgefile already exists.'
end
end
end

describe ".list" do
describe '.list' do
before :each do
contents = <<-RUBY
build :default do
Expand All @@ -137,32 +137,31 @@ def run(options={})
allow(subject).to receive(:shell).and_return(shell)
end

context "when not given a filter string" do
it "lists all the defined builds" do
context 'when not given a filter string' do
it 'lists all the defined builds' do
subject.list
expect(@output).to eql "default\t\nother\tnot the default"
end
end

context "when given a filter string" do
context "that matches one or builds" do
it "lists only the builds that match the filter" do
context 'when given a filter string' do
context 'that matches one or builds' do
it 'lists only the builds that match the filter' do
subject.list 'oth'
expect(@output).to eql "other\tnot the default"
end

it "ignores the case of the filter" do
it 'ignores the case of the filter' do
subject.list 'OTH'
expect(@output).to eql "other\tnot the default"
end
end

context "that matches no builds" do
it "outputs nothing" do
context 'that matches no builds' do
it 'outputs nothing' do
expect(@output).to eql ''
end
end
end
end

end
Loading

0 comments on commit 37eaa83

Please sign in to comment.