Sha256: 4eb68da3a0e66f15871ca870c2729f817d22405ed73e6906e694ef9479aa2d30

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe PuppetStrings::Yard::Parsers::JSON::TaskStatement do
  let(:source) { <<-SOURCE
{
  "description": "Allows you to backup your database to local file.",
  "input_method": "stdin",
  "parameters": {
    "database": {
      "description": "Database to connect to",
      "type": "Optional[String[1]]"
    },
    "user": {
      "description": "The user",
      "type": "Optional[String[1]]"
    },
    "password": {
      "description": "The password",
      "type": "Optional[String[1]]"
    },
     "sql": {
      "description": "Path to file you want backup to",
      "type": "String[1]"
    }
  }
}
SOURCE
  }
  let(:json) { JSON.parse(source) }
  subject { PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, source, "test.json") }
  describe '#comments' do
    it 'returns docstring' do
      expect(subject.comments).to eq "Allows you to backup your database to local file."
    end
  end
  describe '#parameters' do
    context 'with params' do
      it 'returns params' do
        expect(subject.parameters.size > 0).to be true
      end
    end
    context 'no params' do
      let(:source) { <<-SOURCE
{
  "description": "Allows you to backup your database to local file.",
  "input_method": "stdin"
}
SOURCE
      }
      it 'returns an empty hash' do
        expect(subject.parameters).to eq({})
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-strings-2.2.0 spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb
puppet-strings-2.1.0 spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb
puppet-strings-2.0.0 spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb