Skip to content

Commit

Permalink
Fixes tests on master
Browse files Browse the repository at this point in the history
**What**

- Fixes rubocop failures using default rules with the exception of one
  case
- Removes CodeClimate from the code because its implementation was
  deprecated on TravisCI. I opened an issue to look into this:
  #7
- Added the latest stable ruby version (that RVM has to offer) to run on
  TravisCI
- Did the minimum necessary to mock out the repo linter functionality so
  that the existing tests will pass. I will make a follow-up eventually
  to write tests for the repo linter.
- Fixed some small things in the existing tests to get them to pass
- Added test coverage to the `Runner` spec.
  • Loading branch information
raychatter committed Feb 1, 2018
1 parent 27489a2 commit e8d866a
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Metrics/CyclomaticComplexity:
Metrics/ParameterLists:
Max: 10

Style/AccessorMethodName:
Enabled: false

# default disabled rules
Style/AutoResourceCleanup:
Enabled: true
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rvm:
- 2.1
- 2.2
- 2.3.0
- 2.4.3
before_install: gem install bundler -v 1.11.2
script:
- bundle exec rake
Expand Down
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
source 'https://rubygems.org'

gemspec

group :test do
gem 'codeclimate-test-reporter'
end
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def lookup_project_card(context_link)
ScrumLint::Trello::CardMapper.(
trello_card,
list: trello_card.list,
board_name: trello_card.board.name,
board_name: trello_card.board.name
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module InteractiveLinter
# checks that cards have #HashTag and interactively assigns
class MissingHashTag < InteractiveLinter::Base

MESSAGE = 'missing hashtag'
MESSAGE = 'missing hashtag'.freeze

def call(card, reporter:, **_)
return if card.hashtags.any?
Expand Down
2 changes: 1 addition & 1 deletion lib/scrum_lint/mappers/trello/list_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def call(trello_list, board_name:)
list.cards = mapped_cards(
list: list,
trello_list: trello_list,
board_name: board_name,
board_name: board_name
)
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/scrum-lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
trello_developer_public_key: nope
trello_member_token: nada
github_access_token: foo
github_repo_names: ['foo/bar']
1 change: 1 addition & 0 deletions spec/scrum_lint/models/card_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
RSpec.describe ScrumLint::Card do
let(:card_params) do
{
board_name: nil,
checklists: nil,
desc: nil,
labels: nil,
Expand Down
38 changes: 33 additions & 5 deletions spec/scrum_lint/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ module ScrumLint
let(:runner) { described_class.new }

before(:each) do
allow(Launchy).to receive(:open)

allow(::Trello::Board).to receive(:all).and_return([fake_trello_board])
allow(::Trello::Card).to receive(:find).and_return(fake_trello_card)

allow(Octokit::Source).to receive(:call).and_return([])
end

it 'configures trello settings' do
Expand All @@ -15,17 +20,40 @@ module ScrumLint
it 'validates the selected board' do
allow(Linter::MissingTaskList).to receive(:call).and_call_original
allow(Linter::ExtraList).to receive(:call).and_call_original
allow(Linter::MissingTaskList).to receive(:call).and_call_original
runner.([])
expect(Linter::MissingTaskList).to have_received(:call)
.with(instance_of(Board))
expect(Linter::ExtraList).to have_received(:call).with(instance_of(Board))
expect(Linter::ExtraList).to have_received(:call).with(instance_of(Board))
end

it 'checks contexts' do
allow(Linter::MissingContext).to receive(:call).and_call_original
runner.([])
expect(Linter::MissingContext).to have_received(:call)
.with(instance_of(Board))
describe 'card linters' do
it 'runs linters where card tags are superset of linter tags' do
allow(Linter::MissingHashTag).to receive(:call).and_call_original
allow(Linter::MissingContext).to receive(:call).and_call_original
allow(Linter::MissingExpendedPoints).to receive(:call)
runner.([])
expect(Linter::MissingHashTag).to have_received(:call)
.with(instance_of(Card))
expect(Linter::MissingContext).to have_received(:call)
.with(instance_of(Card))
expect(Linter::MissingExpendedPoints).not_to have_received(:call)
end

it 'runs linters where card tags are superset of linter tags' do
allow(ScrumLint::CardTagger).to receive(:call)
.and_return([:task, :done])
allow(Linter::MissingHashTag).to receive(:call).and_call_original
allow(Linter::MissingContext).to receive(:call)
allow(Linter::MissingExpendedPoints).to receive(:call).and_call_original
runner.([])
expect(Linter::MissingHashTag).to have_received(:call)
.with(instance_of(Card))
expect(Linter::MissingContext).not_to have_received(:call)
expect(Linter::MissingExpendedPoints).to have_received(:call)
.with(instance_of(Card))
end
end
end
end
7 changes: 1 addition & 6 deletions spec/support/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
SimpleCov.add_filter '/spec/'
SimpleCov.add_filter '/vendor/bundle/'

if ENV['TRAVIS']
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
else
SimpleCov.start
end
SimpleCov.start

SimpleCov.command_name "rspec_#{Process.pid}"
end
12 changes: 10 additions & 2 deletions spec/support/fake_builders.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
def fake_trello_card(name: 'What card', desc: 'some desc', **options)
instance_double(Trello::Card, name: name, desc: desc, **options)
instance_double(
Trello::Card,
name: name,
desc: desc,
card_labels: 'abc123',
short_url: 'https://foo.bar.baz.biz',
url: 'https://something.much.longer',
**options
)
end

def fake_trello_list(name: 'Planned', cards: [])
def fake_trello_list(name: 'Planned', cards: [fake_trello_card])
instance_double(Trello::List, name: name, cards: cards)
end

Expand Down

0 comments on commit e8d866a

Please sign in to comment.