diff options
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/integration_test_helper.rb | 3 | ||||
| -rw-r--r-- | spec/support/matchers.rb | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb index 485af1b..5ef00a1 100644 --- a/spec/support/integration_test_helper.rb +++ b/spec/support/integration_test_helper.rb @@ -2,7 +2,8 @@ module IntegrationTestHelper class IntegrationTestRunner attr_reader :project_path - def initialize(project_path = Dir.mktmpdir('lm')) + def initialize(project_path = File.join(Dir.pwd, 'tmp', SecureRandom.uuid)) + FileUtils.mkdir_p(project_path) @project_path = project_path end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb new file mode 100644 index 0000000..1d1c263 --- /dev/null +++ b/spec/support/matchers.rb @@ -0,0 +1,14 @@ +RSpec::Matchers.define :match_schema do |version: '2.0'| + match do |actual| + schema = License::Management.root + .join("spec/fixtures/schema/v#{version}.json") + .to_s + @errors = JSON::Validator.fully_validate(schema, actual) + @errors.empty? + end + + failure_message do |response| + "didn't match the schema for version #{version}" \ + " The validation errors were:\n#{@errors.join("\n")}" + end +end |
