rspec_rails_scaffold_templates 1.1.1 → 1.2.0

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: 96d01b2f3d856c0957aea2cb02602ad741ecb937
4
- data.tar.gz: bd2318a67220c8b2837460505fe9aba6f8eda358
3
+ metadata.gz: 7ab917e3778d83572e0494b9c38c73c39a3ccae3
4
+ data.tar.gz: ff92ff555c659a2002f45431946734b9536f1704
5
5
  SHA512:
6
- metadata.gz: 28c1e716f4e91b63b2aa410058b7ae45ff3fa5d1d248bf1bd759900e4cb2e82c42af2f6bce97fc3a3505cd9b56af19aa230decda9f509d4b97a53ca15aeceeed
7
- data.tar.gz: e057f5199f34a5603d8f690144a8740639340d43386cf0770908d1e49d3aa2a86a0cba27f7f4333998ed261d57d51cdd2f8843c345041e5b6dd7a5d2fe8d488e
6
+ metadata.gz: 6de2ecd958d26af84a1bb9c521c5034a6429b8d73cf93788039cb6504dd06ab789f2884978dba14705c9a42c1f933f5003c800d6700ef25f1c0000c9a3457801
7
+ data.tar.gz: dc09e7fc53508e40148dbf6d25afb3d501dff9080634c28435c619cb2dfe527c8b3950ecb8ef240cf1f6fbd4bdffa3c0c3fc8db981b416386ccdd916e35c993c
data/README.rdoc CHANGED
@@ -21,6 +21,52 @@ Next time you run
21
21
 
22
22
  you will get the needed specs for controller and views.
23
23
 
24
+ === Configuring
25
+
26
+ You have to add to the <tt>application.rb</tt> file the config for generators as follows
27
+ config.generators do |g|
28
+ g.cancan true
29
+ end
30
+ in order to have it the generated specs the code that works around the code
31
+ that checks ability.
32
+
33
+ For the specs on view it will be
34
+ before(:each) do
35
+ allow(controller).to receive(:can?).and_return(true)
36
+ end
37
+ while in the controller and request spec it will be
38
+ before :each do
39
+ allow(controller).to receive(:current_user).and_return(current_user)
40
+ end
41
+ So, you need to add a method <tt>current_user</tt> to your rspec support, say, like this
42
+ def current_user(stubs = {})
43
+ @mock_current_user ||= mock_model(User, name: 'Mock Current User').tap do |user|
44
+ stubs.reverse_merge! is?: true, landing: nil
45
+ stubs.each do |k, v|
46
+ allow(user).to receive(k) {v}
47
+ end
48
+ end
49
+ end
50
+
51
+ You may want to stub <tt>current_ability</tt> instead of <tt>current_user</tt> in
52
+ controller. For doing this replace <tt>true</tt> with <tt>:current_ability</tt>
53
+ in <tt>g.cancan</tt> config like this
54
+ config.generators do |g|
55
+ g.cancan :current_ability
56
+ end
57
+ Of course, you will need method <tt>current_ability</tt> in you spec support in this case, say, like this
58
+ class GodAbility
59
+ include CanCan::Ability
60
+
61
+ def initialize
62
+ can :manage, :all
63
+ end
64
+ end
65
+
66
+ def current_ability
67
+ GodAbility.new
68
+ end
69
+
24
70
  == Contributing to rspec_rails_scaffold_templates
25
71
 
26
72
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.2.0
@@ -5,9 +5,10 @@ require 'spec_helper'
5
5
  <% end -%>
6
6
 
7
7
  describe "<%= class_name.pluralize %>", type: :request do
8
- <% if Rails.application.config.generators.options[:rails][:cancan] -%>
8
+ <% if method = Rails.application.config.generators.options[:rails][:cancan] -%>
9
+ <% method = 'current_user' unless Symbol === method -%>
9
10
  before :each do
10
- allow_any_instance_of(<%= class_name.pluralize %>Controller).to receive(:current_user).and_return(current_user)
11
+ allow_any_instance_of(<%= class_name.pluralize %>Controller).to receive(:<%=method%>).and_return(<%=method%>)
11
12
  end
12
13
 
13
14
  <% end -%>
@@ -7,9 +7,10 @@ require 'spec_helper'
7
7
  <% module_namespacing do -%>
8
8
  describe <%= controller_class_name %>Controller, type: :controller do
9
9
 
10
- <% if Rails.application.config.generators.options[:rails][:cancan] -%>
10
+ <% if method = Rails.application.config.generators.options[:rails][:cancan] -%>
11
+ <% method = 'current_user' unless Symbol === method -%>
11
12
  before :each do
12
- allow(controller).to receive(:current_user).and_return(current_user)
13
+ allow(controller).to receive(:<%=method%>).and_return(<%=method%>)
13
14
  end
14
15
 
15
16
  <% end -%>
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rspec_rails_scaffold_templates 1.1.1 ruby lib
5
+ # stub: rspec_rails_scaffold_templates 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "rspec_rails_scaffold_templates"
9
- s.version = "1.1.1"
9
+ s.version = "1.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Dmitri Koulikoff"]
14
- s.date = "2015-06-14"
14
+ s.date = "2016-03-02"
15
15
  s.description = "RSpec scaffold generator templates that use FactoryGirl and WiceGrid"
16
16
  s.email = "dima@koulikoff.ru"
17
17
  s.extra_rdoc_files = [
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
39
39
  ]
40
40
  s.homepage = "http://github.com/dima4p/rspec_rails_scaffold_templates"
41
41
  s.licenses = ["MIT"]
42
- s.rubygems_version = "2.2.2"
42
+ s.rubygems_version = "2.5.1"
43
43
  s.summary = "RSpec scaffold generator templates that use FactoryGirl and WiceGrid"
44
44
 
45
45
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_rails_scaffold_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitri Koulikoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.5.1
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: RSpec scaffold generator templates that use FactoryGirl and WiceGrid