File: test_jsonpath_bin.rb

package info (click to toggle)
ruby-jsonpath 1.1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 332 kB
  • sloc: ruby: 1,831; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'minitest/autorun'
require 'jsonpath'

class TestJsonpathBin < Minitest::Test
  def setup
    @runner = 'ruby -Ilib bin/jsonpath'
    @original_dir = Dir.pwd
    Dir.chdir(File.join(File.dirname(__FILE__), '..'))
  end

  def teardown
    Dir.chdir(@original_dir)
    `rm /tmp/test.json`
  end

  def test_stdin
    File.open('/tmp/test.json', 'w') { |f| f << '{"test": "time"}' }
    assert_equal '["time"]', `#{@runner} '$.test' /tmp/test.json`.strip
  end
end