default_value_for-matchers 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/default_value_for-matchers.gemspec +17 -0
- data/lib/default_value_for/matchers.rb +51 -0
- data/lib/default_value_for/matchers/version.rb +5 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 37dc1467effb2836ade6333b56b9ac0871115757
|
4
|
+
data.tar.gz: 34b8545dd8b3dc996cc49faa6bd32b65eb03859c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 18d94f93b6f22c930e44e52f19be14fe776b5c0c76c69e3868427aa150a1c66b88ee62c633ecc235227e60cd46cf7c13bcbe8e6c801e0bbc1a4dc13dd2db29c5
|
7
|
+
data.tar.gz: 542bf88769bbe45a18a47e10819382468f9f5599800ef78638f3249f1ff10dbdcbda99e91c0a674137deb709ed5c0ac38920e9a6ad9f457cf4f8a417d592044e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# DefaultValueFor::Matchers
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/default_value_for/matchers`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'default_value_for-matchers'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install default_value_for-matchers
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/default_value_for-matchers.
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'default_value_for/matchers/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'default_value_for-matchers'
|
7
|
+
s.version = DefaultValueFor::Matchers::VERSION
|
8
|
+
s.authors = 'kami'
|
9
|
+
s.email = 'kami30k@gmail.com'
|
10
|
+
|
11
|
+
s.summary = 'RSpec matchers for default_value_for gem.'
|
12
|
+
s.description = 'RSpec matchers for default_value_for gem.'
|
13
|
+
s.homepage = 'https://github.com/kami30k/default_value_for-matchers'
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
RSpec::Matchers.define :have_default_value_for do |attribute|
|
2
|
+
match do
|
3
|
+
@attribute = attribute.to_s
|
4
|
+
@values = klass._default_attribute_values
|
5
|
+
@disallow_nil = klass._default_attribute_values_not_allowing_nil
|
6
|
+
|
7
|
+
match?
|
8
|
+
end
|
9
|
+
|
10
|
+
chain :with_value do |value|
|
11
|
+
@expected_value = value
|
12
|
+
end
|
13
|
+
|
14
|
+
chain :and_allow_nil do
|
15
|
+
@expected_disallow_nil = false
|
16
|
+
end
|
17
|
+
|
18
|
+
chain :and_disallow_nil do
|
19
|
+
@expected_disallow_nil = true
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def klass
|
25
|
+
subject.class
|
26
|
+
end
|
27
|
+
|
28
|
+
def match?
|
29
|
+
have_value? && have_expected_value? && disallows_nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
def have_value?
|
33
|
+
!@values[@attribute].nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
def have_expected_value?
|
37
|
+
if @expected_value.nil?
|
38
|
+
true
|
39
|
+
else
|
40
|
+
@values[@attribute].instance_variable_get(:@value) == @expected_value
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def disallows_nil?
|
45
|
+
if @expected_disallow_nil.nil?
|
46
|
+
true
|
47
|
+
else
|
48
|
+
@disallow_nil.include?(@attribute) == @expected_disallow_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: default_value_for-matchers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kami
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: RSpec matchers for default_value_for gem.
|
14
|
+
email: kami30k@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- ".travis.yml"
|
21
|
+
- Gemfile
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- bin/console
|
25
|
+
- bin/setup
|
26
|
+
- default_value_for-matchers.gemspec
|
27
|
+
- lib/default_value_for/matchers.rb
|
28
|
+
- lib/default_value_for/matchers/version.rb
|
29
|
+
homepage: https://github.com/kami30k/default_value_for-matchers
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 2.4.5
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: RSpec matchers for default_value_for gem.
|
53
|
+
test_files: []
|
54
|
+
has_rdoc:
|