All Projects → izumin5210 → Rspec Validator_spec_helper

izumin5210 / Rspec Validator_spec_helper

Licence: mit
Provide dummy class for validator spec

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Rspec Validator spec helper

factory bot-preload
Preload factories (factory_bot) just like fixtures. It will be easy and, probably, faster!
Stars: ✭ 68 (+257.89%)
Mutual labels:  rspec
Rspec Style Guide
可読性の高いテストコードを書くためのお作法集
Stars: ✭ 325 (+1610.53%)
Mutual labels:  rspec
Rubocop Rspec
Code style checking for RSpec files
Stars: ✭ 603 (+3073.68%)
Mutual labels:  rspec
rubybookshelf
The Thoughtbot contest Winner application
Stars: ✭ 14 (-26.32%)
Mutual labels:  rspec
Shoulda Matchers
Simple one-liner tests for common Rails functionality
Stars: ✭ 3,166 (+16563.16%)
Mutual labels:  rspec
Autodoc
Generate documentation from your rack application & request-spec.
Stars: ✭ 366 (+1826.32%)
Mutual labels:  rspec
rspec-storage
RSpec output test report to any stroage (current support is [s3, gcs])
Stars: ✭ 22 (+15.79%)
Mutual labels:  rspec
Capybara error intel
🐛 Ruby gem for heuristic error messages in Capybara based Page Objects
Stars: ✭ 16 (-15.79%)
Mutual labels:  rspec
Infrataster
Infrastructure Behavior Testing Framework
Stars: ✭ 322 (+1594.74%)
Mutual labels:  rspec
Sinatra Template
A base Sinatra application template with DataMapper, and RSpec. Just fork and build.
Stars: ✭ 534 (+2710.53%)
Mutual labels:  rspec
Rspec junit formatter
RSpec results that your CI can read
Stars: ✭ 255 (+1242.11%)
Mutual labels:  rspec
Everydayrails Rspec 2017
Sample source for the 2017 edition of Everyday Rails Testing with RSpec.
Stars: ✭ 280 (+1373.68%)
Mutual labels:  rspec
Knapsack
Knapsack splits tests evenly across parallel CI nodes to run fast CI build and save you time.
Stars: ✭ 430 (+2163.16%)
Mutual labels:  rspec
jsonapi-swagger
Create a JSONAPI Swagger.
Stars: ✭ 49 (+157.89%)
Mutual labels:  rspec
Rspec Style Guide
Best practices for writing your specs!
Stars: ✭ 735 (+3768.42%)
Mutual labels:  rspec
spree-postal-service
Weight based calculator for Spree Commerce.
Stars: ✭ 21 (+10.53%)
Mutual labels:  rspec
N plus one control
RSpec and Minitest matchers to prevent N+1 queries problem
Stars: ✭ 345 (+1715.79%)
Mutual labels:  rspec
Aruba
Test command-line applications with Cucumber-Ruby, RSpec or Minitest. The most up to date documentation can be found on Cucumber.Pro (https://app.cucumber.pro/projects/aruba)
Stars: ✭ 900 (+4636.84%)
Mutual labels:  rspec
Chefspec
Write RSpec examples and generate coverage reports for Chef recipes!
Stars: ✭ 825 (+4242.11%)
Mutual labels:  rspec
Rspec Benchmark
Performance testing matchers for RSpec
Stars: ✭ 460 (+2321.05%)
Mutual labels:  rspec

RSpec::ValidatorSpecHelper

Build Status

Provide dummy class for validator spec

Installation

Add this line to your application's Gemfile, then execute bundle install.

gem 'rspec-validator_spec_helper'

Then include Rspec::ValidatorSpecHelper into your RSpec.configuration.

# spec/rails_helper.rb or spec/spec_helper.rb
RSpec.configure do |config|

  config.include RSpec::ValidatorSpecHelper, type: :validator

end

Usage

RSpec::ValidatorSpecHelper provides some let and subject to your example groups.

EachValidator

describe EmailValidator, type: :validator do
  describe '#validate_each' do
    context 'with invalid format address' do
      let(:value) { 'kokoro.pyonpyon' }
      it { is_expected.to_not be_valid }
    end

    context 'with valid format address' do
      let(:value) { '[email protected]' }
      it { is_expected.to be_valid }
    end

    context 'with strict option' do
      let(:options) { { strict: true } }
      let(:value) { '[email protected]' }
      it { is_expected.to_not be_valid }
    end
  end
end

Validator

describe NotOverlappedValidator, type: :validator do
  let(:attribute_names) { [:begin_at, :end_at] }
  let(:begin_at) { Time.parse("2014-12-24T12:00:00+09:00") }

  describe '#validate' do
    context 'when end_at is overlapped' do
      let(:end_at) { Time.parse("2014-12-24T09:00:00+09:00") }
      it { is_expected.to_not be_valid }
    end

    context 'when end_at is not overlapped' do
      let(:end_at) { Time.parse("2014-12-24T19:00:00+09:00") }
      it { is_expected.to be_valid }
    end

    context 'with allow_same_time option' do
      let(:options) { { allow_same_time: true } }
      let(:end_at) { begin_at }
      it { is_expected.to be_valid }
    end
  end
end

License

RSpec::ValidatorSpecHelper is licensed under MIT-LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].