Skip to content

Commit

Permalink
Merge pull request #23 from kyoshidajp/rspec_compare_as_hash
Browse files Browse the repository at this point in the history
RSpec converts YAML files to Hash before comparison
  • Loading branch information
k0kubun committed Apr 24, 2021
2 parents 37f3d44 + 3a749e5 commit 9a65dcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions spec/rspec/rack_test_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper'
require 'fileutils'
require 'yaml'

RSpec.describe 'rack-test spec' do
include SpecHelper
Expand All @@ -9,8 +10,9 @@
end

it 'generates the same spec/roda/doc/openapi.yaml' do
FileUtils.rm_f(openapi_path)
org_yaml = YAML.load(File.read(openapi_path))
rspec 'spec/requests/roda_spec.rb', openapi: true
assert_run 'git', 'diff', '--exit-code', '--', openapi_path
new_yaml = YAML.load(File.read(openapi_path))
expect(new_yaml).to eq org_yaml
end
end
6 changes: 4 additions & 2 deletions spec/rspec/rails_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'yaml'

RSpec.describe 'rails request spec' do
include SpecHelper
Expand All @@ -8,8 +9,9 @@
end

it 'generates the same spec/rails/doc/openapi.yaml' do
FileUtils.rm_f(openapi_path)
org_yaml = YAML.load(File.read(openapi_path))
rspec 'spec/requests/rails_spec.rb', openapi: true
assert_run 'git', 'diff', '--exit-code', '--', openapi_path
new_yaml = YAML.load(File.read(openapi_path))
expect(new_yaml).to eq org_yaml
end
end

0 comments on commit 9a65dcc

Please sign in to comment.