default_value_for-matchers 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -6
- data/.rspec +1 -0
- data/.travis.yml +1 -2
- data/Gemfile +0 -1
- data/README.md +37 -15
- data/Rakefile +7 -1
- data/default_value_for-matchers.gemspec +5 -0
- data/lib/default_value_for/matchers/version.rb +1 -1
- data/lib/default_value_for/matchers.rb +2 -0
- data/spec/dummy/application.rb +46 -0
- data/spec/dummy/bin/rails +5 -0
- data/spec/dummy/config.ru +1 -0
- data/spec/models/user_spec.rb +11 -0
- data/spec/spec_helper.rb +1 -0
- metadata +50 -4
- data/bin/console +0 -14
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96c01f22b3ebabd8305d2b947350974d7acfbf51
|
4
|
+
data.tar.gz: d5db41babefd12d974777d46ea8c9c9e792294ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f2aa9b9fa41734205774ada718f6d5dbcfe037a8f2af7bbfb2cd721c6e9ed1410780d5388d120aff5840a7d6a784189f029ce6fe01b5492f11faa3d3d42c063
|
7
|
+
data.tar.gz: 98d6c6adbf8e2ff28ff390f5d5cba618fb99cef8a89040421fe920c775c1439bb7723d04678d60c4426508c46e344c870d248a5d0930e54757715b8f1367d485
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,36 +1,58 @@
|
|
1
|
-
#
|
1
|
+
# default_value_for-matchers
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/default_value_for-matchers.svg)](http://badge.fury.io/rb/default_value_for-matchers)
|
4
4
|
|
5
|
-
|
5
|
+
This gem is a RSpec matchers for [default_value_for](https://github.com/FooBarWidget/default_value_for) gem.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
|
12
|
+
group :test do
|
13
|
+
gem 'default_value_for-matchers'
|
14
|
+
end
|
13
15
|
```
|
14
16
|
|
15
17
|
And then execute:
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
$ gem install default_value_for-matchers
|
19
|
+
```
|
20
|
+
$ bundle
|
21
|
+
```
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Include `default_value_for/matchers` in your `rails_helper.rb`:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'default_value_for/matchers'
|
29
|
+
```
|
26
30
|
|
27
|
-
|
31
|
+
Then you can use `have_default_value_for` matcher and `with_value`, `and_allow_nil` and `and_disallow_nil` submatchers.
|
28
32
|
|
29
|
-
|
33
|
+
For example:
|
30
34
|
|
31
|
-
|
35
|
+
```ruby
|
36
|
+
# app/models/user.rb
|
37
|
+
class User < ActiveRecord::Base
|
38
|
+
default_value_for :name, 'no name'
|
39
|
+
default_value_for :age, value: 20, allows_nil: false
|
40
|
+
end
|
41
|
+
|
42
|
+
# spec/models/user.rb
|
43
|
+
describe User, type: :model do
|
44
|
+
# name
|
45
|
+
it { is_expected.to have_default_value_for(:name) }
|
46
|
+
it { is_expected.to have_default_value_for(:name).with_value('no name') }
|
47
|
+
it { is_expected.to have_default_value_for(:name).with_value('no name').and_allow_nil }
|
48
|
+
|
49
|
+
# age
|
50
|
+
it { is_expected.to have_default_value_for(:age) }
|
51
|
+
it { is_expected.to have_default_value_for(:age).with_value(20) }
|
52
|
+
it { is_expected.to have_default_value_for(:age).with_value(20).and_disallow_nil }
|
53
|
+
end
|
54
|
+
```
|
32
55
|
|
33
56
|
## Contributing
|
34
57
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
36
|
-
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kami30k/default_value_for-matchers.
|
data/Rakefile
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
$:.unshift File.expand_path('../../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'action_controller/railtie'
|
4
|
+
require 'active_record'
|
5
|
+
|
6
|
+
require 'default_value_for'
|
7
|
+
require 'default_value_for/matchers'
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
config.secret_token = 'abcdefghijklmnopqrstuvwxyz0123456789'
|
12
|
+
config.session_store :cookie_store, key: '_dummy_session'
|
13
|
+
config.eager_load = false
|
14
|
+
config.active_support.deprecation = :log
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Dummy::Application.initialize!
|
19
|
+
|
20
|
+
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
21
|
+
|
22
|
+
#
|
23
|
+
# Models
|
24
|
+
#
|
25
|
+
|
26
|
+
class User < ActiveRecord::Base
|
27
|
+
default_value_for :name, 'no name'
|
28
|
+
default_value_for :age, value: 20, allows_nil: false
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Migrates
|
33
|
+
#
|
34
|
+
|
35
|
+
class CreateUsers < ActiveRecord::Migration
|
36
|
+
def change
|
37
|
+
create_table :users do |t|
|
38
|
+
t.string :name
|
39
|
+
t.integer :age
|
40
|
+
|
41
|
+
t.timestamps null: false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
CreateUsers.new.change
|
@@ -0,0 +1 @@
|
|
1
|
+
run Rails.application
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe User, type: :model do
|
4
|
+
it { is_expected.to have_default_value_for(:name) }
|
5
|
+
it { is_expected.to have_default_value_for(:name).with_value('no name') }
|
6
|
+
it { is_expected.to have_default_value_for(:name).with_value('no name').and_allow_nil }
|
7
|
+
|
8
|
+
it { is_expected.to have_default_value_for(:age) }
|
9
|
+
it { is_expected.to have_default_value_for(:age).with_value(20) }
|
10
|
+
it { is_expected.to have_default_value_for(:age).with_value(20).and_disallow_nil }
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'dummy/application'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: default_value_for-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kami
|
@@ -9,7 +9,49 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-07-03 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: default_value_for
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
description: RSpec matchers for default_value_for gem.
|
14
56
|
email: kami30k@gmail.com
|
15
57
|
executables: []
|
@@ -17,15 +59,19 @@ extensions: []
|
|
17
59
|
extra_rdoc_files: []
|
18
60
|
files:
|
19
61
|
- ".gitignore"
|
62
|
+
- ".rspec"
|
20
63
|
- ".travis.yml"
|
21
64
|
- Gemfile
|
22
65
|
- README.md
|
23
66
|
- Rakefile
|
24
|
-
- bin/console
|
25
|
-
- bin/setup
|
26
67
|
- default_value_for-matchers.gemspec
|
27
68
|
- lib/default_value_for/matchers.rb
|
28
69
|
- lib/default_value_for/matchers/version.rb
|
70
|
+
- spec/dummy/application.rb
|
71
|
+
- spec/dummy/bin/rails
|
72
|
+
- spec/dummy/config.ru
|
73
|
+
- spec/models/user_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
29
75
|
homepage: https://github.com/kami30k/default_value_for-matchers
|
30
76
|
licenses:
|
31
77
|
- MIT
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "default_value_for/matchers"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|