should_pricot 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,39 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class AssignedAssertion
|
|
3
|
-
def initialize(klass_or_symbol)
|
|
4
|
-
if klass_or_symbol.is_a? Symbol
|
|
5
|
-
@symbol = klass_or_symbol
|
|
6
|
-
else
|
|
7
|
-
@klass = klass_or_symbol
|
|
8
|
-
@symbol = get_symbol_from_klass
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
@test = Funktional.test_instance
|
|
12
|
-
@assigned = @test.assigns(@symbol)
|
|
13
|
-
|
|
14
|
-
@test.assert_not_nil @assigned, "No [#{@symbol}] assigned"
|
|
15
|
-
|
|
16
|
-
if @klass
|
|
17
|
-
@test.assert @assigned.is_a?(@klass), type_safety_failed_msg
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def should_be(expected_value)
|
|
22
|
-
@test.assert_equal expected_value, @assigned
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
protected
|
|
26
|
-
|
|
27
|
-
def method_missing(method, *args)
|
|
28
|
-
RecursiveAssertion.new(@assigned, method)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def get_symbol_from_klass
|
|
32
|
-
@klass.to_s.tableize.singularize.to_sym
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def type_safety_failed_msg
|
|
36
|
-
"assigned [#{@symbol}] is not a [#{@klass}]"
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
module AttributeTestHelper
|
|
3
|
-
|
|
4
|
-
def missing_attrib(to_remove)
|
|
5
|
-
copy_of_attrib = attrib.clone
|
|
6
|
-
found = copy_of_attrib.delete to_remove
|
|
7
|
-
raise Exception, 'attribute marked for removal is missing' unless found
|
|
8
|
-
|
|
9
|
-
return copy_of_attrib
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def blank_attrib(to_blank)
|
|
13
|
-
attrib.merge(to_blank => '')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def replace_attrib(to_replace)
|
|
17
|
-
key = to_replace.keys.first
|
|
18
|
-
value = to_replace.values.first
|
|
19
|
-
|
|
20
|
-
attrib.merge(key => value)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def add_attrib(addition)
|
|
24
|
-
attrib.merge(addition)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
data/test/test-app/vendor/plugins/funktional/lib/funktional/context/assigned_should_block.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class AssignedShouldBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(recorder, context)
|
|
5
|
-
@recorder, @context = recorder, context
|
|
6
|
-
@should_name = "the assigned(#{@recorder.__target})"
|
|
7
|
-
|
|
8
|
-
@blk = lambda do
|
|
9
|
-
result = nil
|
|
10
|
-
|
|
11
|
-
recorder.__each_called do |meth, args|
|
|
12
|
-
if result.nil?
|
|
13
|
-
result = assigned(recorder.__target).send(meth, *args)
|
|
14
|
-
else
|
|
15
|
-
result.send(meth, *args)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_name_parts
|
|
22
|
-
call_chain = ''
|
|
23
|
-
|
|
24
|
-
@recorder.__each_called do |meth, args|
|
|
25
|
-
call_chain << ".#{meth}" unless meth.eql? :should_be
|
|
26
|
-
end
|
|
27
|
-
@should_name << "#{call_chain} should be [#{@recorder.__last_value}]"
|
|
28
|
-
|
|
29
|
-
return ["test:", "#{@context.full_name},", "#{@should_name}"]
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class << self
|
|
3
|
-
attr_accessor :contexts
|
|
4
|
-
|
|
5
|
-
def contexts
|
|
6
|
-
@contexts ||= []
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def current_context
|
|
10
|
-
self.contexts.last
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def add_context(context)
|
|
14
|
-
self.contexts.push(context)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def remove_context
|
|
18
|
-
self.contexts.pop
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class CountShouldBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(recorder, context)
|
|
5
|
-
@recorder, @context = recorder, context
|
|
6
|
-
@should_name = "count(#{@recorder.__target})"
|
|
7
|
-
|
|
8
|
-
@blk = lambda do
|
|
9
|
-
count(recorder.__target).send(recorder.__meth(0)[:name], *recorder.__meth(0)[:args])
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def test_name_parts
|
|
14
|
-
parts = ["test:", "#{@context.full_name},", "#{@should_name}"]
|
|
15
|
-
parts << @recorder.__meth(0)[:name].to_s.gsub('_', ' ')
|
|
16
|
-
parts << "[#{@recorder.__meth(0)[:args]}]"
|
|
17
|
-
|
|
18
|
-
return parts
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
data/test/test-app/vendor/plugins/funktional/lib/funktional/context/delegating_should_block.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class DelegatingShouldBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(options, context, &blk)
|
|
5
|
-
@should_name = build_should_name(options, &blk)
|
|
6
|
-
@blk = proc { should(options, &blk) }
|
|
7
|
-
@context = context
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def build_should_name(options, &blk)
|
|
11
|
-
case options.keys.first
|
|
12
|
-
when :render
|
|
13
|
-
"render the [#{options[:render]}] template"
|
|
14
|
-
when :render_404
|
|
15
|
-
"render the [#{options[:render_404]}] template with a [404] status code"
|
|
16
|
-
when :redirect_to
|
|
17
|
-
"redirect to the [#{options[:redirect_to]}] url"
|
|
18
|
-
when :assign_new
|
|
19
|
-
"assign a new [#{options[:assign_new]}]"
|
|
20
|
-
when :route, :method
|
|
21
|
-
args = (options.length > 1) ? options : options.values.first
|
|
22
|
-
RouteChecker.build(args, &blk).__test_name
|
|
23
|
-
when :send_email
|
|
24
|
-
"send an email #{options[:send_email].inspect}"
|
|
25
|
-
else
|
|
26
|
-
raise NoMethodError, "#{options.inspect} is not recognised"
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ElementShouldBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(recorder, context)
|
|
5
|
-
@recorder, @context = recorder, context
|
|
6
|
-
@should_name = "element(#{@recorder.__target})"
|
|
7
|
-
|
|
8
|
-
@blk = lambda do
|
|
9
|
-
element(recorder.__target).send(recorder.__meth(0)[:name], *recorder.__meth(0)[:args])
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def test_name_parts
|
|
14
|
-
parts = ["test:", "#{@context.full_name},", "#{@should_name}"]
|
|
15
|
-
parts << @recorder.__meth(0)[:name].to_s.gsub('_', ' ')
|
|
16
|
-
|
|
17
|
-
if called?(:should_be) or called?(:should_contain)
|
|
18
|
-
parts << "[#{@recorder.__meth(0)[:args]}]"
|
|
19
|
-
end
|
|
20
|
-
return parts
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def called?(name)
|
|
26
|
-
@recorder.__meth(0)[:name].eql? name
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class FlashedShouldBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(recorder, context)
|
|
5
|
-
@recorder, @context = recorder, context
|
|
6
|
-
@should_name = "flash[:#{@recorder.__target}]"
|
|
7
|
-
|
|
8
|
-
@blk = lambda do
|
|
9
|
-
flashed(recorder.__target).send(recorder.__meth(0)[:name], *recorder.__meth(0)[:args])
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def test_name_parts
|
|
14
|
-
["test:", "#{@context.full_name},", @should_name, "should be", "[#{@recorder.__meth(0)[:args]}]"]
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ShouldBlock
|
|
3
|
-
|
|
4
|
-
def self.build(options, context, &blk)
|
|
5
|
-
return self.new(name = options, context, &blk) if options.is_a? String
|
|
6
|
-
|
|
7
|
-
options = {:render_404 => 'public/404'} if options == :render_404
|
|
8
|
-
|
|
9
|
-
case options.keys.first
|
|
10
|
-
when :create
|
|
11
|
-
ShouldCreateBlock.new(options[:create], context)
|
|
12
|
-
when :delete
|
|
13
|
-
ShouldDeleteBlock.new(options[:delete], context)
|
|
14
|
-
else
|
|
15
|
-
DelegatingShouldBlock.new(options, context, &blk)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def initialize(should_name, context, &blk)
|
|
20
|
-
raise 'block required' unless block_given?
|
|
21
|
-
@should_name, @blk, @context = should_name, blk, context
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def to_test
|
|
25
|
-
context, blk, before = @context, @blk, @before
|
|
26
|
-
|
|
27
|
-
@context.test_unit_class.send(:define_method, build_test_name) do
|
|
28
|
-
begin
|
|
29
|
-
context.run_parent_setup_blocks(self)
|
|
30
|
-
before.bind(self).call if before
|
|
31
|
-
|
|
32
|
-
context.run_current_setup_blocks(self)
|
|
33
|
-
blk.bind(self).call
|
|
34
|
-
ensure
|
|
35
|
-
context.run_all_teardown_blocks(self)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
protected
|
|
41
|
-
|
|
42
|
-
def test_and_line_no
|
|
43
|
-
stack_frame = caller.grep(/bind/).last
|
|
44
|
-
stack_frame.split(':in ').first
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def build_test_name
|
|
48
|
-
test_name = test_name_parts.flatten.join(' ')
|
|
49
|
-
|
|
50
|
-
if @context.test_unit_class.instance_methods.include?(test_name)
|
|
51
|
-
warn " * WARNING: '#{test_name}' is already defined"
|
|
52
|
-
end
|
|
53
|
-
return test_name.to_sym
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_name_parts
|
|
57
|
-
["test:", @context.full_name, "should", "#{@should_name}."]
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ShouldCreateBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(klass, context)
|
|
5
|
-
@context = context
|
|
6
|
-
@should_name = "create a #{klass}"
|
|
7
|
-
|
|
8
|
-
@before = lambda { @before_setup_count = klass.count }
|
|
9
|
-
where = test_and_line_no
|
|
10
|
-
|
|
11
|
-
@blk = lambda do
|
|
12
|
-
expected_count = @before_setup_count + 1
|
|
13
|
-
assert_equal expected_count, klass.count, "New [#{klass}] was not created. #{where}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ShouldDeleteBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(klass, context)
|
|
5
|
-
@context = context
|
|
6
|
-
@should_name = "delete a #{klass}"
|
|
7
|
-
|
|
8
|
-
@before = lambda { @before_setup_count = klass.count }
|
|
9
|
-
where = test_and_line_no
|
|
10
|
-
|
|
11
|
-
@blk = lambda do
|
|
12
|
-
expected_count = @before_setup_count - 1
|
|
13
|
-
assert_equal expected_count, klass.count, "New [#{klass}] was not deleted. #{where}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ShouldNotBlock
|
|
3
|
-
|
|
4
|
-
def self.build(options, context, &blk)
|
|
5
|
-
|
|
6
|
-
if options.is_a? Symbol and options.eql? :send_email
|
|
7
|
-
return ShouldNotSendEmailBlock.new(context)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
case options.keys.first
|
|
11
|
-
when :create
|
|
12
|
-
ShouldNotCreateBlock.new(options[:create], context)
|
|
13
|
-
when :delete
|
|
14
|
-
ShouldNotDeleteBlock.new(options[:delete], context)
|
|
15
|
-
else
|
|
16
|
-
raise "Unknown assertion [should_not #{options.inspect}]"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_not_create_block.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ShouldNotCreateBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(klass, context)
|
|
5
|
-
@context = context
|
|
6
|
-
@should_name = "not create a #{klass}"
|
|
7
|
-
|
|
8
|
-
@before = lambda { @before_setup_count = klass.count }
|
|
9
|
-
where = test_and_line_no
|
|
10
|
-
|
|
11
|
-
@blk = lambda do
|
|
12
|
-
expected_count = @before_setup_count
|
|
13
|
-
assert_equal expected_count, klass.count, "New [#{klass}] was created. #{where}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_not_delete_block.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ShouldNotDeleteBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(klass, context)
|
|
5
|
-
@context = context
|
|
6
|
-
@should_name = "not delete a #{klass}"
|
|
7
|
-
|
|
8
|
-
@before = lambda { @before_setup_count = klass.count }
|
|
9
|
-
where = test_and_line_no
|
|
10
|
-
|
|
11
|
-
@blk = lambda do
|
|
12
|
-
expected_count = @before_setup_count
|
|
13
|
-
assert_equal expected_count, klass.count, "New [#{klass}] was deleted. #{where}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
data/test/test-app/vendor/plugins/funktional/lib/funktional/context/should_not_send_email_block.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class ShouldNotSendEmailBlock < ShouldBlock
|
|
3
|
-
|
|
4
|
-
def initialize(context)
|
|
5
|
-
@context = context
|
|
6
|
-
@should_name = "not send an email"
|
|
7
|
-
|
|
8
|
-
@before = lambda { @before_setup_count = ActionMailer::Base.deliveries.size }
|
|
9
|
-
where = test_and_line_no
|
|
10
|
-
|
|
11
|
-
@blk = lambda do
|
|
12
|
-
expected_count = @before_setup_count
|
|
13
|
-
current = ActionMailer::Base.deliveries.size
|
|
14
|
-
assert_equal expected_count, current, "New [Email] was sent."
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class BlankSlate
|
|
3
|
-
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
class StackRecorder < BlankSlate
|
|
7
|
-
attr_reader :__target
|
|
8
|
-
|
|
9
|
-
def initialize(target)
|
|
10
|
-
@__target = target
|
|
11
|
-
@__methods = []
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def __meth(index)
|
|
15
|
-
@__methods[index]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def __each_called
|
|
19
|
-
@__methods.each { |meth| yield [meth[:name], meth[:args]] }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def __last_value
|
|
23
|
-
@__methods.last[:args].first
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def method_missing(method_name, *args)
|
|
27
|
-
@__methods << {
|
|
28
|
-
:name => method_name,
|
|
29
|
-
:args => args
|
|
30
|
-
}
|
|
31
|
-
return self
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
# borrowing heavily from shoulda contexts.
|
|
2
|
-
|
|
3
|
-
module Funktional
|
|
4
|
-
class Context
|
|
5
|
-
|
|
6
|
-
attr_accessor :name
|
|
7
|
-
attr_accessor :parent
|
|
8
|
-
attr_accessor :sub_contexts
|
|
9
|
-
attr_accessor :setup_blocks
|
|
10
|
-
attr_accessor :teardown_blocks
|
|
11
|
-
attr_accessor :should_blocks
|
|
12
|
-
|
|
13
|
-
def initialize(name, parent, &blk)
|
|
14
|
-
Funktional.add_context(self)
|
|
15
|
-
self.name = name
|
|
16
|
-
self.parent = parent
|
|
17
|
-
self.setup_blocks = []
|
|
18
|
-
self.teardown_blocks = []
|
|
19
|
-
self.should_blocks = []
|
|
20
|
-
self.sub_contexts = []
|
|
21
|
-
|
|
22
|
-
merge_block(&blk)
|
|
23
|
-
Funktional.remove_context
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def merge_block(&blk)
|
|
27
|
-
blk.bind(self).call
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def context(name, &blk)
|
|
31
|
-
self.sub_contexts << Context.new(name, self, &blk)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def setup(&blk)
|
|
35
|
-
self.setup_blocks << blk
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
alias :before :setup
|
|
39
|
-
|
|
40
|
-
def teardown(&blk)
|
|
41
|
-
self.teardown_blocks << blk
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
alias :after :teardown
|
|
45
|
-
|
|
46
|
-
def should(options, &blk)
|
|
47
|
-
self.should_blocks << ShouldBlock.build(options, self, &blk)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def should_not(options, &blk)
|
|
51
|
-
self.should_blocks << ShouldNotBlock.build(options, self, &blk)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def element(selector)
|
|
55
|
-
recorder = StackRecorder.new(selector)
|
|
56
|
-
self.should_blocks << ElementShouldBlock.new(recorder, self)
|
|
57
|
-
|
|
58
|
-
return recorder
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def count(selector)
|
|
62
|
-
recorder = StackRecorder.new(selector)
|
|
63
|
-
self.should_blocks << CountShouldBlock.new(recorder, self)
|
|
64
|
-
|
|
65
|
-
return recorder
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def assigned(target)
|
|
69
|
-
recorder = StackRecorder.new(target)
|
|
70
|
-
self.should_blocks << AssignedShouldBlock.new(recorder, self)
|
|
71
|
-
|
|
72
|
-
return recorder
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def flashed(kind)
|
|
76
|
-
recorder = StackRecorder.new(kind)
|
|
77
|
-
self.should_blocks << FlashedShouldBlock.new(recorder, self)
|
|
78
|
-
|
|
79
|
-
return recorder
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def full_name
|
|
83
|
-
parent_name = parent.full_name if sub_context?
|
|
84
|
-
return [parent_name, name].join(" ").strip
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def sub_context?
|
|
88
|
-
parent.is_a?(self.class)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def test_unit_class
|
|
92
|
-
sub_context? ? parent.test_unit_class : parent
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def run_all_setup_blocks(binding)
|
|
96
|
-
run_parent_setup_blocks(binding)
|
|
97
|
-
run_current_setup_blocks(binding)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def run_parent_setup_blocks(binding)
|
|
101
|
-
self.parent.run_all_setup_blocks(binding) if sub_context?
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def run_current_setup_blocks(binding)
|
|
105
|
-
setup_blocks.each do |setup_block|
|
|
106
|
-
setup_block.bind(binding).call
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def run_all_teardown_blocks(binding)
|
|
111
|
-
teardown_blocks.reverse.each do |teardown_block|
|
|
112
|
-
teardown_block.bind(binding).call
|
|
113
|
-
end
|
|
114
|
-
self.parent.run_all_teardown_blocks(binding) if sub_context?
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def build
|
|
118
|
-
self.should_blocks.map(&:to_test)
|
|
119
|
-
sub_contexts.each { |context| context.build }
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def method_missing(method, *args, &blk)
|
|
123
|
-
test_unit_class.send(method, *args, &blk)
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class EmailAssertion < Funktional::Assertion
|
|
3
|
-
def initialize(expectations)
|
|
4
|
-
if ActionMailer::Base.deliveries.size < 1
|
|
5
|
-
flunk 'No emails have been sent'
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
email = ActionMailer::Base.deliveries.last
|
|
9
|
-
|
|
10
|
-
expectations.each_key do |key|
|
|
11
|
-
case key
|
|
12
|
-
when :from
|
|
13
|
-
then check_from(expectations[:from], email.from)
|
|
14
|
-
when :to
|
|
15
|
-
then check_to(expectations[:to], email.to)
|
|
16
|
-
when :subject
|
|
17
|
-
then assert_equal expectations[:subject], email.subject
|
|
18
|
-
when :containing
|
|
19
|
-
then check_containing(expectations[:containing], email.body)
|
|
20
|
-
else
|
|
21
|
-
flunk "Assertion key: [#{key}] not recognised"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def check_from(expected_from, email_from)
|
|
27
|
-
if email_from.nil?
|
|
28
|
-
flunk 'email is missing a [from]'
|
|
29
|
-
end
|
|
30
|
-
assert_equal expected_from, email_from[0]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def check_to(expected_to, email_to)
|
|
34
|
-
if email_to.nil?
|
|
35
|
-
flunk 'email is missing a [to]'
|
|
36
|
-
end
|
|
37
|
-
assert_equal expected_to, email_to[0]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def check_containing(should_contain, body)
|
|
41
|
-
if should_contain.is_a? Array
|
|
42
|
-
should_contain.each do |should_i|
|
|
43
|
-
assert_match /#{Regexp.escape(should_i)}/, body
|
|
44
|
-
end
|
|
45
|
-
else
|
|
46
|
-
assert_match /#{Regexp.escape(should_contain)}/, body
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Funktional
|
|
2
|
-
class FlashedAssertion < Funktional::Assertion
|
|
3
|
-
def initialize(symbol)
|
|
4
|
-
@symbol = symbol
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def should_be(expected_value)
|
|
8
|
-
assert_not_nil flash[@symbol], "Flash is empty [#{expected_value}] expected."
|
|
9
|
-
assert_equal expected_value, flash[@symbol]
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|