<commit_before># frozen_string_literal: true

require 'rails_helper'

RSpec.describe Api::DeckResource, :type => :resource do
  let(:deck) { create :deck }
  let(:context) { {} }

  subject { described_class.new deck, context }

  it { is_expected.to have_primary_key :id }

  it { is_expected.to have_attribute :name }
  it { is_expected.to have_attribute :state }

  it { is_expected.to have_one :owner }

  it { is_expected.to have_many(:contributors).with_class_name 'User' }
  it { is_expected.to have_many(:tags).with_class_name 'Tag' }

  describe 'fields' do
    it 'should have a valid set of fetchable fields' do
      expect(subject.fetchable_fields).to match_array %i[id name state description owner contributors tags]
    end

    it 'should have a valid set of creatable fields' do
      expect(described_class.creatable_fields).to match_array %i[name state description owner]
    end

    it 'should have a valid set of updatable fields' do
      expect(described_class.updatable_fields).to match_array %i[name state description owner tags]
    end

    it 'should have a valid set of sortable fields' do
      expect(described_class.sortable_fields context).to match_array %i[id name state description]
    end
  end

  describe 'filters' do
    it 'should have a valid set of filters' do
      expect(described_class.filters.keys).to match_array %i[id name state description]
    end

    let(:verify) { described_class.filters[:state][:verify] }<commit_msg>Fix deck specs<commit_after># frozen_string_literal: true

require 'rails_helper'

RSpec.describe Api::DeckResource, :type => :resource do
  let(:deck) { create :deck }
  let(:context) { {} }

  subject { described_class.new deck, context }

  it { is_expected.to have_primary_key :id }

  it { is_expected.to have_attribute :name }
  it { is_expected.to have_attribute :state }

  it { is_expected.to have_one :owner }

  it { is_expected.to have_many(:contributors).with_class_name 'User' }

  describe 'fields' do
    it 'should have a valid set of fetchable fields' do
      expect(subject.fetchable_fields).to match_array %i[id name state description owner contributors]
    end

    it 'should have a valid set of creatable fields' do
      expect(described_class.creatable_fields).to match_array %i[name state description owner]
    end

    it 'should have a valid set of updatable fields' do
      expect(described_class.updatable_fields).to match_array %i[name state description owner]
    end

    it 'should have a valid set of sortable fields' do
      expect(described_class.sortable_fields context).to match_array %i[id name state description]
    end
  end

  describe 'filters' do
    it 'should have a valid set of filters' do
      expect(described_class.filters.keys).to match_array %i[id name state description]
    end

    let(:verify) { described_class.filters[:state][:verify] }
{'fraction_non_alphanumeric': 0.08582348853370396, 'fraction_numerical': 0.0, 'mean_word_length': 3.9723661485319517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3940804', 'n_tokens_mistral': 892, 'n_tokens_neox': 854, 'n_words': 276}