weak_parameters 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f727084d2f5b6f19f5e23073a6bdb53da5612e8
4
- data.tar.gz: 5d41ed3547ea2ee49ab1b3651feecf7b93ecd590
3
+ metadata.gz: 50b0c13f9e3c5697ffe2103ce08be27f4f647d04
4
+ data.tar.gz: 2d29e0b13db351bfb7149b8a503995ec76ff1ec0
5
5
  SHA512:
6
- metadata.gz: 13b1e3c781bb9ce765edd8c7236ce116f31eaf3044644ab991b4d253a3d4068ad8b89c29d4620db1d55245f94b57edf89e901878b5c54f839b016b1457a77f8b
7
- data.tar.gz: 6d86b954fb1053e3e467892bb1daae3b0774de30c5608f13b1893033b66dde035beea8d021afd0fee7385ce207ec14a4acf5b404bccb854c5414baa75f2b1f9e
6
+ metadata.gz: 5b2cb7add33324eb6368ed684116d7b9e08d045e59efcd1e70ad9fe9bed2856f06c84401902ff81ba254b4d3d15478cd77ad1b1ed63b1c02ab1a78df731e5225
7
+ data.tar.gz: 5456a73dbb05f9a45d676d251ce1082034946e0a3c56ed3394b6c59597ee64687f032fd743673ebaa09b7e25840bd43a412d1abdf66a7de6387e09ec678cef49
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ before_install:
2
+ - gem update bundler
3
+ language: ruby
4
+ rvm:
5
+ - 2.2.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.3
2
+ - Change execution context of validator block
3
+ - Fix a development dependencies problem
4
+
1
5
  ## 0.2.2
2
6
  - Fix nil validation bug on nested parameters (Thx @mzp)
3
7
 
data/Gemfile CHANGED
@@ -3,9 +3,3 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem "rails", "4.0.0"
6
-
7
- group :test do
8
- gem "autodoc"
9
- gem "pry-rails"
10
- gem "rspec-rails"
11
- end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # WeakParameters
1
+ # WeakParameters [![Build Status](https://travis-ci.org/r7kamura/weak_parameters.svg?branch=master)](https://travis-ci.org/r7kamura/weak_parameters)
2
2
  Validates `params` in your controller.
3
3
 
4
4
  ## Installation
@@ -59,7 +59,7 @@ irb(main):005:0> app.post "/recipes", name: "alice", type: "bob"
59
59
  * object
60
60
  * list
61
61
 
62
- ### Avilable options
62
+ ### Available options
63
63
  * required
64
64
  * only
65
65
  * except
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -46,7 +46,7 @@ module WeakParameters
46
46
  false
47
47
  when exist? && exceptional?
48
48
  false
49
- when exist? && block && !block.call(value)
49
+ when exist? && block && !controller.instance_exec(value, &block)
50
50
  false
51
51
  else
52
52
  true
@@ -1,3 +1,3 @@
1
1
  module WeakParameters
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -11,7 +11,7 @@ class RecipesController < ApplicationController
11
11
  file :attachment
12
12
  integer :custom, only: 0..1, handler: :render_error
13
13
  string :zip_code do |value|
14
- value =~ /\A\d{3}-\d{4}\z/
14
+ zip_pattern(value)
15
15
  end
16
16
  object :nested, required: true do
17
17
  integer :number, only: [0, 1]
@@ -36,4 +36,8 @@ class RecipesController < ApplicationController
36
36
  def render_error
37
37
  head 403
38
38
  end
39
+
40
+ def zip_pattern(value)
41
+ value =~ /\A\d{3}-\d{4}\z/
42
+ end
39
43
  end
@@ -29,14 +29,14 @@ describe "Recipes", type: :request do
29
29
  shared_examples_for "400" do
30
30
  it "returns 400" do
31
31
  post "/recipes", params
32
- response.status.should == 400
32
+ expect(response.status).to eq(400)
33
33
  end
34
34
  end
35
35
 
36
36
  shared_examples_for "201" do
37
37
  it "creates a new recipe" do
38
38
  post "/recipes", params
39
- response.status.should == 201
39
+ expect(response.status).to eq(201)
40
40
  end
41
41
  end
42
42
 
@@ -142,7 +142,7 @@ describe "Recipes", type: :request do
142
142
  end
143
143
  it "delegates to specified method" do
144
144
  post "/recipes", params
145
- response.status.should == 403
145
+ expect(response.status).to eq(403)
146
146
  end
147
147
  end
148
148
 
@@ -49,52 +49,52 @@ describe "Strong", type: :request do
49
49
  describe "#permitted_params" do
50
50
  it "returns permitted_params" do
51
51
  post "/strongs", params
52
- controller.permitted_params.should have_key "strong_object"
53
- controller.permitted_params.should_not have_key "object"
52
+ expect(controller.permitted_params).to have_key "strong_object"
53
+ expect(controller.permitted_params).not_to have_key "object"
54
54
 
55
- controller.permitted_params.should have_key "strong_name"
56
- controller.permitted_params.should_not have_key "name"
55
+ expect(controller.permitted_params).to have_key "strong_name"
56
+ expect(controller.permitted_params).not_to have_key "name"
57
57
 
58
- controller.permitted_params.should have_key "strong_number"
59
- controller.permitted_params.should_not have_key "number"
58
+ expect(controller.permitted_params).to have_key "strong_number"
59
+ expect(controller.permitted_params).not_to have_key "number"
60
60
 
61
- controller.permitted_params.should have_key "strong_type"
62
- controller.permitted_params.should_not have_key "type"
61
+ expect(controller.permitted_params).to have_key "strong_type"
62
+ expect(controller.permitted_params).not_to have_key "type"
63
63
 
64
- controller.permitted_params.should have_key "strong_flag"
65
- controller.permitted_params.should_not have_key "flag"
64
+ expect(controller.permitted_params).to have_key "strong_flag"
65
+ expect(controller.permitted_params).not_to have_key "flag"
66
66
 
67
- controller.permitted_params.should have_key "strong_config"
68
- controller.permitted_params.should_not have_key "config"
67
+ expect(controller.permitted_params).to have_key "strong_config"
68
+ expect(controller.permitted_params).not_to have_key "config"
69
69
 
70
- controller.permitted_params.should have_key "strong_tags"
71
- controller.permitted_params.should_not have_key "tags"
70
+ expect(controller.permitted_params).to have_key "strong_tags"
71
+ expect(controller.permitted_params).not_to have_key "tags"
72
72
 
73
- controller.permitted_params.should_not have_key "strong_rate"
74
- controller.permitted_params.should_not have_key "rate"
73
+ expect(controller.permitted_params).not_to have_key "strong_rate"
74
+ expect(controller.permitted_params).not_to have_key "rate"
75
75
 
76
- controller.permitted_params.should have_key "strong_attachment"
77
- controller.permitted_params.should_not have_key "attachment"
76
+ expect(controller.permitted_params).to have_key "strong_attachment"
77
+ expect(controller.permitted_params).not_to have_key "attachment"
78
78
 
79
- controller.permitted_params.should have_key "strong_zip_code"
80
- controller.permitted_params.should_not have_key "zip_code"
79
+ expect(controller.permitted_params).to have_key "strong_zip_code"
80
+ expect(controller.permitted_params).not_to have_key "zip_code"
81
81
 
82
- controller.permitted_params.should have_key "strong_custom"
83
- controller.permitted_params.should_not have_key "custom"
82
+ expect(controller.permitted_params).to have_key "strong_custom"
83
+ expect(controller.permitted_params).not_to have_key "custom"
84
84
 
85
- controller.permitted_params.should have_key "strong_nested"
86
- controller.permitted_params.should_not have_key "nested"
85
+ expect(controller.permitted_params).to have_key "strong_nested"
86
+ expect(controller.permitted_params).not_to have_key "nested"
87
87
 
88
- controller.permitted_params.should have_key "strong_numbers"
89
- controller.permitted_params.should_not have_key "numbers"
88
+ expect(controller.permitted_params).to have_key "strong_numbers"
89
+ expect(controller.permitted_params).not_to have_key "numbers"
90
90
 
91
- controller.permitted_params.should have_key "strong_body"
92
- controller.permitted_params.should_not have_key "body"
91
+ expect(controller.permitted_params).to have_key "strong_body"
92
+ expect(controller.permitted_params).not_to have_key "body"
93
93
 
94
- controller.permitted_params[:strong_body].should have_key "items"
94
+ expect(controller.permitted_params[:strong_body]).to have_key "items"
95
95
 
96
- controller.permitted_params[:strong_body][:items].first.should have_key "strong_price"
97
- controller.permitted_params[:strong_body][:items].first.should_not have_key "name"
96
+ expect(controller.permitted_params[:strong_body][:items].first).to have_key "strong_price"
97
+ expect(controller.permitted_params[:strong_body][:items].first).not_to have_key "name"
98
98
  end
99
99
  end
100
100
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  ENV["RAILS_ENV"] ||= "test"
2
2
  require File.expand_path("../../spec/dummy/config/environment", __FILE__)
3
3
  require "rspec/rails"
4
- require "rspec/autorun"
5
4
 
6
5
  RSpec.configure do |config|
7
6
  # If you"re not using ActiveRecord, or you"d prefer not to run each of your
@@ -14,5 +13,14 @@ RSpec.configure do |config|
14
13
  # rspec-rails.
15
14
  config.infer_base_class_for_anonymous_controllers = false
16
15
 
17
- config.treat_symbols_as_metadata_keys_with_true_values = true
16
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
17
+ # from the file location. You can explicitly opt-in to the feature using this
18
+ # config option.
19
+ # To explicitly tag specs without using automatic inference, set the `:type`
20
+ # metadata manually:
21
+ #
22
+ # describe ThingsController, :type => :controller do
23
+ # # Equivalent to being in spec/controllers
24
+ # end
25
+ config.infer_spec_type_from_file_location!
18
26
  end
@@ -18,7 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "rails", ">= 3.2.11"
21
+ spec.add_development_dependency "autodoc"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "pry-rails"
22
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec-rails"
23
26
  spec.add_development_dependency "sqlite3"
27
+ spec.add_development_dependency "test-unit"
24
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weak_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.11
27
+ - !ruby/object:Gem::Dependency
28
+ name: autodoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rake
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +80,20 @@ dependencies:
52
80
  - - ">="
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: sqlite3
57
99
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +108,20 @@ dependencies:
66
108
  - - ">="
67
109
  - !ruby/object:Gem::Version
68
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: test-unit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
69
125
  description:
70
126
  email:
71
127
  - r7kamura@gmail.com
@@ -74,6 +130,7 @@ extensions: []
74
130
  extra_rdoc_files: []
75
131
  files:
76
132
  - ".gitignore"
133
+ - ".travis.yml"
77
134
  - CHANGELOG.md
78
135
  - Gemfile
79
136
  - LICENSE.txt