Skip to content

Commit

Permalink
up: require spec support files
Browse files Browse the repository at this point in the history
  • Loading branch information
wbotelhos committed Mar 19, 2022
1 parent b7d350e commit 057d213
Show file tree
Hide file tree
Showing 29 changed files with 25 additions and 61 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require common_helper
24 changes: 24 additions & 0 deletions spec/common_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

ENV['RAILS_ENV'] ||= 'test'

require 'support/coverage'

require 'normalizy'
require 'pry-byebug'

require 'support/db/schema'
require 'support/filters/blacklist'
require 'support/filters/block'
require 'support/filters/info'

require 'support/models/alias'
require 'support/models/match'
require 'support/models/model'
require 'support/models/model_date'
require 'support/models/model_money'
require 'support/models/model_number'
require 'support/models/model_percent'
require 'support/models/model_slug'
require 'support/models/model_strip'
require 'support/models/rule'
2 changes: 0 additions & 2 deletions spec/normalizy/config/add_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Config, '#add' do
it 'adds filters to the built-in filters' do
Normalizy.configure do |config|
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/config/alias_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Config, '#alias' do
it 'accepts alias' do
Normalizy.configure do |config|
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/config/default_filters_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Config, 'default_filters' do
context 'when get' do
it 'returns the default filters' do
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/config/initialize_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Config, 'filters' do
it 'loads some filters' do
expect(subject.filters).to eq(
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/config/normalizy_aliases_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Config, 'normalizy_aliases' do
it 'has the right defaults' do
expect(subject.normalizy_aliases).to eq({})
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/filters/date_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelDate, 'filters:date' do
it { expect(described_class.create(date: '1984-10-23').date).to eq(Time.new(1984, 10, 23, 0, 0, 0, 0)) }
it { expect(described_class.create(date_format: '84/10/23').date_format).to eq(Time.new(1984, 10, 23, 0, 0, 0, 0)) }
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/filters/money_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelMoney, 'filters:money' do
it do
expect(described_class.create(text: '$ 42.00').text).to eq '42.00'
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/filters/number_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelNumber, 'filters:number' do
it do
expect(described_class.create(number: 'Botelho 32').number).to eq '32'
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/filters/percent_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelPercent, 'filters:percent' do
it do
expect(described_class.create(text: '42.00 %').text).to eq '42.00'
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/filters/slug_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelSlug, 'filters:slug' do
from = 'The Títle'
to = 'the-title'
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/filters/strip_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe ModelStrip, 'filters:strip' do
it do
expect(described_class.create(strip: ' Botelho ').strip).to eq 'Botelho'
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/model_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe '#apply_normalizy' do
context 'when object has no normalizy' do
it do
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/extensions/normalizy_rules_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Extension, ':normalizy_rules' do
let!(:model) { Rule }

Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/filters/date_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Filters::Date do
it { expect(subject.call('')).to eq '' }

Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/filters/money_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Filters::Money do
describe 'default options' do
it { expect(subject.call('')).to eq nil }
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/filters/number_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Filters::Number do
context 'with no cast' do
it { expect(subject.call('abcdefghijklmnopkrstuvxyz')).to eq nil }
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/filters/percent_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Filters::Percent do
describe 'default options' do
it { expect(subject.call('')).to eq nil }
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/filters/slug_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Filters::Slug do
describe 'default options' do
it { expect(subject.call(nil)).to eq nil }
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/filters/strip_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::Filters::Strip do
it { expect(subject.call(' Some Text ')).to eq 'Some Text' }
it { expect(subject.call(' Some Text ', side: :left)).to eq 'Some Text ' }
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/normalizy/configure_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy, '#configure' do
it 'yields the default config' do
described_class.configure do |conf|
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/rspec/matcher/description_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::RSpec::Matcher, '.description' do
let!(:matcher) { described_class.new :name }

Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/rspec/matcher/failure_message_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::RSpec::Matcher, '.failure_message' do
let!(:model) { Match }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::RSpec::Matcher, '.failure_message_when_negated' do
let!(:model) { Match }

Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/rspec/matcher/from_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::RSpec::Matcher, '.from' do
it 'caches the value' do
matcher = described_class.new(:downcase_field)
Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/rspec/matcher/matches_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
let!(:object) { Match.new }

Expand Down
2 changes: 0 additions & 2 deletions spec/normalizy/rspec/matcher/to_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::RSpec::Matcher, '.to' do
it 'caches the value' do
matcher = described_class.new(:downcase)
Expand Down
9 changes: 0 additions & 9 deletions spec/rails_helper.rb

This file was deleted.

0 comments on commit 057d213

Please sign in to comment.