<commit_before>require 'spec_helper'

describe 'ScalrApiV2::Roles.list' do
  subject do
    with_modified_env SCALR_URL: 'https://test.scalr.local', SCALR_KEY_ID: '1234', SCALR_KEY_SECRET: '5678', SCALR_ENV_ID: '1' do
      ScalrApiV2::Roles.new.list
    end
  end

  # list method tests
  it '.list returns an array' do
    expect(subject).not_to be nil
    expect(subject).to be_kind_of(Array)
  end

  it '.list returns stubbed data from fakeScalr' do
    expect(subject[0]['id']).to eq('1')
    expect(subject[1]['id']).to eq('2')
  end
end

describe 'ScalrApiV2::Roles.create' do
  subject do
    with_modified_env SCALR_URL: 'https://test.scalr.local', SCALR_KEY_ID: '1234', SCALR_KEY_SECRET: '5678', SCALR_ENV_ID: '1' do
      ScalrApiV2::Roles.new.create({ 'builtinAutomation' => ['base', 'chef'], 'category' => { 'id' => 1 }, 'name' => 'apirolemike', 'os' => { 'id' => 'centos-7-x' } })
    end
  end<commit_msg>Rubocop fixes<commit_after>require 'spec_helper'

describe 'ScalrApiV2::Roles.list' do
  subject do
    with_modified_env SCALR_URL: 'https://test.scalr.local', SCALR_KEY_ID: '1234', SCALR_KEY_SECRET: '5678', SCALR_ENV_ID: '1' do
      ScalrApiV2::Roles.new.list
    end
  end

  # list method tests
  it '.list returns an array' do
    expect(subject).not_to be nil
    expect(subject).to be_kind_of(Array)
  end

  it '.list returns stubbed data from fakeScalr' do
    expect(subject[0]['id']).to eq('1')
    expect(subject[1]['id']).to eq('2')
  end
end

describe 'ScalrApiV2::Roles.create' do
  subject do
    with_modified_env SCALR_URL: 'https://test.scalr.local', SCALR_KEY_ID: '1234', SCALR_KEY_SECRET: '5678', SCALR_ENV_ID: '1' do
      ScalrApiV2::Roles.new.create({ 'builtinAutomation' => %w[base chef], 'category' => { 'id' => 1 }, 'name' => 'apirolemike', 'os' => { 'id' => 'centos-7-x' } })
    end
  end
{'fraction_non_alphanumeric': 0.1631321370309951, 'fraction_numerical': 0.030451332245785754, 'mean_word_length': 4.168539325842697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6843109', 'n_tokens_mistral': 765, 'n_tokens_neox': 732, 'n_words': 156}