def test_execute_fixer(self): tool = Rubocop(self.problems, {'fixer': True}, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' eq_(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer__fewer_problems_remain(self): tool = Rubocop(self.problems, {'fixer': True}, root_dir) # The fixture file can have all problems fixed by rubocop original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) read_and_restore_file(self.fixtures[1], original) eq_(1, len(self.problems.all()), 'Most errors should be fixed') assert_in('too long', self.problems.all()[0].body)
def test_process_files_one_file_fail_display_cop_names(self): options = { 'display_cop_names': 'True', } self.tool = Rubocop(self.problems, options) linty_filename = abspath(self.fixtures[1]) self.tool.process_files([linty_filename]) problems = self.problems.all(linty_filename) expected = Comment(linty_filename, 3, 3, 'C: Metrics/LineLength: Line is too long. [82/80]') eq_(expected, problems[4])
def test_process_files_one_file_fail_display_cop_names(self): options = { 'display_cop_names': 'True', } self.tool = Rubocop(self.problems, options) linty_filename = abspath(self.fixtures[1]) self.tool.process_files([linty_filename]) problems = self.problems.all(linty_filename) expected = Comment( linty_filename, 4, 4, 'C: Style/TrailingWhitespace: Trailing whitespace detected.') eq_(expected, problems[1])
def test_process_files_one_file_fail_display_cop_names__bool(self): options = { 'display_cop_names': True, } self.tool = Rubocop(self.problems, options, root_dir) linty_filename = self.fixtures[1] self.tool.process_files([linty_filename]) problems = self.problems.all(linty_filename) expected = Comment( linty_filename, 4, 4, 'C: Layout/TrailingWhitespace: Trailing whitespace detected.') self.assertEqual(expected, problems[1])
def test_process_files_one_file_fail_display_cop_names__bool(self): options = { 'display_cop_names': True, } self.tool = Rubocop(self.problems, options, root_dir) linty_filename = self.fixtures[1] self.tool.process_files([linty_filename]) problems = self.problems.all(linty_filename) long_line = problems[1] assert long_line.filename == linty_filename assert long_line.line == 3 assert long_line.position == 3 assert 'Lint/UnusedMethodArgument' in long_line.body
def test_process_files_one_file_fail_display_cop_names__bool(self): options = { 'display_cop_names': True, } self.tool = Rubocop(self.problems, options, root_dir) linty_filename = self.fixtures[1] self.tool.process_files([linty_filename]) problems = self.problems.all(linty_filename) long_line = problems[1] assert long_line.filename == linty_filename assert long_line.line == 3 assert long_line.position == 3 assert 'C: Metrics/LineLength: Line is too long. [82/80]' in long_line.body
def setUp(self): self.problems = Problems() self.tool = Rubocop(self.problems)
def test_has_fixer__enabled(self): tool = Rubocop(self.problems, {'fixer': True}, root_dir) eq_(True, tool.has_fixer())
def test_has_fixer__not_enabled(self): tool = Rubocop(self.problems, {}, root_dir) eq_(False, tool.has_fixer())
def setUp(self): self.problems = Problems() self.tool = Rubocop(self.problems, {}, root_dir)