No commit activity in last 3 years
No release in over 3 years
RSpec matchers for default_value_for gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

default_value_for-matchers

Build Status Gem Version

This gem is a RSpec matchers for default_value_for gem.

Installation

Add this line to your application's Gemfile:

group :test do
  gem 'default_value_for-matchers'
end

And then execute:

$ bundle

Usage

You can use have_default_value_for matcher and with_value, and_allow_nil, and_disallow_nil submatchers.

For example:

# app/models/user.rb
class User < ActiveRecord::Base
  default_value_for :name, 'no name'
  default_value_for :age, value: 20, allows_nil: false
end

# spec/models/user.rb
describe User, type: :model do
  # name
  it { is_expected.to have_default_value_for(:name) }
  it { is_expected.to have_default_value_for(:name).with_value('no name') }
  it { is_expected.to have_default_value_for(:name).with_value('no name').and_allow_nil }

  # age
  it { is_expected.to have_default_value_for(:age) }
  it { is_expected.to have_default_value_for(:age).with_value(20) }
  it { is_expected.to have_default_value_for(:age).with_value(20).and_disallow_nil }
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kami-zh/default_value_for-matchers.