Skip to content

Commit

Permalink
chore(spec): group scattered it blocks for Graphql Types (#3167)
Browse files Browse the repository at this point in the history
## Context

Our test suite has become pretty long to run.

## Description

This change **saves 951 examples**.

For all GQL types, we use one `it` block per line. It looks very good
but this is not ideal. This PR groups all the it blocks

> [!NOTE]
Once merged, I'll add the merge commit to the `.git-blame-ignore-revs`
file.

**Before**

```ruby
  it { is_expected.to ... }
  it { is_expected.to ... }
  it { is_expected.to ... }
```

**After**

```ruby
  it do
    expect(subject).to ...
    expect(subject).to ...
    expect(subject).to ...
  end
```

![CleanShot 2025-02-11 at 12 32
43@2x](https://github.com/user-attachments/assets/cf029987-221c-4340-a948-2dbca8dee6d8)
  • Loading branch information
julienbourdeau authored Feb 11, 2025
1 parent b88c03d commit f83dbe1
Show file tree
Hide file tree
Showing 112 changed files with 1,327 additions and 1,103 deletions.
16 changes: 9 additions & 7 deletions spec/graphql/types/add_ons/create_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
RSpec.describe Types::AddOns::CreateInput do
subject { described_class }

it { is_expected.to accept_argument(:amount_cents).of_type('BigInt!') }
it { is_expected.to accept_argument(:amount_currency).of_type('CurrencyEnum!') }
it { is_expected.to accept_argument(:code).of_type('String!') }
it { is_expected.to accept_argument(:description).of_type('String') }
it { is_expected.to accept_argument(:invoice_display_name).of_type('String') }
it { is_expected.to accept_argument(:name).of_type('String!') }
it { is_expected.to accept_argument(:tax_codes).of_type('[String!]') }
it do
expect(subject).to accept_argument(:amount_cents).of_type('BigInt!')
expect(subject).to accept_argument(:amount_currency).of_type('CurrencyEnum!')
expect(subject).to accept_argument(:code).of_type('String!')
expect(subject).to accept_argument(:description).of_type('String')
expect(subject).to accept_argument(:invoice_display_name).of_type('String')
expect(subject).to accept_argument(:name).of_type('String!')
expect(subject).to accept_argument(:tax_codes).of_type('[String!]')
end
end
32 changes: 17 additions & 15 deletions spec/graphql/types/add_ons/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
RSpec.describe Types::AddOns::Object do
subject { described_class }

it { is_expected.to have_field(:id).of_type('ID!') }
it { is_expected.to have_field(:organization).of_type('Organization') }
it { is_expected.to have_field(:code).of_type('String!') }
it { is_expected.to have_field(:description).of_type('String') }
it { is_expected.to have_field(:invoice_display_name).of_type('String') }
it { is_expected.to have_field(:name).of_type('String!') }
it { is_expected.to have_field(:amount_cents).of_type('BigInt!') }
it { is_expected.to have_field(:amount_currency).of_type('CurrencyEnum!') }
it { is_expected.to have_field(:created_at).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:deleted_at).of_type('ISO8601DateTime') }
it { is_expected.to have_field(:updated_at).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:applied_add_ons_count).of_type('Int!') }
it { is_expected.to have_field(:customers_count).of_type('Int!') }
it { is_expected.to have_field(:taxes).of_type('[Tax!]') }
it { is_expected.to have_field(:integration_mappings).of_type('[Mapping!]') }
it do
expect(subject).to have_field(:id).of_type('ID!')
expect(subject).to have_field(:organization).of_type('Organization')
expect(subject).to have_field(:code).of_type('String!')
expect(subject).to have_field(:description).of_type('String')
expect(subject).to have_field(:invoice_display_name).of_type('String')
expect(subject).to have_field(:name).of_type('String!')
expect(subject).to have_field(:amount_cents).of_type('BigInt!')
expect(subject).to have_field(:amount_currency).of_type('CurrencyEnum!')
expect(subject).to have_field(:created_at).of_type('ISO8601DateTime!')
expect(subject).to have_field(:deleted_at).of_type('ISO8601DateTime')
expect(subject).to have_field(:updated_at).of_type('ISO8601DateTime!')
expect(subject).to have_field(:applied_add_ons_count).of_type('Int!')
expect(subject).to have_field(:customers_count).of_type('Int!')
expect(subject).to have_field(:taxes).of_type('[Tax!]')
expect(subject).to have_field(:integration_mappings).of_type('[Mapping!]')
end
end
18 changes: 10 additions & 8 deletions spec/graphql/types/add_ons/update_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
RSpec.describe Types::AddOns::UpdateInput do
subject { described_class }

it { is_expected.to accept_argument(:amount_cents).of_type('BigInt!') }
it { is_expected.to accept_argument(:amount_currency).of_type('CurrencyEnum!') }
it { is_expected.to accept_argument(:code).of_type('String!') }
it { is_expected.to accept_argument(:description).of_type('String') }
it { is_expected.to accept_argument(:id).of_type('ID!') }
it { is_expected.to accept_argument(:invoice_display_name).of_type('String') }
it { is_expected.to accept_argument(:name).of_type('String!') }
it { is_expected.to accept_argument(:tax_codes).of_type('[String!]') }
it do
expect(subject).to accept_argument(:amount_cents).of_type('BigInt!')
expect(subject).to accept_argument(:amount_currency).of_type('CurrencyEnum!')
expect(subject).to accept_argument(:code).of_type('String!')
expect(subject).to accept_argument(:description).of_type('String')
expect(subject).to accept_argument(:id).of_type('ID!')
expect(subject).to accept_argument(:invoice_display_name).of_type('String')
expect(subject).to accept_argument(:name).of_type('String!')
expect(subject).to accept_argument(:tax_codes).of_type('[String!]')
end
end
18 changes: 10 additions & 8 deletions spec/graphql/types/adjusted_fees/create_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
RSpec.describe Types::AdjustedFees::CreateInput do
subject { described_class }

it { is_expected.to accept_argument(:invoice_id).of_type('ID!') }
it { is_expected.to accept_argument(:fee_id).of_type('ID') }
it { is_expected.to accept_argument(:charge_id).of_type('ID') }
it { is_expected.to accept_argument(:charge_filter_id).of_type('ID') }
it { is_expected.to accept_argument(:subscription_id).of_type('ID') }
it { is_expected.to accept_argument(:invoice_display_name).of_type('String') }
it { is_expected.to accept_argument(:unit_precise_amount).of_type('String') }
it { is_expected.to accept_argument(:units).of_type('Float') }
it do
expect(subject).to accept_argument(:invoice_id).of_type('ID!')
expect(subject).to accept_argument(:fee_id).of_type('ID')
expect(subject).to accept_argument(:charge_id).of_type('ID')
expect(subject).to accept_argument(:charge_filter_id).of_type('ID')
expect(subject).to accept_argument(:subscription_id).of_type('ID')
expect(subject).to accept_argument(:invoice_display_name).of_type('String')
expect(subject).to accept_argument(:unit_precise_amount).of_type('String')
expect(subject).to accept_argument(:units).of_type('Float')
end
end
8 changes: 5 additions & 3 deletions spec/graphql/types/analytics/gross_revenues/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
RSpec.describe Types::Analytics::GrossRevenues::Object do
subject { described_class }

it { is_expected.to have_field(:month).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:amount_cents).of_type('BigInt') }
it { is_expected.to have_field(:currency).of_type('CurrencyEnum') }
it do
expect(subject).to have_field(:month).of_type('ISO8601DateTime!')
expect(subject).to have_field(:amount_cents).of_type('BigInt')
expect(subject).to have_field(:currency).of_type('CurrencyEnum')
end
end
12 changes: 7 additions & 5 deletions spec/graphql/types/analytics/invoice_collections/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
RSpec.describe Types::Analytics::InvoiceCollections::Object do
subject { described_class }

it { is_expected.to have_field(:month).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:payment_status).of_type('InvoicePaymentStatusTypeEnum') }
it { is_expected.to have_field(:invoices_count).of_type('BigInt!') }
it { is_expected.to have_field(:amount_cents).of_type('BigInt!') }
it { is_expected.to have_field(:currency).of_type('CurrencyEnum') }
it do
expect(subject).to have_field(:month).of_type('ISO8601DateTime!')
expect(subject).to have_field(:payment_status).of_type('InvoicePaymentStatusTypeEnum')
expect(subject).to have_field(:invoices_count).of_type('BigInt!')
expect(subject).to have_field(:amount_cents).of_type('BigInt!')
expect(subject).to have_field(:currency).of_type('CurrencyEnum')
end
end
10 changes: 6 additions & 4 deletions spec/graphql/types/analytics/invoiced_usages/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
RSpec.describe Types::Analytics::InvoicedUsages::Object do
subject { described_class }

it { is_expected.to have_field(:month).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:code).of_type('String') }
it { is_expected.to have_field(:currency).of_type('CurrencyEnum!') }
it { is_expected.to have_field(:amount_cents).of_type('BigInt!') }
it do
expect(subject).to have_field(:month).of_type('ISO8601DateTime!')
expect(subject).to have_field(:code).of_type('String')
expect(subject).to have_field(:currency).of_type('CurrencyEnum!')
expect(subject).to have_field(:amount_cents).of_type('BigInt!')
end
end
8 changes: 5 additions & 3 deletions spec/graphql/types/analytics/mrrs/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
RSpec.describe Types::Analytics::Mrrs::Object do
subject { described_class }

it { is_expected.to have_field(:month).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:amount_cents).of_type('BigInt') }
it { is_expected.to have_field(:currency).of_type('CurrencyEnum') }
it do
expect(subject).to have_field(:month).of_type('ISO8601DateTime!')
expect(subject).to have_field(:amount_cents).of_type('BigInt')
expect(subject).to have_field(:currency).of_type('CurrencyEnum')
end
end
10 changes: 6 additions & 4 deletions spec/graphql/types/analytics/overdue_balances/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
RSpec.describe Types::Analytics::OverdueBalances::Object do
subject { described_class }

it { is_expected.to have_field(:amount_cents).of_type('BigInt!') }
it { is_expected.to have_field(:currency).of_type('CurrencyEnum!') }
it { is_expected.to have_field(:lago_invoice_ids).of_type('[String!]!') }
it { is_expected.to have_field(:month).of_type('ISO8601DateTime!') }
it do
expect(subject).to have_field(:amount_cents).of_type('BigInt!')
expect(subject).to have_field(:currency).of_type('CurrencyEnum!')
expect(subject).to have_field(:lago_invoice_ids).of_type('[String!]!')
expect(subject).to have_field(:month).of_type('ISO8601DateTime!')
end
end
16 changes: 9 additions & 7 deletions spec/graphql/types/api_keys/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
RSpec.describe Types::ApiKeys::Object do
subject { described_class }

it { is_expected.to have_field(:id).of_type('ID!') }
it { is_expected.to have_field(:name).of_type('String') }
it { is_expected.to have_field(:permissions).of_type('JSON!') }
it { is_expected.to have_field(:value).of_type('String!') }
it { is_expected.to have_field(:created_at).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:expires_at).of_type('ISO8601DateTime') }
it { is_expected.to have_field(:last_used_at).of_type('ISO8601DateTime') }
it do
expect(subject).to have_field(:id).of_type('ID!')
expect(subject).to have_field(:name).of_type('String')
expect(subject).to have_field(:permissions).of_type('JSON!')
expect(subject).to have_field(:value).of_type('String!')
expect(subject).to have_field(:created_at).of_type('ISO8601DateTime!')
expect(subject).to have_field(:expires_at).of_type('ISO8601DateTime')
expect(subject).to have_field(:last_used_at).of_type('ISO8601DateTime')
end
end
8 changes: 5 additions & 3 deletions spec/graphql/types/api_keys/rotate_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
RSpec.describe Types::ApiKeys::RotateInput do
subject { described_class }

it { is_expected.to accept_argument(:id).of_type('ID!') }
it { is_expected.to accept_argument(:name).of_type('String') }
it { is_expected.to accept_argument(:expires_at).of_type('ISO8601DateTime') }
it do
expect(subject).to accept_argument(:id).of_type('ID!')
expect(subject).to accept_argument(:name).of_type('String')
expect(subject).to accept_argument(:expires_at).of_type('ISO8601DateTime')
end
end
16 changes: 9 additions & 7 deletions spec/graphql/types/api_keys/sanitized_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
RSpec.describe Types::ApiKeys::SanitizedObject do
subject { described_class }

it { is_expected.to have_field(:id).of_type('ID!') }
it { is_expected.to have_field(:name).of_type('String') }
it { is_expected.to have_field(:permissions).of_type('JSON!') }
it { is_expected.to have_field(:value).of_type('String!') }
it { is_expected.to have_field(:created_at).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:expires_at).of_type('ISO8601DateTime') }
it { is_expected.to have_field(:last_used_at).of_type('ISO8601DateTime') }
it do
expect(subject).to have_field(:id).of_type('ID!')
expect(subject).to have_field(:name).of_type('String')
expect(subject).to have_field(:permissions).of_type('JSON!')
expect(subject).to have_field(:value).of_type('String!')
expect(subject).to have_field(:created_at).of_type('ISO8601DateTime!')
expect(subject).to have_field(:expires_at).of_type('ISO8601DateTime')
expect(subject).to have_field(:last_used_at).of_type('ISO8601DateTime')
end
end
8 changes: 5 additions & 3 deletions spec/graphql/types/api_keys/update_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
RSpec.describe Types::ApiKeys::UpdateInput do
subject { described_class }

it { is_expected.to accept_argument(:id).of_type('ID!') }
it { is_expected.to accept_argument(:name).of_type('String') }
it { is_expected.to accept_argument(:permissions).of_type('JSON') }
it do
expect(subject).to accept_argument(:id).of_type('ID!')
expect(subject).to accept_argument(:name).of_type('String')
expect(subject).to accept_argument(:permissions).of_type('JSON')
end
end
6 changes: 4 additions & 2 deletions spec/graphql/types/billable_metric_filters/input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
RSpec.describe Types::BillableMetricFilters::Input do
subject { described_class }

it { is_expected.to accept_argument(:key).of_type('String!') }
it { is_expected.to accept_argument(:values).of_type('[String!]!') }
it do
expect(subject).to accept_argument(:key).of_type('String!')
expect(subject).to accept_argument(:values).of_type('[String!]!')
end
end
8 changes: 5 additions & 3 deletions spec/graphql/types/billable_metric_filters/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
RSpec.describe Types::BillableMetricFilters::Object do
subject { described_class }

it { is_expected.to have_field(:id).of_type('ID!') }
it { is_expected.to have_field(:key).of_type('String!') }
it { is_expected.to have_field(:values).of_type('[String!]!') }
it do
expect(subject).to have_field(:id).of_type('ID!')
expect(subject).to have_field(:key).of_type('String!')
expect(subject).to have_field(:values).of_type('[String!]!')
end
end
24 changes: 13 additions & 11 deletions spec/graphql/types/billable_metrics/create_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
RSpec.describe Types::BillableMetrics::CreateInput do
subject { described_class }

it { is_expected.to accept_argument(:aggregation_type).of_type('AggregationTypeEnum!') }
it { is_expected.to accept_argument(:code).of_type('String!') }
it { is_expected.to accept_argument(:description).of_type('String!') }
it { is_expected.to accept_argument(:expression).of_type('String') }
it { is_expected.to accept_argument(:field_name).of_type('String') }
it { is_expected.to accept_argument(:name).of_type('String!') }
it { is_expected.to accept_argument(:recurring).of_type('Boolean') }
it { is_expected.to accept_argument(:rounding_function).of_type('RoundingFunctionEnum') }
it { is_expected.to accept_argument(:rounding_precision).of_type('Int') }
it { is_expected.to accept_argument(:weighted_interval).of_type('WeightedIntervalEnum') }
it { is_expected.to accept_argument(:filters).of_type('[BillableMetricFiltersInput!]') }
it do
expect(subject).to accept_argument(:aggregation_type).of_type('AggregationTypeEnum!')
expect(subject).to accept_argument(:code).of_type('String!')
expect(subject).to accept_argument(:description).of_type('String!')
expect(subject).to accept_argument(:expression).of_type('String')
expect(subject).to accept_argument(:field_name).of_type('String')
expect(subject).to accept_argument(:name).of_type('String!')
expect(subject).to accept_argument(:recurring).of_type('Boolean')
expect(subject).to accept_argument(:rounding_function).of_type('RoundingFunctionEnum')
expect(subject).to accept_argument(:rounding_precision).of_type('Int')
expect(subject).to accept_argument(:weighted_interval).of_type('WeightedIntervalEnum')
expect(subject).to accept_argument(:filters).of_type('[BillableMetricFiltersInput!]')
end
end
44 changes: 23 additions & 21 deletions spec/graphql/types/billable_metrics/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@
RSpec.describe Types::BillableMetrics::Object do
subject { described_class }

it { is_expected.to have_field(:id).of_type('ID!') }
it { is_expected.to have_field(:organization).of_type('Organization') }
it { is_expected.to have_field(:code).of_type('String!') }
it { is_expected.to have_field(:name).of_type('String!') }
it { is_expected.to have_field(:description).of_type('String') }
it { is_expected.to have_field(:aggregation_type).of_type('AggregationTypeEnum!') }
it { is_expected.to have_field(:expression).of_type('String') }
it { is_expected.to have_field(:field_name).of_type('String') }
it { is_expected.to have_field(:weighted_interval).of_type('WeightedIntervalEnum') }
it { is_expected.to have_field(:filters).of_type('[BillableMetricFilter!]') }
it { is_expected.to have_field(:active_subscriptions_count).of_type('Int!') }
it { is_expected.to have_field(:draft_invoices_count).of_type('Int!') }
it { is_expected.to have_field(:plans_count).of_type('Int!') }
it { is_expected.to have_field(:recurring).of_type('Boolean!') }
it { is_expected.to have_field(:subscriptions_count).of_type('Int!') }
it { is_expected.to have_field(:created_at).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:deleted_at).of_type('ISO8601DateTime') }
it { is_expected.to have_field(:updated_at).of_type('ISO8601DateTime!') }
it { is_expected.to have_field(:integration_mappings).of_type('[Mapping!]') }
it { is_expected.to have_field(:rounding_function).of_type('RoundingFunctionEnum') }
it { is_expected.to have_field(:rounding_precision).of_type('Int') }
it do
expect(subject).to have_field(:id).of_type('ID!')
expect(subject).to have_field(:organization).of_type('Organization')
expect(subject).to have_field(:code).of_type('String!')
expect(subject).to have_field(:name).of_type('String!')
expect(subject).to have_field(:description).of_type('String')
expect(subject).to have_field(:aggregation_type).of_type('AggregationTypeEnum!')
expect(subject).to have_field(:expression).of_type('String')
expect(subject).to have_field(:field_name).of_type('String')
expect(subject).to have_field(:weighted_interval).of_type('WeightedIntervalEnum')
expect(subject).to have_field(:filters).of_type('[BillableMetricFilter!]')
expect(subject).to have_field(:active_subscriptions_count).of_type('Int!')
expect(subject).to have_field(:draft_invoices_count).of_type('Int!')
expect(subject).to have_field(:plans_count).of_type('Int!')
expect(subject).to have_field(:recurring).of_type('Boolean!')
expect(subject).to have_field(:subscriptions_count).of_type('Int!')
expect(subject).to have_field(:created_at).of_type('ISO8601DateTime!')
expect(subject).to have_field(:deleted_at).of_type('ISO8601DateTime')
expect(subject).to have_field(:updated_at).of_type('ISO8601DateTime!')
expect(subject).to have_field(:integration_mappings).of_type('[Mapping!]')
expect(subject).to have_field(:rounding_function).of_type('RoundingFunctionEnum')
expect(subject).to have_field(:rounding_precision).of_type('Int')
end
end
26 changes: 14 additions & 12 deletions spec/graphql/types/billable_metrics/update_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
RSpec.describe Types::BillableMetrics::UpdateInput do
subject { described_class }

it { is_expected.to accept_argument(:id).of_type('String!') }
it { is_expected.to accept_argument(:aggregation_type).of_type('AggregationTypeEnum!') }
it { is_expected.to accept_argument(:code).of_type('String!') }
it { is_expected.to accept_argument(:description).of_type('String!') }
it { is_expected.to accept_argument(:expression).of_type('String') }
it { is_expected.to accept_argument(:field_name).of_type('String') }
it { is_expected.to accept_argument(:name).of_type('String!') }
it { is_expected.to accept_argument(:recurring).of_type('Boolean') }
it { is_expected.to accept_argument(:rounding_function).of_type('RoundingFunctionEnum') }
it { is_expected.to accept_argument(:rounding_precision).of_type('Int') }
it { is_expected.to accept_argument(:weighted_interval).of_type('WeightedIntervalEnum') }
it { is_expected.to accept_argument(:filters).of_type('[BillableMetricFiltersInput!]') }
it do
expect(subject).to accept_argument(:id).of_type('String!')
expect(subject).to accept_argument(:aggregation_type).of_type('AggregationTypeEnum!')
expect(subject).to accept_argument(:code).of_type('String!')
expect(subject).to accept_argument(:description).of_type('String!')
expect(subject).to accept_argument(:expression).of_type('String')
expect(subject).to accept_argument(:field_name).of_type('String')
expect(subject).to accept_argument(:name).of_type('String!')
expect(subject).to accept_argument(:recurring).of_type('Boolean')
expect(subject).to accept_argument(:rounding_function).of_type('RoundingFunctionEnum')
expect(subject).to accept_argument(:rounding_precision).of_type('Int')
expect(subject).to accept_argument(:weighted_interval).of_type('WeightedIntervalEnum')
expect(subject).to accept_argument(:filters).of_type('[BillableMetricFiltersInput!]')
end
end
Loading

0 comments on commit f83dbe1

Please sign in to comment.