ripped_params 0.0.1 → 0.0.2

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: 209b31e316f447e3b662a74a157eb6be3bc099c6
4
- data.tar.gz: c20c59300c3a4a7ce036250aa087b4bb491e69c8
3
+ metadata.gz: ad8da616f64162a6c287415486cbe6bf6dad0294
4
+ data.tar.gz: 170885080e97f4193590b5b0b1d9b438ca21cad8
5
5
  SHA512:
6
- metadata.gz: 35901930d96c137303027473457dfe69675f1b6961bbca31f5b885d594f03b378ea8d873476a749b654ed1b2849b6014a5edc6d44c55fad984d30a4182dcee14
7
- data.tar.gz: 830666164e681294e1d377ccdf56b19dfb4fe7ca548b549eab3b30554744f405ab20b3bbba0d7215984c7338571fa2b9916700edeeb7c20f322f64976cd02ab7
6
+ metadata.gz: d13238e6a5900c62c9c067afcb5b0a53bdf54958ee52431f535edaf79b2c15bbc0bf45224f0dfc972ac7e5b32b29f4787a1b4611e05f79e58d819dc06c934f2d
7
+ data.tar.gz: bc9ad070a337945a4a5e76d8a3b442eb0e9ff29fb0e200d36c9212ba321da89db6e7e3177d0f95416cd5035beb5c09efa13f06c9530c566b93b93219ecaf289e
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/README.md CHANGED
@@ -18,9 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Once installed use the command `ripped_params:install` to add the ripped_params folder into your lib folder along with an example YAML file
21
+ Once installed, run this command to add the ripped_params folder into your lib directory along with an example YAML file
22
22
 
23
- ## YAML file explained
23
+ ```
24
+ rails generate ripped_params:install
25
+ ```
26
+
27
+ ## Example YAML file explained
24
28
 
25
29
  ```
26
30
  ---
@@ -53,7 +57,7 @@ In each controller you want to add a Ripped Param include the following:
53
57
 
54
58
  `uses_ripped_params :project_params`
55
59
 
56
- This will look for a file somewhere in the ripped_params directory called "project_params.yml"
60
+ This will look for a file somewhere in the ripped_params directory called "project_params.yml" and give you a method called project_params in that controller.
57
61
 
58
62
  You can add as many Ripped Params as you need in each controller.
59
63
 
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ task :console do
4
+ exec "irb -r ripped_params -I ./lib"
5
+ end
6
+
@@ -1,4 +1,5 @@
1
1
  require 'find'
2
+ require 'yaml'
2
3
 
3
4
  class NoYAMLFileFoundError < Exception; end
4
5
 
@@ -1,3 +1,3 @@
1
1
  module RippedParams
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -21,4 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "byebug"
24
+
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'actionpack'
27
+ spec.add_development_dependency 'activesupport'
24
28
  end
Binary file
@@ -0,0 +1,31 @@
1
+ ---
2
+ :require: :not_project
3
+ :permit:
4
+ - :name
5
+ - :service_id
6
+ - :quote
7
+ - :document_attributes:
8
+ - :filepicker_url
9
+ - :category_id
10
+ - :start_at_text
11
+ - :estimated_duration
12
+ - :status
13
+ - :roles_attributes:
14
+ - :id
15
+ - :name
16
+ - :actor_short
17
+ - :tasks_attributes:
18
+ - :id
19
+ - :name
20
+ - :description
21
+ - :public
22
+ - :assigned_to_role
23
+ - :reviewer_role
24
+ - :due_at_offset
25
+ - :start_at_offset
26
+ - :tag_list: []
27
+ - :dynamic_fields_attributes:
28
+ - :id
29
+ - :kind
30
+ - :attribute
31
+ - :receiver
@@ -0,0 +1,31 @@
1
+ ---
2
+ :require: :project
3
+ :permit:
4
+ - :name
5
+ - :service_id
6
+ - :quote
7
+ - :document_attributes:
8
+ - :filepicker_url
9
+ - :category_id
10
+ - :start_at_text
11
+ - :estimated_duration
12
+ - :status
13
+ - :roles_attributes:
14
+ - :id
15
+ - :name
16
+ - :actor_short
17
+ - :tasks_attributes:
18
+ - :id
19
+ - :name
20
+ - :description
21
+ - :public
22
+ - :assigned_to_role
23
+ - :reviewer_role
24
+ - :due_at_offset
25
+ - :start_at_offset
26
+ - :tag_list: []
27
+ - :dynamic_fields_attributes:
28
+ - :id
29
+ - :kind
30
+ - :attribute
31
+ - :receiver
@@ -0,0 +1,52 @@
1
+ require "spec_helper"
2
+ require "ripped_params/params_builder"
3
+ require 'action_controller'
4
+ require "byebug"
5
+
6
+ module RippedParams
7
+ describe ParamsBuilder do
8
+ describe "#build" do
9
+ let(:simple_params) do
10
+ ActionController::Parameters.new({
11
+ project: {
12
+ service_id: 12,
13
+ name: "Some Project"
14
+ }
15
+ })
16
+ end
17
+
18
+ it "returns required param" do
19
+ params_builder = RippedParams::ParamsBuilder.new(simple_params, "project_params")
20
+ params_builder.stub(:yaml_files_directory).and_return("spec/fixtures/ripped_params")
21
+ correct_params = {"name"=>"Some Project", "service_id"=>12}
22
+ expect(correct_params).to eq(params_builder.build)
23
+ end
24
+
25
+ it "rejects params that are not included in the yaml file" do
26
+ bad_params = ActionController::Parameters.new({
27
+ project: {
28
+ service_id: 12,
29
+ name: "Some Project",
30
+ wrong_key: "Should not show up"
31
+ }
32
+ })
33
+ params_builder = RippedParams::ParamsBuilder.new(bad_params, "project_params")
34
+ params_builder.stub(:yaml_files_directory).and_return("spec/fixtures/ripped_params")
35
+ correct_params = {"name"=>"Some Project", "service_id"=>12}
36
+ expect(correct_params).to eq(params_builder.build)
37
+ end
38
+
39
+ it "raises error when yaml file name is passes in that is not included in ripped_params directory" do
40
+ params_builder = RippedParams::ParamsBuilder.new(simple_params, "not_project_params")
41
+ params_builder.stub(:yaml_files_directory).and_return("spec/fixtures/ripped_params")
42
+ expect{params_builder.build}.to raise_error(NoYAMLFileFoundError)
43
+ end
44
+
45
+ it "raises error when required param is not found in the incomming params" do
46
+ params_builder = RippedParams::ParamsBuilder.new(simple_params, "no_required_params")
47
+ params_builder.stub(:yaml_files_directory).and_return("spec/fixtures/ripped_params")
48
+ expect{params_builder.build}.to raise_error(ActionController::ParameterMissing)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,91 @@
1
+ require 'ripped_params'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
6
+ # file to always be loaded, without a need to explicitly require it in any files.
7
+ #
8
+ # Given that it is always loaded, you are encouraged to keep this file as
9
+ # light-weight as possible. Requiring heavyweight dependencies from this file
10
+ # will add to the boot time of your test suite on EVERY test run, even for an
11
+ # individual file that may not need all of that loaded. Instead, consider making
12
+ # a separate helper file that requires the additional dependencies and performs
13
+ # the additional setup, and require it from the spec files that actually need it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
54
+ # For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ config.disable_monkey_patching!
59
+
60
+ # This setting enables warnings. It's recommended, but in some cases may
61
+ # be too noisy due to issues in dependencies.
62
+ config.warnings = true
63
+
64
+ # Many RSpec users commonly either run the entire suite or an individual
65
+ # file, and it's useful to allow more verbose output when running an
66
+ # individual spec file.
67
+ if config.files_to_run.one?
68
+ # Use the documentation formatter for detailed output,
69
+ # unless a formatter has already been configured
70
+ # (e.g. via a command-line flag).
71
+ config.default_formatter = 'doc'
72
+ end
73
+
74
+ # Print the 10 slowest examples and example groups at the
75
+ # end of the spec run, to help surface which specs are running
76
+ # particularly slow.
77
+ config.profile_examples = 10
78
+
79
+ # Run specs in random order to surface order dependencies. If you find an
80
+ # order dependency and want to debug it, you can fix the order by providing
81
+ # the seed, which is printed after each run.
82
+ # --seed 1234
83
+ config.order = :random
84
+
85
+ # Seed global randomization in this process using the `--seed` CLI option.
86
+ # Setting this allows you to use `--seed` to deterministically reproduce
87
+ # test failures related to randomization by passing the same `--seed` value
88
+ # as the one that triggered the failure.
89
+ Kernel.srand config.seed
90
+ =end
91
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripped_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nemrow
@@ -52,6 +52,48 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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'
69
+ - !ruby/object:Gem::Dependency
70
+ name: actionpack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
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
  description: Specify all strong params into separate yaml files and have then turned
56
98
  into controller methods
57
99
  email:
@@ -61,6 +103,7 @@ extensions: []
61
103
  extra_rdoc_files: []
62
104
  files:
63
105
  - .gitignore
106
+ - .rspec
64
107
  - Gemfile
65
108
  - LICENSE.txt
66
109
  - README.md
@@ -73,6 +116,11 @@ files:
73
116
  - lib/ripped_params/railtie.rb
74
117
  - lib/ripped_params/version.rb
75
118
  - ripped_params.gemspec
119
+ - spec/fixtures/.DS_Store
120
+ - spec/fixtures/ripped_params/no_required_params.yml
121
+ - spec/fixtures/ripped_params/project_params.yml
122
+ - spec/ripped_params/params_builder_spec.rb
123
+ - spec/spec_helper.rb
76
124
  homepage: ''
77
125
  licenses:
78
126
  - MIT
@@ -97,4 +145,9 @@ rubygems_version: 2.2.2
97
145
  signing_key:
98
146
  specification_version: 4
99
147
  summary: Organize strong params into yaml files
100
- test_files: []
148
+ test_files:
149
+ - spec/fixtures/.DS_Store
150
+ - spec/fixtures/ripped_params/no_required_params.yml
151
+ - spec/fixtures/ripped_params/project_params.yml
152
+ - spec/ripped_params/params_builder_spec.rb
153
+ - spec/spec_helper.rb