phoenix_testing 0.2.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/phoenix/tasks/testing.rake +47 -0
- data/lib/phoenix/testing.rb +29 -0
- data/lib/phoenix/testing/controller_macros.rb +7 -0
- data/lib/phoenix/testing/controller_macros/authentication.rb +31 -0
- data/lib/phoenix/testing/railtie.rb +33 -0
- data/lib/phoenix/testing/request_macros.rb +7 -0
- data/lib/phoenix/testing/request_macros/authentication.rb +33 -0
- data/lib/phoenix_testing.rb +1 -0
- metadata +176 -0
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
= Phoenix Testing Helper Project
|
@@ -0,0 +1,47 @@
|
|
1
|
+
namespace :phoenix do
|
2
|
+
namespace :testing do
|
3
|
+
desc "Generates a dummy app for testing"
|
4
|
+
task :dummy_app => [:setup_dummy_app, :migrate_dummy_app]
|
5
|
+
|
6
|
+
task :setup_dummy_app do
|
7
|
+
require 'phoenix'
|
8
|
+
|
9
|
+
params = %w(--quiet)
|
10
|
+
|
11
|
+
Phoenix::DummyGenerator.start params
|
12
|
+
|
13
|
+
# Load generated dummy app after generation - some of the follow
|
14
|
+
# generators depend on Rails.root being available
|
15
|
+
# load File.join(ENGINE_PATH, 'spec/dummy/config/environment.rb')
|
16
|
+
end
|
17
|
+
|
18
|
+
task :migrate_dummy_app do
|
19
|
+
engines = %w(
|
20
|
+
phoenix_core
|
21
|
+
phoenix_settings
|
22
|
+
)
|
23
|
+
|
24
|
+
task_params = [%Q{ bundle exec rake -f #{Phoenix::Testing::Railtie.target_engine_path.join('Rakefile')} }]
|
25
|
+
task_params << %Q{ app:railties:install:migrations FROM="#{engines.join(', ')}" }
|
26
|
+
task_params << %Q{ app:db:drop app:db:create app:db:migrate app:db:seed app:db:test:prepare }
|
27
|
+
task_params << %Q{ RAILS_ENV=development --quiet }
|
28
|
+
|
29
|
+
system task_params.join(' ')
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Remove the dummy app used for testing"
|
33
|
+
task :clean_dummy_app do
|
34
|
+
Phoenix::Testing::Railtie.target_engine_path.join('spec', 'dummy').rmtree
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace :engine do
|
38
|
+
desc "Initialize the testing environment"
|
39
|
+
task :setup => [:init_test_database]
|
40
|
+
|
41
|
+
task :init_test_database => [
|
42
|
+
'app:db:migrate',
|
43
|
+
'app:db:test:prepare'
|
44
|
+
]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'phoenix_core'
|
2
|
+
require 'factory_girl_rails'
|
3
|
+
|
4
|
+
module Phoenix
|
5
|
+
module Testing
|
6
|
+
class << self
|
7
|
+
def root
|
8
|
+
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
9
|
+
end
|
10
|
+
|
11
|
+
# Load the factories of all currently loaded engines
|
12
|
+
def load_factories
|
13
|
+
Phoenix.engines.each do |engine_const|
|
14
|
+
if engine_const.respond_to?(:factory_paths)
|
15
|
+
engine_const.send(:factory_paths).each do |path|
|
16
|
+
FactoryGirl.definition_file_paths << path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
FactoryGirl.find_definitions
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'phoenix/testing/railtie' if defined?(Rails)
|
25
|
+
|
26
|
+
autoload :ControllerMacros, 'phoenix/testing/controller_macros'
|
27
|
+
autoload :RequestMacros, 'phoenix/testing/request_macros'
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Phoenix
|
2
|
+
module Testing
|
3
|
+
module ControllerMacros
|
4
|
+
module Authentication
|
5
|
+
def login_user
|
6
|
+
before(:each) do
|
7
|
+
@user = FactoryGirl.create(:user)
|
8
|
+
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
9
|
+
sign_in @user
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def login_phoenix_user
|
14
|
+
before(:each) do
|
15
|
+
@phoenix_user = FactoryGirl.create(:phoenix_user)
|
16
|
+
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
17
|
+
sign_in @phoenix_user
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def login_phoenix_translator
|
22
|
+
before(:each) do
|
23
|
+
@phoenix_translator = FactoryGirl.create(:phoenix_translator)
|
24
|
+
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
25
|
+
sign_in @phoenix_translator
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'phoenix_testing'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module Phoenix
|
5
|
+
module Testing
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
railtie_name :phoenix_testing
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_reader :target_engine_path # :nodoc:
|
11
|
+
|
12
|
+
# Loads Rake tasks to assist with manipulating dummy applications for testing engines. Takes
|
13
|
+
# a string representing the path to your application or engine.
|
14
|
+
#
|
15
|
+
# This function should be used in the Rakefile of your application or engine
|
16
|
+
#
|
17
|
+
# Example:
|
18
|
+
# Phoenix::Testing::Railtie.load_dummy_tasks(File.dirname(__FILE__))
|
19
|
+
#
|
20
|
+
# Phoenix::Testing::Railtie.load_dummy_tasks('/users/reset/code/mynew_app')
|
21
|
+
def load_dummy_tasks(app_root)
|
22
|
+
@target_engine_path = Pathname.new(app_root.to_s)
|
23
|
+
load 'phoenix/tasks/testing.rake'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
config.after_initialize do
|
28
|
+
#Phoenix.register_engine(Phoenix::Testing)
|
29
|
+
#Testing.load_factories
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Phoenix
|
2
|
+
module Testing
|
3
|
+
module RequestMacros
|
4
|
+
module Authentication
|
5
|
+
def login_phoenix_user
|
6
|
+
before(:each) do
|
7
|
+
FactoryGirl.create(:phoenix_user, :username => "phoenix",
|
8
|
+
:password => "123456",
|
9
|
+
:password_confirmation => "123456",
|
10
|
+
:email => "phoenix@example.com")
|
11
|
+
visit new_phoenix_user_session_path
|
12
|
+
fill_in "Login", :with => "phoenix"
|
13
|
+
fill_in "Password", :with => "123456"
|
14
|
+
click_button "Sign in"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def login_phoenix_translator
|
19
|
+
before(:each) do
|
20
|
+
FactoryGirl.create(:phoenix_user)
|
21
|
+
user = FactoryGirl.create(:phoenix_translator, :password => "123456",
|
22
|
+
:password_confirmation => "123456")
|
23
|
+
|
24
|
+
visit new_phoenix_user_session_path
|
25
|
+
fill_in "Login", :with => user.username
|
26
|
+
fill_in "Password", :with => "123456"
|
27
|
+
click_button "Sign in"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'phoenix/testing'
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phoenix_testing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0.beta
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lanvige Jiang
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: database_cleaner
|
16
|
+
requirement: &70361803266820 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70361803266820
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: launchy
|
27
|
+
requirement: &70361803266220 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70361803266220
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: factory_girl_rails
|
38
|
+
requirement: &70361803265480 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70361803265480
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: json_pure
|
49
|
+
requirement: &70361803264760 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70361803264760
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rack-test
|
60
|
+
requirement: &70361803264340 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70361803264340
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-rails
|
71
|
+
requirement: &70361803263600 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70361803263600
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: fuubar
|
82
|
+
requirement: &70361803263020 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70361803263020
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rspec-instafail
|
93
|
+
requirement: &70361803262500 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70361803262500
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: capybara
|
104
|
+
requirement: &70361803278120 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70361803278120
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: guard-rspec
|
115
|
+
requirement: &70361803277500 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *70361803277500
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: phoenix_core
|
126
|
+
requirement: &70361803276380 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - =
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.2.0.beta
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: *70361803276380
|
135
|
+
description: This plugin adds the ability to run cucumber and rspec against the Pheonix
|
136
|
+
Engine project
|
137
|
+
email: lanvige@gmail.com
|
138
|
+
executables: []
|
139
|
+
extensions: []
|
140
|
+
extra_rdoc_files: []
|
141
|
+
files:
|
142
|
+
- lib/phoenix/tasks/testing.rake
|
143
|
+
- lib/phoenix/testing/controller_macros/authentication.rb
|
144
|
+
- lib/phoenix/testing/controller_macros.rb
|
145
|
+
- lib/phoenix/testing/railtie.rb
|
146
|
+
- lib/phoenix/testing/request_macros/authentication.rb
|
147
|
+
- lib/phoenix/testing/request_macros.rb
|
148
|
+
- lib/phoenix/testing.rb
|
149
|
+
- lib/phoenix_testing.rb
|
150
|
+
- README.md
|
151
|
+
homepage: http://lanvige.com
|
152
|
+
licenses: []
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
159
|
+
requirements:
|
160
|
+
- - ! '>='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 1.9.2
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
none: false
|
165
|
+
requirements:
|
166
|
+
- - ! '>'
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 1.3.1
|
169
|
+
requirements:
|
170
|
+
- none
|
171
|
+
rubyforge_project: phoenix_testing
|
172
|
+
rubygems_version: 1.8.13
|
173
|
+
signing_key:
|
174
|
+
specification_version: 3
|
175
|
+
summary: Testing plugin for Phoenix Engine
|
176
|
+
test_files: []
|