spec/pmd_spec.rb in danger-pmd-1.0.2 vs spec/pmd_spec.rb in danger-pmd-1.0.3
- old
+ new
@@ -17,61 +17,66 @@
it 'Check default Gradle task' do
expect(@pmd.gradle_task).to eq('pmd')
end
it 'Set custom Gradle task' do
- custom_task = 'pmdStagingDebug'
- @pmd.gradle_task = custom_task
- expect(@pmd.gradle_task).to eq(custom_task)
+ @pmd.gradle_task = 'pmdStagingDebug'
+ expect(@pmd.gradle_task).to eq('pmdStagingDebug')
end
it 'Check default skip Gradle task' do
- expect(@pmd.skip_gradle_task).to eq(false)
+ expect(@pmd.skip_gradle_task).to be_falsey
end
it 'Set custom skip Gradle task' do
- skip_gradle_task = true
- @pmd.skip_gradle_task = skip_gradle_task
- expect(@pmd.skip_gradle_task).to eq(skip_gradle_task)
+ @pmd.skip_gradle_task = true
+ expect(@pmd.skip_gradle_task).to be_truthy
end
+ it 'Check default root path' do
+ expect(@pmd.root_path).to eq(Dir.pwd)
+ end
+
+ it 'Set custom root path' do
+ @pmd.root_path = '/Users/developer/project'
+ expect(@pmd.root_path).to eq('/Users/developer/project')
+ end
+
it 'Check default report file path' do
expect(@pmd.report_file).to eq('app/build/reports/pmd/pmd.xml')
end
it 'Set custom report file path' do
- custom_report_path = 'custom-path/pmd_sub_report.xml'
- @pmd.report_file = custom_report_path
- expect(@pmd.report_file).to eq(custom_report_path)
+ @pmd.report_file = 'custom-path/pmd_sub_report.xml'
+ expect(@pmd.report_file).to eq('custom-path/pmd_sub_report.xml')
end
it 'Check default report files paths' do
- expect(@pmd.report_files).to eq(['app/build/reports/pmd/pmd.xml'])
+ expect(@pmd.report_files).to contain_exactly('app/build/reports/pmd/pmd.xml')
end
it 'Set custom report files paths' do
- custom_report_paths = %w[custom-path/pmd_report_1.xml custom-path/pmd_report_2.xml]
- @pmd.report_files = custom_report_paths
- expect(@pmd.report_files).to eq(custom_report_paths)
+ @pmd.report_files = %w[custom-path/pmd_report_1.xml custom-path/pmd_report_2.xml]
+ expect(@pmd.report_files).to contain_exactly('custom-path/pmd_report_1.xml', 'custom-path/pmd_report_2.xml')
end
it 'Check default root path' do
expect(@pmd.root_path).to eq(Dir.pwd)
end
it 'Set custom root path' do
- root_path = '/Users/developer/sample/'
- @pmd.root_path = root_path
- expect(@pmd.root_path).to eq(root_path)
+ @pmd.root_path = '/Users/developer/sample/'
+ expect(@pmd.root_path).to eq('/Users/developer/sample/')
end
it 'Report with report file' do
+ # noinspection RubyLiteralArrayInspection
target_files = [
- "app/src/main/java/com/android/sample/MainActivity.java",
- "app/src/main/java/com/android/sample/Tools.java",
- "app/src/test/java/com/android/sample/ExampleUnitTest.java",
- "app/src/test/java/com/android/sample/ToolsTest.java"
+ 'app/src/main/java/com/android/sample/MainActivity.java',
+ 'app/src/main/java/com/android/sample/Tools.java',
+ 'app/src/test/java/com/android/sample/ExampleUnitTest.java',
+ 'app/src/test/java/com/android/sample/ToolsTest.java'
]
allow_any_instance_of(Danger::DangerPmd).to receive(:target_files).and_return(target_files)
@pmd.report_file = 'spec/fixtures/pmd_report.xml'
@pmd.root_path = '/Users/developer/sample/'
@@ -123,19 +128,20 @@
expect(pmd_issue4.violations[1]).not_to be_nil
expect(pmd_issue4.violations[1].line).to eq(18)
expect(pmd_issue4.violations[1].description).to eq("The JUnit 4 test method name 'getLabel_2' doesn't match '[a-z][a-zA-Z0-9]*'")
end
- it "Report with report file not in target files" do
+ it 'Report with report file not in target files' do
+ # noinspection RubyLiteralArrayInspection
target_files = [
- "app/src/main/java/com/android/sample/Tools.java",
- "app/src/test/java/com/android/sample/ToolsTest.java"
+ 'app/src/main/java/com/android/sample/Tools.java',
+ 'app/src/test/java/com/android/sample/ToolsTest.java'
]
allow_any_instance_of(Danger::DangerPmd).to receive(:target_files).and_return(target_files)
- @pmd.report_file = "spec/fixtures/pmd_report.xml"
- @pmd.root_path = "/Users/developer/sample/"
+ @pmd.report_file = 'spec/fixtures/pmd_report.xml'
+ @pmd.root_path = '/Users/developer/sample/'
@pmd.skip_gradle_task = true
pmd_issues = @pmd.report
expect(pmd_issues).not_to be_nil
expect(pmd_issues.length).to be(2)
@@ -162,17 +168,18 @@
expect(pmd_issue2.violations[1]).not_to be_nil
expect(pmd_issue2.violations[1].line).to eq(18)
expect(pmd_issue2.violations[1].description).to eq("The JUnit 4 test method name 'getLabel_2' doesn't match '[a-z][a-zA-Z0-9]*'")
end
- it "Report with report files" do
+ it 'Report with report files' do
+ # noinspection RubyLiteralArrayInspection
target_files = [
- "app/src/main/java/com/android/sample/Application.java",
- "app/src/main/java/com/android/sample/MainActivity.java",
- "app/src/main/java/com/android/sample/Tools.java",
- "app/src/main/java/com/android/sample/Utils.java",
- "app/src/test/java/com/android/sample/ExampleUnitTest.java",
- "app/src/test/java/com/android/sample/ToolsTest.java"
+ 'app/src/main/java/com/android/sample/Application.java',
+ 'app/src/main/java/com/android/sample/MainActivity.java',
+ 'app/src/main/java/com/android/sample/Tools.java',
+ 'app/src/main/java/com/android/sample/Utils.java',
+ 'app/src/test/java/com/android/sample/ExampleUnitTest.java',
+ 'app/src/test/java/com/android/sample/ToolsTest.java'
]
allow_any_instance_of(Danger::DangerPmd).to receive(:target_files).and_return(target_files)
@pmd.report_files = %w[spec/fixtures/pmd_report.xml spec/fixtures/**/pmd_sub_report.xml]
@pmd.root_path = '/Users/developer/sample/'