Skip to content

Commit

Permalink
Merge pull request #33 from SonicGarden/dev
Browse files Browse the repository at this point in the history
v4
  • Loading branch information
aki77 authored Jun 26, 2024
2 parents 92f5074 + 234d81b commit 1ee6b97
Show file tree
Hide file tree
Showing 11 changed files with 30,062 additions and 21,601 deletions.
File renamed without changes.
33 changes: 33 additions & 0 deletions .dummy_results-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version":"3.9.2",
"examples":[
{
"id":"./spec/activestorage/validator/blob_spec.rb[1:1:1:1]",
"description":"is expected to eq false",
"full_description":"ActiveRecord::Validations::BlobValidator presence: true has_one_attached is expected to eq false",
"status":"passed",
"file_path":"./spec/activestorage/validator/blob_spec.rb",
"line_number":10,
"run_time":0.016242,
"pending_message":null
},
{
"id":"./spec/activestorage/validator/blob_spec.rb[1:1:1:2]",
"description":"is expected to eq true",
"full_description":"ActiveRecord::Validations::BlobValidator presence: true has_one_attached is expected to eq true",
"status":"passed",
"file_path":"./spec/activestorage/validator/blob_spec.rb",
"line_number":11,
"run_time":0.044519,
"pending_message": "Not yet implemented"
}
],
"summary":{
"duration":0.297397,
"example_count":1,
"failure_count":0,
"pending_count":0,
"errors_outside_of_examples_count":0
},
"summary_line":"1 example, 0 failures, 1 pending"
}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
json-path: '.dummy_results.json'
json-path: '.dummy_results-0.json'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: bundle exec rspec -f j -o tmp/rspec_results.json -f p

- name: RSpec Report
uses: SonicGarden/rspec-report-action@v3
uses: SonicGarden/rspec-report-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
json-path: tmp/rspec_results.json
Expand Down
24 changes: 17 additions & 7 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import * as path from 'path'
import {parse} from '../src/parse'
import {expect, test} from '@jest/globals'
import * as core from '@actions/core'
import {reportSummary} from '../src/report-summary'
import run from '../src/main'

test('Parse rspec result json', async () => {
const result = parse(path.resolve(__dirname, '../.dummy_results.json'))
expect(result).toEqual({
summary: '25 examples, 1 failure',
import {expect, jest, test} from '@jest/globals'

jest.mock('@actions/core')
jest.mock('../src/report-summary')
const mockedCore = jest.mocked(core)

test('Parse multiple rspec json results', async () => {
mockedCore.getInput.mockReturnValue(
path.resolve(__dirname, '../.dummy_results-*.json')
)
await run()
expect(reportSummary).toHaveBeenCalledWith({
examples: [
{
filePath: 'spec/activestorage/validator/blob_spec.rb',
Expand All @@ -15,6 +24,7 @@ test('Parse rspec result json', async () => {
message: '\\nexpected: true\\n got: false\\n\\n(compared using ==)'
}
],
success: false
success: false,
summary: '27 examples, 1 failure, 1 pending'
})
})
20 changes: 20 additions & 0 deletions __tests__/parse.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as path from 'path'
import {parse} from '../src/parse'
import {expect, test} from '@jest/globals'

test('Parse rspec result json', async () => {
const result = parse([path.resolve(__dirname, '../.dummy_results-0.json')])
expect(result).toEqual({
summary: '25 examples, 1 failure',
examples: [
{
filePath: 'spec/activestorage/validator/blob_spec.rb',
lineNumber: 37,
description:
'ActiveRecord::Validations::BlobValidator with size_range option 1.4MB is expected to eq true',
message: '\\nexpected: true\\n got: false\\n\\n(compared using ==)'
}
],
success: false
})
})
Loading

0 comments on commit 1ee6b97

Please sign in to comment.