refinerycms-testing 2.0.10 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/refinery/testing/templates/Guardfile +3 -3
- data/lib/generators/refinery/testing/templates/spec/spec_helper.rb +17 -43
- data/lib/generators/refinery/testing/testing_generator.rb +0 -4
- data/lib/refinery/testing.rb +1 -1
- data/lib/refinery/testing/controller_macros/authentication.rb +59 -20
- data/lib/refinery/testing/feature_macros.rb +7 -0
- data/lib/refinery/testing/feature_macros/authentication.rb +30 -0
- data/refinerycms-testing.gemspec +7 -7
- metadata +30 -16
- data/lib/refinery/testing/request_macros.rb +0 -7
- data/lib/refinery/testing/request_macros/authentication.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e365214719c30cca8e9a7f2cfd6e5a75deed6b2b
|
4
|
+
data.tar.gz: c89fdc7c78d4473d17afa1f2b6cc2c8379e4b360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df0dbac4556ed0bba5de1bfba7b8038870a77c8a504f3bb19d3a5d4945478409f211eb30d1b6b3358ae0a25ca82fa24996781f8ef48a3fbd52741c2f78426248
|
7
|
+
data.tar.gz: b6f2d359153568d461dec0dd230af6acc80d13324d4058eb91f85e724cd944ef1732d5070c5c711ca86a09522b39d29489604c347eb0ddced6cc4293f5c0de94
|
@@ -1,4 +1,4 @@
|
|
1
|
-
extensions = Dir[
|
1
|
+
extensions = Dir[ 'vendor/extensions/*' ]
|
2
2
|
|
3
3
|
guard 'spork', :wait => 60, :cucumber => false, :rspec_env => { 'RAILS_ENV' => 'test' } do
|
4
4
|
watch('config/application.rb')
|
@@ -24,7 +24,7 @@ guard 'rspec', :version => 2, :spec_paths => extensions.map{|e| "#{e}/spec"},
|
|
24
24
|
watch("#{extension}/spec/spec_helper.rb") { "#{extension}/spec" }
|
25
25
|
watch("#{extension}/config/routes.rb") { "#{extension}/spec/routing" }
|
26
26
|
watch("#{extension}/app/controllers/application_controller.rb") { "#{extension}/spec/controllers" }
|
27
|
-
# Capybara
|
28
|
-
watch(%r{^#{extension}/app/views/(.+)/.*\.(erb|haml)$}) { |m| "#{extension}/spec/
|
27
|
+
# Capybara feature specs
|
28
|
+
watch(%r{^#{extension}/app/views/(.+)/.*\.(erb|haml)$}) { |m| "#{extension}/spec/features/#{m[1]}_spec.rb" }
|
29
29
|
end
|
30
30
|
end
|
@@ -1,52 +1,26 @@
|
|
1
1
|
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') unless defined?(ENGINE_RAILS_ROOT)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
# Configure Rails Environment
|
4
|
+
ENV["RAILS_ENV"] ||= 'test'
|
6
5
|
|
7
|
-
|
6
|
+
require File.expand_path("../../config/environment", __FILE__)
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
require 'rspec/rails'
|
9
|
+
require 'capybara/rspec'
|
11
10
|
|
12
|
-
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :rspec
|
15
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
|
+
config.filter_run :focus => true
|
17
|
+
config.run_all_when_everything_filtered = true
|
20
18
|
end
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# in ./support/ and its subdirectories including factories.
|
29
|
-
([ENGINE_RAILS_ROOT, Rails.root.to_s].uniq | ::Refinery::Plugins.registered.pathnames).map{|p|
|
30
|
-
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
|
31
|
-
}.flatten.sort.each do |support_file|
|
32
|
-
require support_file
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# If spork is available in the Gemfile it'll be used but we don't force it.
|
37
|
-
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
|
38
|
-
Spork.prefork do
|
39
|
-
# Loading more in this block will cause your tests to run faster. However,
|
40
|
-
# if you change any configuration or code from libraries loaded here, you'll
|
41
|
-
# need to restart spork for it take effect.
|
42
|
-
setup_environment
|
43
|
-
end
|
44
|
-
|
45
|
-
Spork.each_run do
|
46
|
-
# This code will be run each time you run your specs.
|
47
|
-
each_run
|
48
|
-
end
|
49
|
-
else
|
50
|
-
setup_environment
|
51
|
-
each_run
|
20
|
+
# Requires supporting files with custom matchers and macros, etc,
|
21
|
+
# in ./support/ and its subdirectories including factories.
|
22
|
+
([ENGINE_RAILS_ROOT, Rails.root.to_s].uniq | ::Refinery::Plugins.registered.pathnames).map{|p|
|
23
|
+
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
|
24
|
+
}.flatten.sort.each do |support_file|
|
25
|
+
require support_file
|
52
26
|
end
|
data/lib/refinery/testing.rb
CHANGED
@@ -3,39 +3,78 @@ module Refinery
|
|
3
3
|
module ControllerMacros
|
4
4
|
module Authentication
|
5
5
|
def self.extended(base)
|
6
|
-
base.send
|
6
|
+
base.send :include, Devise::TestHelpers
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def refinery_login_with(*roles)
|
10
|
+
mock_user roles
|
11
|
+
end
|
12
|
+
|
13
|
+
def refinery_login_with_factory(factory)
|
14
|
+
factory_user factory
|
15
|
+
end
|
16
|
+
|
17
|
+
def mock_user(roles)
|
18
|
+
let(:controller_permission) { true }
|
19
|
+
roles = handle_deprecated_roles! roles
|
20
|
+
let(:logged_in_user) do
|
21
|
+
user = double 'Refinery::User', :username => 'Joe Fake'
|
22
|
+
|
23
|
+
roles.each do |role|
|
24
|
+
user.stub(:has_role?).with(role).and_return true
|
25
|
+
end
|
26
|
+
user.stub(:has_role?).with(:superuser).and_return false if roles.exclude? :superuser
|
27
|
+
|
28
|
+
user
|
29
|
+
end
|
30
|
+
|
31
|
+
before do
|
32
|
+
controller.should_receive(:require_refinery_users!).and_return false
|
33
|
+
controller.should_receive(:authenticate_refinery_user!).and_return true
|
34
|
+
controller.should_receive(:restrict_plugins).and_return true
|
35
|
+
controller.should_receive(:allow_controller?).and_return controller_permission
|
36
|
+
controller.stub(:refinery_user?).and_return true
|
37
|
+
controller.stub(:current_refinery_user).and_return logged_in_user
|
14
38
|
end
|
15
39
|
end
|
16
40
|
|
17
|
-
def
|
18
|
-
let(:
|
19
|
-
before
|
41
|
+
def factory_user(factory)
|
42
|
+
let(:logged_in_user) { FactoryGirl.create factory }
|
43
|
+
before do
|
20
44
|
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
21
|
-
sign_in
|
45
|
+
sign_in logged_in_user
|
22
46
|
end
|
23
47
|
end
|
24
48
|
|
49
|
+
def login_user
|
50
|
+
Refinery.deprecate :login_user, :when => '2.2', :replacement => 'refinery_login_with :user'
|
51
|
+
refinery_login_with :user
|
52
|
+
end
|
53
|
+
|
54
|
+
def login_refinery_user
|
55
|
+
Refinery.deprecate :login_refinery_user, :when => '2.2', :replacement => 'refinery_login_with :refinery_user'
|
56
|
+
refinery_login_with :refinery_user
|
57
|
+
end
|
58
|
+
|
25
59
|
def login_refinery_superuser
|
26
|
-
|
27
|
-
|
28
|
-
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
29
|
-
sign_in refinery_superuser
|
30
|
-
end
|
60
|
+
Refinery.deprecate :login_refinery_superuser, :when => '2.2', :replacement => 'refinery_login_with :refinery_superuser'
|
61
|
+
refinery_login_with :refinery_superuser
|
31
62
|
end
|
32
63
|
|
33
64
|
def login_refinery_translator
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
65
|
+
Refinery.deprecate :login_refinery_translator, :when => '2.2', :replacement => 'refinery_login_with :refinery_translator'
|
66
|
+
refinery_login_with :refinery_translator
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
def handle_deprecated_roles!(*roles)
|
71
|
+
mappings = {
|
72
|
+
:user => [],
|
73
|
+
:refinery_user => [:refinery],
|
74
|
+
:refinery_superuser => [:refinery, :superuser],
|
75
|
+
:refinery_translator => [:refinery, :translator]
|
76
|
+
}
|
77
|
+
mappings[roles.first] || roles
|
39
78
|
end
|
40
79
|
end
|
41
80
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Testing
|
3
|
+
module FeatureMacros
|
4
|
+
module Authentication
|
5
|
+
def refinery_login_with(factory)
|
6
|
+
let!(:logged_in_user) { FactoryGirl.create(factory) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
login_as logged_in_user, :scope => :refinery_user
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def login_refinery_user
|
14
|
+
Refinery.deprecate(:login_refinery_user, :when => '2.2', :replacement => 'refinery_login_with :refinery_user')
|
15
|
+
refinery_login_with(:refinery_user)
|
16
|
+
end
|
17
|
+
|
18
|
+
def login_refinery_superuser
|
19
|
+
Refinery.deprecate(:login_refinery_superuser, :when => '2.2', :replacement => 'refinery_login_with :refinery_superuser')
|
20
|
+
refinery_login_with(:refinery_superuser)
|
21
|
+
end
|
22
|
+
|
23
|
+
def login_refinery_translator
|
24
|
+
Refinery.deprecate(:login_refinery_translator, :when => '2.2', :replacement => 'refinery_login_with :refinery_translator')
|
25
|
+
refinery_login_with(:refinery_translator)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/refinerycms-testing.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Encoding: UTF-8
|
2
|
-
|
3
|
-
require 'refinery/version'
|
2
|
+
require File.expand_path('../../core/lib/refinery/version', __FILE__)
|
4
3
|
|
5
4
|
version = Refinery::Version.to_s
|
6
5
|
|
@@ -9,7 +8,7 @@ Gem::Specification.new do |s|
|
|
9
8
|
s.name = %q{refinerycms-testing}
|
10
9
|
s.version = version
|
11
10
|
s.summary = %q{Testing plugin for Refinery CMS}
|
12
|
-
s.description = %q{This plugin adds the ability to
|
11
|
+
s.description = %q{This plugin adds the ability to tests against the Refinery CMS gem while inside a Refinery CMS extension}
|
13
12
|
s.email = %q{info@refinerycms.com}
|
14
13
|
s.homepage = %q{http://refinerycms.com}
|
15
14
|
s.rubyforge_project = %q{refinerycms}
|
@@ -20,8 +19,9 @@ Gem::Specification.new do |s|
|
|
20
19
|
s.files = `git ls-files`.split("\n")
|
21
20
|
|
22
21
|
s.add_dependency 'refinerycms-core', version
|
23
|
-
s.add_dependency 'database_cleaner', '~> 0.
|
24
|
-
s.add_dependency 'factory_girl_rails', '~>
|
25
|
-
s.add_dependency 'rspec-rails', '~> 2.
|
26
|
-
s.add_dependency 'capybara', '~>
|
22
|
+
s.add_dependency 'database_cleaner', '~> 1.0.1'
|
23
|
+
s.add_dependency 'factory_girl_rails', '~> 4.2.1'
|
24
|
+
s.add_dependency 'rspec-rails', '~> 2.13'
|
25
|
+
s.add_dependency 'capybara', '~> 2.1.0'
|
26
|
+
s.add_dependency 'selenium-webdriver', '~> 2.33.0'
|
27
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Arndt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: refinerycms-core
|
@@ -18,72 +18,86 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0
|
21
|
+
version: 2.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 2.0
|
28
|
+
version: 2.1.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: database_cleaner
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 1.0.1
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 1.0.1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: factory_girl_rails
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 4.2.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ~>
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: 4.2.1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rspec-rails
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - ~>
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '2.
|
63
|
+
version: '2.13'
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '2.
|
70
|
+
version: '2.13'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: capybara
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 2.1.0
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - ~>
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
85
|
-
|
86
|
-
|
84
|
+
version: 2.1.0
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: selenium-webdriver
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 2.33.0
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 2.33.0
|
99
|
+
description: This plugin adds the ability to tests against the Refinery CMS gem while
|
100
|
+
inside a Refinery CMS extension
|
87
101
|
email: info@refinerycms.com
|
88
102
|
executables: []
|
89
103
|
extensions: []
|
@@ -98,9 +112,9 @@ files:
|
|
98
112
|
- lib/refinery/testing/controller_macros.rb
|
99
113
|
- lib/refinery/testing/controller_macros/authentication.rb
|
100
114
|
- lib/refinery/testing/controller_macros/methods.rb
|
115
|
+
- lib/refinery/testing/feature_macros.rb
|
116
|
+
- lib/refinery/testing/feature_macros/authentication.rb
|
101
117
|
- lib/refinery/testing/railtie.rb
|
102
|
-
- lib/refinery/testing/request_macros.rb
|
103
|
-
- lib/refinery/testing/request_macros/authentication.rb
|
104
118
|
- lib/refinerycms-testing.rb
|
105
119
|
- refinerycms-testing.gemspec
|
106
120
|
homepage: http://refinerycms.com
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Refinery
|
2
|
-
module Testing
|
3
|
-
module RequestMacros
|
4
|
-
module Authentication
|
5
|
-
def login_refinery_user
|
6
|
-
before do
|
7
|
-
password = '123456'
|
8
|
-
refinery_user = FactoryGirl.create(:refinery_user, {
|
9
|
-
:username => "refinerycms",
|
10
|
-
:password => password,
|
11
|
-
:password_confirmation => password,
|
12
|
-
:email => "refinerycms@refinerycms.com"
|
13
|
-
})
|
14
|
-
|
15
|
-
visit refinery.new_refinery_user_session_path
|
16
|
-
|
17
|
-
fill_in "Login", :with => refinery_user.username
|
18
|
-
fill_in "Password", :with => password
|
19
|
-
|
20
|
-
click_button "Sign in"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def login_refinery_superuser
|
25
|
-
before(:each) do
|
26
|
-
password = '123456'
|
27
|
-
refinery_superuser = FactoryGirl.create(:refinery_superuser, {
|
28
|
-
:username => "refinerycms",
|
29
|
-
:password => password,
|
30
|
-
:password_confirmation => password,
|
31
|
-
:email => "refinerycms@refinerycms.com"
|
32
|
-
})
|
33
|
-
|
34
|
-
visit refinery.new_refinery_user_session_path
|
35
|
-
|
36
|
-
fill_in "Login", :with => refinery_superuser.username
|
37
|
-
fill_in "Password", :with => password
|
38
|
-
|
39
|
-
click_button "Sign in"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def login_refinery_translator
|
44
|
-
before do
|
45
|
-
password = '123456'
|
46
|
-
FactoryGirl.create(:refinery_user)
|
47
|
-
user = FactoryGirl.create(:refinery_translator, {
|
48
|
-
:password => password,
|
49
|
-
:password_confirmation => password
|
50
|
-
})
|
51
|
-
|
52
|
-
visit refinery.new_refinery_user_session_path
|
53
|
-
|
54
|
-
fill_in "Login", :with => user.username
|
55
|
-
fill_in "Password", :with => password
|
56
|
-
|
57
|
-
click_button "Sign in"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|