rspec-check-auth 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1 +1,2 @@
1
- v0.5 - Public Release
1
+ v0.5 - Public Release
2
+ v0.5.1 - Adding :only as an argument to CheckAuth#resource_actions
data/README.md CHANGED
@@ -28,6 +28,8 @@ Here's an example block that expects HTML to be redirected to login_url and XML/
28
28
 
29
29
  ## Usage
30
30
 
31
+ require "rspec_check_auth"
32
+
31
33
  CheckAuth knows about different HTTP methods, and can figure out the usual crowd (POST create, DELETE destroy, etc.) You can override the method by passing a `:method` argument.
32
34
 
33
35
  check_auth_for do |c|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -36,19 +36,41 @@ class CheckAuth
36
36
  # Any params given (other than :except) are passed to each action as params,
37
37
  # and actions that require an id (edit, show, update) get passed "some_id"
38
38
  #
39
- # Accepts :except => [:action, :names] for actions to be skipped in testing
39
+ # Accepts:
40
+ # :only => [:action, :names]
41
+ # :except => [:action, :names]
42
+ #
43
+ # Either param can be a single action, or an array of actions. :only takes precedence over :except.
40
44
  #
41
45
  def resource_actions params={}
42
- skip = params.delete(:except).arrayize || {}
46
+ except = params.delete(:except).arrayize.compact
47
+ only = params.delete(:only).arrayize.compact
48
+
43
49
  params[:format] = params.has_key?(:format) ? params[:format].arrayize : [:html,:xml]
44
- # Add each action, unless they should be skipped
45
- add :index, params unless skip.include?(:index)
46
- add :new, params unless skip.include?(:new)
47
- add :create, params unless skip.include?(:create)
48
- add :edit, {:id => "some_id"}.merge(params) unless skip.include?(:edit)
49
- add :show, {:id => "some_id"}.merge(params) unless skip.include?(:show)
50
- add :update, {:id => "some_id"}.merge(params) unless skip.include?(:update)
51
- add :destroy, {:id => "some_id"}.merge(params) unless skip.include?(:destroy)
50
+
51
+ # Logic to see if we should add an action
52
+ # It should either be in :only, or :except isn't empty and it's not in :except
53
+ should_add = lambda do |action|
54
+ # Only isn't empty and our action is contained within
55
+ if !only.empty?
56
+ break only.include?(action)
57
+ end
58
+ # Except isn't empty and our action isn't contained therein
59
+ if !except.empty?
60
+ break !except.include?(action)
61
+ end
62
+ # Just add it
63
+ true
64
+ end
65
+
66
+ # Add each action, if we should
67
+ add :index, params if should_add[:index]
68
+ add :new, params if should_add[:new]
69
+ add :create, params if should_add[:create]
70
+ add :edit, {:id => "some_id"}.merge(params) if should_add[:edit]
71
+ add :show, {:id => "some_id"}.merge(params) if should_add[:show]
72
+ add :update, {:id => "some_id"}.merge(params) if should_add[:update]
73
+ add :destroy, {:id => "some_id"}.merge(params) if should_add[:destroy]
52
74
  end
53
75
 
54
76
  def output
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-check-auth}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Caius Durling"]
12
- s.date = %q{2009-12-03}
12
+ s.date = %q{2010-06-28}
13
13
  s.description = %q{Quickly check your rails controller actions require authentication}
14
14
  s.email = %q{hello@brightbox.co.uk}
15
15
  s.extra_rdoc_files = [
@@ -31,12 +31,13 @@ Gem::Specification.new do |s|
31
31
  "lib/rspec_check_auth/extend_object.rb",
32
32
  "rspec-check-auth.gemspec",
33
33
  "spec/rspec_check_auth_spec.rb",
34
+ "spec/spec.opts",
34
35
  "spec/spec_helper.rb"
35
36
  ]
36
37
  s.homepage = %q{http://github.com/brightbox/rspec-check-auth}
37
38
  s.rdoc_options = ["--charset=UTF-8"]
38
39
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.5}
40
+ s.rubygems_version = %q{1.3.7}
40
41
  s.summary = %q{Quickly check your rails controller actions require authentication}
41
42
  s.test_files = [
42
43
  "spec/rspec_check_auth_spec.rb",
@@ -47,7 +48,7 @@ Gem::Specification.new do |s|
47
48
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
49
  s.specification_version = 3
49
50
 
50
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
52
  s.add_development_dependency(%q<rspec>, [">= 0"])
52
53
  else
53
54
  s.add_dependency(%q<rspec>, [">= 0"])
@@ -89,6 +89,18 @@ describe "RspecCheckAuth" do
89
89
  end
90
90
  end
91
91
 
92
+ it "should only expect resources it's been told to" do
93
+ expect_request_for :index, :html
94
+ expect_request_for :index, :xml
95
+
96
+ expect_output_for(:html, [:index_html])
97
+ expect_output_for(:xml, [:index_xml])
98
+
99
+ CheckAuth.for do |c|
100
+ c.resource_actions :only => :index
101
+ end
102
+ end
103
+
92
104
  it "should add standard resource routes with extra params" do
93
105
  expect_requests_for_resource_actions :some => :fields
94
106
 
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-check-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 1
10
+ version: 0.5.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Caius Durling
@@ -9,19 +15,23 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-03 00:00:00 +00:00
18
+ date: 2010-06-28 00:00:00 +01:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
23
32
  version: "0"
24
- version:
33
+ type: :development
34
+ version_requirements: *id001
25
35
  description: Quickly check your rails controller actions require authentication
26
36
  email: hello@brightbox.co.uk
27
37
  executables: []
@@ -46,6 +56,7 @@ files:
46
56
  - lib/rspec_check_auth/extend_object.rb
47
57
  - rspec-check-auth.gemspec
48
58
  - spec/rspec_check_auth_spec.rb
59
+ - spec/spec.opts
49
60
  - spec/spec_helper.rb
50
61
  has_rdoc: true
51
62
  homepage: http://github.com/brightbox/rspec-check-auth
@@ -57,21 +68,27 @@ rdoc_options:
57
68
  require_paths:
58
69
  - lib
59
70
  required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
60
72
  requirements:
61
73
  - - ">="
62
74
  - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
63
78
  version: "0"
64
- version:
65
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
66
81
  requirements:
67
82
  - - ">="
68
83
  - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
69
87
  version: "0"
70
- version:
71
88
  requirements: []
72
89
 
73
90
  rubyforge_project:
74
- rubygems_version: 1.3.5
91
+ rubygems_version: 1.3.7
75
92
  signing_key:
76
93
  specification_version: 3
77
94
  summary: Quickly check your rails controller actions require authentication