should_pricot 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/Rakefile +0 -13
- data/VERSION +1 -0
- data/lib/should_pricot/test_helper_methods.rb +21 -0
- data/lib/should_pricot.rb +8 -19
- data/test/should_pricot_test.rb +5 -0
- data/test/test_helper.rb +8 -25
- metadata +21 -114
- data/Manifest +0 -92
- data/should_pricot.gemspec +0 -31
- data/tasks/should_pricot_tasks.rake +0 -4
- data/test/fixtures/posts.yml +0 -4
- data/test/fixtures/users.yml +0 -9
- data/test/functional/users_controller_test.rb +0 -16
- data/test/test-app/app/controllers/application_controller.rb +0 -10
- data/test/test-app/app/controllers/users_controller.rb +0 -40
- data/test/test-app/app/helpers/application_helper.rb +0 -3
- data/test/test-app/app/models/post.rb +0 -3
- data/test/test-app/app/models/user.rb +0 -7
- data/test/test-app/app/views/users/edit.html.erb +0 -0
- data/test/test-app/app/views/users/index.html.erb +0 -9
- data/test/test-app/app/views/users/new.html.erb +0 -0
- data/test/test-app/config/boot.rb +0 -110
- data/test/test-app/config/database.yml +0 -4
- data/test/test-app/config/environment.rb +0 -12
- data/test/test-app/config/environments/test.rb +0 -0
- data/test/test-app/config/initializers/funktional.rb +0 -8
- data/test/test-app/config/initializers/new_rails_defaults.rb +0 -21
- data/test/test-app/config/routes.rb +0 -5
- data/test/test-app/db/migrate/001_create_users.rb +0 -18
- data/test/test-app/db/migrate/002_create_posts.rb +0 -13
- data/test/test-app/public/404.html +0 -30
- data/test/test-app/public/422.html +0 -30
- data/test/test-app/public/500.html +0 -30
- data/test/test-app/script/console +0 -3
- data/test/test-app/script/generate +0 -3
- data/test/test-app/vendor/plugins/funktional/MIT-LICENSE +0 -20
- data/test/test-app/vendor/plugins/funktional/README.rdoc +0 -289
- data/test/test-app/vendor/plugins/funktional/Rakefile +0 -23
- data/test/test-app/vendor/plugins/funktional/init.rb +0 -8
- data/test/test-app/vendor/plugins/funktional/install.rb +0 -1
- data/test/test-app/vendor/plugins/funktional/lib/funktional/assertion.rb +0 -9
- data/test/test-app/vendor/plugins/funktional/lib/funktional/assigned_assertion.rb +0 -39
- data/test/test-app/vendor/plugins/funktional/lib/funktional/attribute_test_helper.rb +0 -27
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/assigned_should_block.rb +0 -32
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/collector.rb +0 -21
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/count_should_block.rb +0 -21
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/delegating_should_block.rb +0 -30
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/element_should_block.rb +0 -29
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/flashed_should_block.rb +0 -17
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_block.rb +0 -60
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_create_block.rb +0 -17
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_delete_block.rb +0 -17
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_not_block.rb +0 -20
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_not_create_block.rb +0 -17
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_not_delete_block.rb +0 -17
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_not_send_email_block.rb +0 -18
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context/stack_recorder.rb +0 -34
- data/test/test-app/vendor/plugins/funktional/lib/funktional/context.rb +0 -126
- data/test/test-app/vendor/plugins/funktional/lib/funktional/email_assertion.rb +0 -50
- data/test/test-app/vendor/plugins/funktional/lib/funktional/flashed_assertion.rb +0 -12
- data/test/test-app/vendor/plugins/funktional/lib/funktional/model_assertions.rb +0 -108
- data/test/test-app/vendor/plugins/funktional/lib/funktional/random_characters.rb +0 -11
- data/test/test-app/vendor/plugins/funktional/lib/funktional/recursive_assertion.rb +0 -23
- data/test/test-app/vendor/plugins/funktional/lib/funktional/route_checker.rb +0 -49
- data/test/test-app/vendor/plugins/funktional/lib/funktional/setup.rb +0 -11
- data/test/test-app/vendor/plugins/funktional/lib/funktional/test_class_methods.rb +0 -28
- data/test/test-app/vendor/plugins/funktional/lib/funktional/test_instance_methods.rb +0 -131
- data/test/test-app/vendor/plugins/funktional/lib/funktional.rb +0 -41
- data/test/test-app/vendor/plugins/funktional/tasks/should_b_tasks.rake +0 -4
- data/test/test-app/vendor/plugins/funktional/test/fixtures/posts.yml +0 -4
- data/test/test-app/vendor/plugins/funktional/test/fixtures/users.yml +0 -5
- data/test/test-app/vendor/plugins/funktional/test/test-app/app/controllers/application_controller.rb +0 -10
- data/test/test-app/vendor/plugins/funktional/test/test-app/app/helpers/application_helper.rb +0 -3
- data/test/test-app/vendor/plugins/funktional/test/test-app/app/models/post.rb +0 -3
- data/test/test-app/vendor/plugins/funktional/test/test-app/app/models/user.rb +0 -7
- data/test/test-app/vendor/plugins/funktional/test/test-app/config/boot.rb +0 -110
- data/test/test-app/vendor/plugins/funktional/test/test-app/config/database.yml +0 -4
- data/test/test-app/vendor/plugins/funktional/test/test-app/config/environment.rb +0 -12
- data/test/test-app/vendor/plugins/funktional/test/test-app/config/environments/test.rb +0 -0
- data/test/test-app/vendor/plugins/funktional/test/test-app/config/initializers/funktional.rb +0 -8
- data/test/test-app/vendor/plugins/funktional/test/test-app/config/initializers/new_rails_defaults.rb +0 -21
- data/test/test-app/vendor/plugins/funktional/test/test-app/config/routes.rb +0 -4
- data/test/test-app/vendor/plugins/funktional/test/test-app/db/migrate/001_create_users.rb +0 -18
- data/test/test-app/vendor/plugins/funktional/test/test-app/db/migrate/002_create_posts.rb +0 -13
- data/test/test-app/vendor/plugins/funktional/test/test-app/public/404.html +0 -30
- data/test/test-app/vendor/plugins/funktional/test/test-app/public/422.html +0 -30
- data/test/test-app/vendor/plugins/funktional/test/test-app/public/500.html +0 -30
- data/test/test-app/vendor/plugins/funktional/test/test-app/script/console +0 -3
- data/test/test-app/vendor/plugins/funktional/test/test-app/script/generate +0 -3
- data/test/test-app/vendor/plugins/funktional/test/test_helper.rb +0 -27
- data/test/test-app/vendor/plugins/funktional/test/unit/user_test.rb +0 -12
- data/test/test-app/vendor/plugins/funktional/uninstall.rb +0 -1
@@ -1,108 +0,0 @@
|
|
1
|
-
module Funktional
|
2
|
-
module ModelAssertions
|
3
|
-
def should_require_a(field, expected_error_message = nil)
|
4
|
-
check_test_instance!
|
5
|
-
must_be_valid_before_test!
|
6
|
-
|
7
|
-
assign_nil_to(field, expected_error_message) do
|
8
|
-
assert_invalid("'#{self.class.name}' should require a '#{field}'")
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
alias :should_require_an :should_require_a
|
13
|
-
|
14
|
-
def should_not_require_a(field)
|
15
|
-
check_test_instance!
|
16
|
-
|
17
|
-
assign_nil_to(field) do
|
18
|
-
assert_valid
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
alias :should_not_require_an :should_not_require_a
|
23
|
-
|
24
|
-
def should_have_invalid(field, expected_error_message = nil)
|
25
|
-
check_test_instance!
|
26
|
-
|
27
|
-
assert_invalid("'#{self.class.name}' should have invalid '#{field}'")
|
28
|
-
assert_message(field, expected_error_message) if expected_error_message
|
29
|
-
end
|
30
|
-
|
31
|
-
def should_mass_assign(*fields)
|
32
|
-
check_test_instance!
|
33
|
-
fields.each do |field|
|
34
|
-
Funktional.test_instance.assert self.class.accessible_attributes.include?(field.to_s)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def should_not_mass_assign(*fields)
|
39
|
-
check_test_instance!
|
40
|
-
accessible_attrib = self.class.accessible_attributes.to_a
|
41
|
-
protected_attrib = self.class.protected_attributes.to_a
|
42
|
-
fields = fields.map(&:to_s)
|
43
|
-
|
44
|
-
if accessible_attrib.any?
|
45
|
-
common_fields = (accessible_attrib & fields)
|
46
|
-
@test.assert((common_fields.size == 0), "#{common_fields.inspect} marked accessible")
|
47
|
-
elsif protected_attrib.any?
|
48
|
-
common_fields = (protected_attrib & fields)
|
49
|
-
difference = (fields - protected_attrib)
|
50
|
-
@test.assert((common_fields.size == fields.size), "#{difference.inspect} not protected")
|
51
|
-
else
|
52
|
-
@test.flunk "#{fields.inspect} not protected"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def should_protect(*fields)
|
57
|
-
check_test_instance!
|
58
|
-
fields.each do |field|
|
59
|
-
Funktional.test_instance.assert self.class.protected_attributes.include?(field.to_s)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def should_respond_to(method)
|
64
|
-
Funktional.test_instance.assert_respond_to self, method
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def assign_nil_to(field, expected_error_message = nil)
|
70
|
-
saved_existing_value = self.send field
|
71
|
-
self.send "#{field}=", nil
|
72
|
-
|
73
|
-
yield
|
74
|
-
|
75
|
-
assert_message(field, expected_error_message) if expected_error_message
|
76
|
-
self.send "#{field}=", saved_existing_value
|
77
|
-
|
78
|
-
# clear errors
|
79
|
-
self.valid?
|
80
|
-
end
|
81
|
-
|
82
|
-
def assert_invalid(message)
|
83
|
-
Funktional.test_instance.assert self.invalid?, message
|
84
|
-
end
|
85
|
-
|
86
|
-
def assert_valid
|
87
|
-
Funktional.test_instance.assert self.valid?
|
88
|
-
end
|
89
|
-
|
90
|
-
def assert_message(field, expected_error_message)
|
91
|
-
Funktional.test_instance.assert_equal(expected_error_message, self.errors[field])
|
92
|
-
end
|
93
|
-
|
94
|
-
def must_be_valid_before_test!
|
95
|
-
if self.invalid?
|
96
|
-
error = "Funktional requires a valid instance of #{self.class.name}"
|
97
|
-
Funktional.test_instance.flunk error
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def check_test_instance!
|
102
|
-
if Funktional.test_instance.nil?
|
103
|
-
raise Funktional::Setup::Error, 'Did you forget to (setup :funktional) in test/test_helper?'
|
104
|
-
end
|
105
|
-
@test = Funktional.test_instance
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Funktional
|
2
|
-
class RecursiveAssertion < Funktional::Assertion
|
3
|
-
def initialize(assigned, method)
|
4
|
-
@test = Funktional.test_instance
|
5
|
-
@assigned = assigned
|
6
|
-
@method = method
|
7
|
-
|
8
|
-
@test.assert_respond_to @assigned, @method
|
9
|
-
end
|
10
|
-
|
11
|
-
def should_be(expected_value)
|
12
|
-
value = @assigned.send @method
|
13
|
-
@test.assert_equal expected_value, value
|
14
|
-
end
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def method_missing(method, *args)
|
19
|
-
@assigned = @assigned.send @method
|
20
|
-
RecursiveAssertion.new(@assigned, method)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Funktional
|
2
|
-
|
3
|
-
class RouteChecker
|
4
|
-
instance_methods.each do |method|
|
5
|
-
undef_method(method) unless %w(__send__ __id__ instance_eval).include?(method)
|
6
|
-
end
|
7
|
-
|
8
|
-
attr_reader :__path_and_method, :__controller_action_etc
|
9
|
-
|
10
|
-
def self.build(params, &blk)
|
11
|
-
checker = self.new(params)
|
12
|
-
|
13
|
-
checker.instance_eval(&blk)
|
14
|
-
return checker
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(params)
|
18
|
-
@__path_and_method = __get_path_and_method(params)
|
19
|
-
@__controller_action_etc = {}
|
20
|
-
end
|
21
|
-
|
22
|
-
def __test_name
|
23
|
-
path = @__path_and_method[:path]
|
24
|
-
method = @__path_and_method[:method]
|
25
|
-
|
26
|
-
"route '#{path}' :method '#{method}' to #{@__controller_action_etc.inspect}"
|
27
|
-
end
|
28
|
-
|
29
|
-
def method_missing(method_name, value)
|
30
|
-
@__controller_action_etc[method_name] = value
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def __get_path_and_method(params)
|
36
|
-
if params.is_a? Hash
|
37
|
-
{
|
38
|
-
:path => params[:route],
|
39
|
-
:method => params[:method].to_sym
|
40
|
-
}
|
41
|
-
else
|
42
|
-
{
|
43
|
-
:path => params,
|
44
|
-
:method => :get
|
45
|
-
}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Funktional
|
2
|
-
|
3
|
-
module TestClassMethods
|
4
|
-
def context(name, &blk)
|
5
|
-
if Funktional.current_context
|
6
|
-
Funktional.current_context.context(name, &blk)
|
7
|
-
else
|
8
|
-
context = Funktional::Context.new(name, self, &blk)
|
9
|
-
context.build
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def should(name, &blk)
|
14
|
-
if Funktional.current_context
|
15
|
-
raise 'block required' unless block_given?
|
16
|
-
Funktional.current_context.should(name, &blk)
|
17
|
-
else
|
18
|
-
context_name = self.name.gsub(/Test/, "")
|
19
|
-
|
20
|
-
context = Funktional::Context.new(context_name, self) do
|
21
|
-
raise 'block required' unless block_given?
|
22
|
-
should(name, &blk)
|
23
|
-
end
|
24
|
-
context.build
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
module Funktional
|
2
|
-
|
3
|
-
module TestInstanceMethods
|
4
|
-
def should(params, &block)
|
5
|
-
method = "should_#{params.keys.first}".to_sym
|
6
|
-
args = (params.length > 1) ? params : params.values.first
|
7
|
-
|
8
|
-
self.send method, args, &block
|
9
|
-
end
|
10
|
-
|
11
|
-
def should_not(params, &block)
|
12
|
-
if params.is_a? Hash
|
13
|
-
method = "should_not_#{params.keys.first}".to_sym
|
14
|
-
args = params.values.first
|
15
|
-
else
|
16
|
-
method = "should_not_#{params}".to_sym
|
17
|
-
args = nil
|
18
|
-
end
|
19
|
-
self.send method, args, &block
|
20
|
-
end
|
21
|
-
|
22
|
-
def flashed(symbol)
|
23
|
-
FlashedAssertion.new(symbol)
|
24
|
-
end
|
25
|
-
|
26
|
-
def assigned(klass)
|
27
|
-
AssignedAssertion.new(klass)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def should_route(params, &blk)
|
33
|
-
_wrap_assertion do
|
34
|
-
checker = RouteChecker.build(params, &blk)
|
35
|
-
assert_routing(checker.__path_and_method, checker.__controller_action_etc)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
alias :should_method :should_route
|
40
|
-
|
41
|
-
def should_send_email(details)
|
42
|
-
EmailAssertion.new(details)
|
43
|
-
end
|
44
|
-
|
45
|
-
def should_not_send_email(going_to_be_nil = nil)
|
46
|
-
before_count = ActionMailer::Base.deliveries.size
|
47
|
-
yield
|
48
|
-
after_count = ActionMailer::Base.deliveries.size
|
49
|
-
assert_equal before_count, after_count, "Email was sent"
|
50
|
-
end
|
51
|
-
|
52
|
-
def should_render(template)
|
53
|
-
_wrap_assertion do
|
54
|
-
assert_response :success
|
55
|
-
assert_template template
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def should_render_404(expected_template = 'public/404')
|
60
|
-
_wrap_assertion do
|
61
|
-
actual_template = @response.rendered[:template].to_s
|
62
|
-
|
63
|
-
if actual_template.blank?
|
64
|
-
msg = "redirected to [#{@response.redirected_to}]"
|
65
|
-
else
|
66
|
-
msg = "rendered template [#{actual_template}]"
|
67
|
-
end
|
68
|
-
assert_response :not_found, msg
|
69
|
-
assert_template expected_template
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def should_assign_new(klass_or_symbol)
|
74
|
-
if klass_or_symbol.is_a? Symbol
|
75
|
-
symbol = klass_or_symbol
|
76
|
-
|
77
|
-
assert_not_nil assigns(symbol), "No [:#{symbol}] assigned"
|
78
|
-
assert assigns(symbol).new_record?, "[:#{symbol}] is not a new record"
|
79
|
-
else
|
80
|
-
klass = klass_or_symbol
|
81
|
-
symbol = klass.to_s.tableize.singularize.to_sym
|
82
|
-
|
83
|
-
assert_not_nil assigns(symbol), "No [#{symbol}] assigned"
|
84
|
-
assert assigns(symbol).new_record?, "[#{klass}] is not a new record"
|
85
|
-
assert assigns(symbol).is_a?(klass), "assigned [#{symbol}] is not a [#{klass}]"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def should_redirect_to(uri)
|
90
|
-
_wrap_assertion do
|
91
|
-
assert_response :redirect
|
92
|
-
assert_redirected_to uri
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def should_respond(expected_response)
|
97
|
-
assert_response :not_found
|
98
|
-
assert_template 'public/404'
|
99
|
-
end
|
100
|
-
|
101
|
-
# Delete
|
102
|
-
|
103
|
-
def should_delete(klass)
|
104
|
-
before_count = klass.count
|
105
|
-
expected_count = before_count - 1
|
106
|
-
yield
|
107
|
-
assert_equal expected_count, klass.count, "A [#{klass}] was not deleted"
|
108
|
-
end
|
109
|
-
|
110
|
-
def should_not_delete(klass)
|
111
|
-
expected_count = klass.count
|
112
|
-
yield
|
113
|
-
assert_equal expected_count, klass.count, "A [#{klass}] was deleted"
|
114
|
-
end
|
115
|
-
|
116
|
-
# Create
|
117
|
-
|
118
|
-
def should_create(klass)
|
119
|
-
before_count = klass.count
|
120
|
-
expected_count = before_count + 1
|
121
|
-
yield
|
122
|
-
assert_equal expected_count, klass.count, "New [#{klass}] was not created"
|
123
|
-
end
|
124
|
-
|
125
|
-
def should_not_create(klass)
|
126
|
-
expected_count = klass.count
|
127
|
-
yield
|
128
|
-
assert_equal expected_count, klass.count, "New [#{klass}] was created"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
Rails.backtrace_cleaner.add_silencer { |line| line =~ /funktional/ }
|
2
|
-
|
3
|
-
require 'test_help'
|
4
|
-
|
5
|
-
require 'funktional/test_instance_methods'
|
6
|
-
require 'funktional/test_class_methods'
|
7
|
-
|
8
|
-
require 'funktional/assertion'
|
9
|
-
require 'funktional/assigned_assertion'
|
10
|
-
require 'funktional/email_assertion'
|
11
|
-
require 'funktional/flashed_assertion'
|
12
|
-
require 'funktional/model_assertions'
|
13
|
-
require 'funktional/route_checker'
|
14
|
-
require 'funktional/attribute_test_helper'
|
15
|
-
|
16
|
-
require 'funktional/context'
|
17
|
-
require 'funktional/context/stack_recorder'
|
18
|
-
require 'funktional/context/should_block'
|
19
|
-
require 'funktional/context/should_not_block'
|
20
|
-
require 'funktional/context/delegating_should_block'
|
21
|
-
require 'funktional/context/should_create_block'
|
22
|
-
require 'funktional/context/should_not_create_block'
|
23
|
-
require 'funktional/context/should_not_delete_block'
|
24
|
-
require 'funktional/context/should_not_send_email_block'
|
25
|
-
require 'funktional/context/should_delete_block'
|
26
|
-
require 'funktional/context/element_should_block'
|
27
|
-
require 'funktional/context/count_should_block'
|
28
|
-
require 'funktional/context/flashed_should_block'
|
29
|
-
require 'funktional/context/assigned_should_block'
|
30
|
-
require 'funktional/context/collector'
|
31
|
-
|
32
|
-
require 'funktional/setup'
|
33
|
-
|
34
|
-
ActiveRecord::Base.send(:include, Funktional::ModelAssertions)
|
35
|
-
|
36
|
-
ActiveSupport::TestCase.send(:include, Funktional::TestInstanceMethods)
|
37
|
-
ActiveSupport::TestCase.send :extend, Funktional::TestClassMethods
|
38
|
-
ActiveSupport::TestCase.send(:include, Funktional::AttributeTestHelper)
|
39
|
-
|
40
|
-
ActiveSupport::TestCase.send(:include, Funktional::Setup)
|
41
|
-
|
data/test/test-app/vendor/plugins/funktional/test/test-app/app/controllers/application_controller.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# Filters added to this controller apply to all controllers in the application.
|
2
|
-
# Likewise, all the methods added will be available for all controllers.
|
3
|
-
|
4
|
-
class ApplicationController < ActionController::Base
|
5
|
-
helper :all # include all helpers, all the time
|
6
|
-
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
-
|
8
|
-
# Scrub sensitive parameters from your log
|
9
|
-
# filter_parameter_logging :password
|
10
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
# Don't change this file!
|
2
|
-
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
-
|
4
|
-
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
class << self
|
8
|
-
def boot!
|
9
|
-
unless booted?
|
10
|
-
preinitialize
|
11
|
-
pick_boot.run
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def booted?
|
16
|
-
defined? Rails::Initializer
|
17
|
-
end
|
18
|
-
|
19
|
-
def pick_boot
|
20
|
-
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
-
end
|
22
|
-
|
23
|
-
def vendor_rails?
|
24
|
-
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
-
end
|
26
|
-
|
27
|
-
def preinitialize
|
28
|
-
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
-
end
|
30
|
-
|
31
|
-
def preinitializer_path
|
32
|
-
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Boot
|
37
|
-
def run
|
38
|
-
load_initializer
|
39
|
-
Rails::Initializer.run(:set_load_path)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class VendorBoot < Boot
|
44
|
-
def load_initializer
|
45
|
-
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
-
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
-
Rails::GemDependency.add_frozen_gem_path
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class GemBoot < Boot
|
52
|
-
def load_initializer
|
53
|
-
self.class.load_rubygems
|
54
|
-
load_rails_gem
|
55
|
-
require 'initializer'
|
56
|
-
end
|
57
|
-
|
58
|
-
def load_rails_gem
|
59
|
-
if version = self.class.gem_version
|
60
|
-
gem 'rails', version
|
61
|
-
else
|
62
|
-
gem 'rails'
|
63
|
-
end
|
64
|
-
rescue Gem::LoadError => load_error
|
65
|
-
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
66
|
-
exit 1
|
67
|
-
end
|
68
|
-
|
69
|
-
class << self
|
70
|
-
def rubygems_version
|
71
|
-
Gem::RubyGemsVersion rescue nil
|
72
|
-
end
|
73
|
-
|
74
|
-
def gem_version
|
75
|
-
if defined? RAILS_GEM_VERSION
|
76
|
-
RAILS_GEM_VERSION
|
77
|
-
elsif ENV.include?('RAILS_GEM_VERSION')
|
78
|
-
ENV['RAILS_GEM_VERSION']
|
79
|
-
else
|
80
|
-
parse_gem_version(read_environment_rb)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def load_rubygems
|
85
|
-
min_version = '1.3.2'
|
86
|
-
require 'rubygems'
|
87
|
-
unless rubygems_version >= min_version
|
88
|
-
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
89
|
-
exit 1
|
90
|
-
end
|
91
|
-
|
92
|
-
rescue LoadError
|
93
|
-
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
94
|
-
exit 1
|
95
|
-
end
|
96
|
-
|
97
|
-
def parse_gem_version(text)
|
98
|
-
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
def read_environment_rb
|
103
|
-
File.read("#{RAILS_ROOT}/config/environment.rb")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# All that for this:
|
110
|
-
Rails.boot!
|
@@ -1,12 +0,0 @@
|
|
1
|
-
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
|
2
|
-
require File.join(File.dirname(__FILE__), 'boot')
|
3
|
-
|
4
|
-
Rails::Initializer.run do |config|
|
5
|
-
config.log_level = :debug
|
6
|
-
config.cache_classes = false
|
7
|
-
config.whiny_nils = true
|
8
|
-
config.action_controller.session = {
|
9
|
-
:key => 'funktional_session',
|
10
|
-
:secret => 'sdasda2138120dsad1201023da'
|
11
|
-
}
|
12
|
-
end
|
File without changes
|
data/test/test-app/vendor/plugins/funktional/test/test-app/config/initializers/funktional.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
# This simulates loading the funktional plugin, but without relying on
|
2
|
-
# vendor/plugins
|
3
|
-
|
4
|
-
funktional_path = File.join(File.dirname(__FILE__), *%w(.. .. .. ..))
|
5
|
-
funktional_lib_path = File.join(funktional_path, "lib")
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift(funktional_lib_path)
|
8
|
-
load File.join(funktional_path, "init.rb")
|
data/test/test-app/vendor/plugins/funktional/test/test-app/config/initializers/new_rails_defaults.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# These settings change the behavior of Rails 2 apps and will be defaults
|
4
|
-
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
5
|
-
|
6
|
-
if defined?(ActiveRecord)
|
7
|
-
# Include Active Record class name as root for JSON serialized output.
|
8
|
-
ActiveRecord::Base.include_root_in_json = true
|
9
|
-
|
10
|
-
# Store the full class name (including module namespace) in STI type column.
|
11
|
-
ActiveRecord::Base.store_full_sti_class = true
|
12
|
-
end
|
13
|
-
|
14
|
-
ActionController::Routing.generate_best_match = false
|
15
|
-
|
16
|
-
# Use ISO 8601 format for JSON serialized times and dates.
|
17
|
-
ActiveSupport.use_standard_json_time_format = true
|
18
|
-
|
19
|
-
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
20
|
-
# if you're including raw json in an HTML page.
|
21
|
-
ActiveSupport.escape_html_entities_in_json = false
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class CreateUsers < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :users do |t|
|
4
|
-
t.string :name
|
5
|
-
t.string :email
|
6
|
-
t.integer :age
|
7
|
-
t.string :phone
|
8
|
-
end
|
9
|
-
add_index :users, :email, :unique => true
|
10
|
-
add_index :users, :name
|
11
|
-
add_index :users, :age
|
12
|
-
add_index :users, [:email, :name], :unique => true
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.down
|
16
|
-
drop_table :users
|
17
|
-
end
|
18
|
-
end
|