default_value_for-matchers 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37dc1467effb2836ade6333b56b9ac0871115757
4
- data.tar.gz: 34b8545dd8b3dc996cc49faa6bd32b65eb03859c
3
+ metadata.gz: 96c01f22b3ebabd8305d2b947350974d7acfbf51
4
+ data.tar.gz: d5db41babefd12d974777d46ea8c9c9e792294ce
5
5
  SHA512:
6
- metadata.gz: 18d94f93b6f22c930e44e52f19be14fe776b5c0c76c69e3868427aa150a1c66b88ee62c633ecc235227e60cd46cf7c13bcbe8e6c801e0bbc1a4dc13dd2db29c5
7
- data.tar.gz: 542bf88769bbe45a18a47e10819382468f9f5599800ef78638f3249f1ff10dbdcbda99e91c0a674137deb709ed5c0ac38920e9a6ad9f457cf4f8a417d592044e
6
+ metadata.gz: 2f2aa9b9fa41734205774ada718f6d5dbcfe037a8f2af7bbfb2cd721c6e9ed1410780d5388d120aff5840a7d6a784189f029ce6fe01b5492f11faa3d3d42c063
7
+ data.tar.gz: 98d6c6adbf8e2ff28ff390f5d5cba618fb99cef8a89040421fe920c775c1439bb7723d04678d60c4426508c46e344c870d248a5d0930e54757715b8f1367d485
data/.gitignore CHANGED
@@ -1,9 +1,4 @@
1
1
  /.bundle/
2
- /.yardoc
3
2
  /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
3
  /pkg/
8
- /spec/reports/
9
- /tmp/
4
+ /spec/dummy/log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml CHANGED
@@ -1,4 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.5
3
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in default_value_for-matchers.gemspec
4
3
  gemspec
data/README.md CHANGED
@@ -1,36 +1,58 @@
1
- # DefaultValueFor::Matchers
1
+ # default_value_for-matchers
2
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.
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
- TODO: Delete this and the text above, and describe your gem
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
- gem 'default_value_for-matchers'
12
+ group :test do
13
+ gem 'default_value_for-matchers'
14
+ end
13
15
  ```
14
16
 
15
17
  And then execute:
16
18
 
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install default_value_for-matchers
19
+ ```
20
+ $ bundle
21
+ ```
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Include `default_value_for/matchers` in your `rails_helper.rb`:
26
+
27
+ ```ruby
28
+ require 'default_value_for/matchers'
29
+ ```
26
30
 
27
- ## Development
31
+ Then you can use `have_default_value_for` matcher and `with_value`, `and_allow_nil` and `and_disallow_nil` submatchers.
28
32
 
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.
33
+ For example:
30
34
 
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).
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/[USERNAME]/default_value_for-matchers.
36
-
58
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kami30k/default_value_for-matchers.
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task default: :spec
@@ -14,4 +14,9 @@ Gem::Specification.new do |s|
14
14
  s.license = 'MIT'
15
15
 
16
16
  s.files = `git ls-files -z`.split("\x0")
17
+
18
+ s.add_dependency 'default_value_for'
19
+ s.add_dependency 'rspec'
20
+
21
+ s.add_development_dependency 'sqlite3'
17
22
  end
@@ -1,5 +1,5 @@
1
1
  module DefaultValueFor
2
2
  module Matchers
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ require 'rspec'
2
+
1
3
  RSpec::Matchers.define :have_default_value_for do |attribute|
2
4
  match do
3
5
  @attribute = attribute.to_s
@@ -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,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ APP_PATH = File.expand_path('../../application', __FILE__)
4
+
5
+ require 'rails/commands'
@@ -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
@@ -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.0
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
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here