coulda 0.6.1 → 0.6.3
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/HISTORY +9 -0
- data/LICENSE +1 -1
- data/Rakefile +0 -2
- data/coulda.gemspec +2 -2
- data/lib/coulda.rb +38 -14
- data/lib/coulda/feature.rb +4 -1
- data/lib/coulda/pending.rb +32 -5
- data/lib/coulda/scenario.rb +8 -3
- data/lib/tasks/tagged_tests.rake +17 -0
- data/test/test_helper.rb +0 -8
- metadata +5 -5
- data/VERSION +0 -1
data/HISTORY
CHANGED
@@ -95,3 +95,12 @@ Cleanup
|
|
95
95
|
0.6.1
|
96
96
|
-----
|
97
97
|
- Requiring coulda automatcally loads coulda/tasks. No longer need to require 'coulda/tasks' to get the Rake task in your Rails app.
|
98
|
+
|
99
|
+
0.6.2
|
100
|
+
-----
|
101
|
+
- Updated call method by name to use class methods so that they, and "macros", may universally be imported via 'extends SomeModule'
|
102
|
+
|
103
|
+
0.6.3
|
104
|
+
-----
|
105
|
+
- Renamed #pending to #coulda_pending to avoid conflicts with Rails 3
|
106
|
+
- Failing test in this release as I stupidly began working on some new features in the master branch. Don't use the new features (they're not documented outside of the new tests) and you'll be fine. ;-)
|
data/LICENSE
CHANGED
@@ -2,7 +2,7 @@ coulda
|
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
5
|
-
Copyright (c) 2009, Evan David Light
|
5
|
+
Copyright (c) 2009, 2010, 2011 Evan David Light
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the "Software"), to deal
|
data/Rakefile
CHANGED
data/coulda.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{coulda}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Evan David Light"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-12-23}
|
13
13
|
s.description = %q{Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse}
|
14
14
|
s.email = %q{evan@tiggerpalace.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/coulda.rb
CHANGED
@@ -1,30 +1,44 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'coulda', 'world')
|
4
|
+
require File.join(File.dirname(__FILE__), 'coulda', 'feature')
|
5
|
+
require File.join(File.dirname(__FILE__), 'coulda', 'scenario')
|
6
|
+
require File.join(File.dirname(__FILE__), 'coulda', 'pending')
|
7
|
+
require File.join(File.dirname(__FILE__), 'coulda', 'vendor', 'constantize')
|
8
|
+
require File.join(File.dirname(__FILE__), 'coulda', 'vendor', 'underscore')
|
9
|
+
require File.join(File.dirname(__FILE__), 'coulda', 'tasks')
|
10
|
+
|
1
11
|
module Coulda
|
2
12
|
SyntaxError = Class.new(StandardError)
|
3
|
-
end
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
13
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require 'coulda/vendor/constantize'
|
12
|
-
require 'coulda/vendor/underscore'
|
13
|
-
require 'coulda/tasks'
|
14
|
+
def Tag(name)
|
15
|
+
@feature_tags ||= []
|
16
|
+
@feature_tags << name.to_s
|
17
|
+
end
|
14
18
|
|
15
|
-
module Kernel
|
16
19
|
# Factory method for Test::Unit::TestCase subclasses
|
17
20
|
def Feature(name, opts = {}, &block)
|
21
|
+
process_command_line_tags
|
22
|
+
|
23
|
+
if @requested_tags && !@requested_tags.empty?
|
24
|
+
if @feature_tags.nil? || !@feature_tags.any? { |f_tag| @requested_tags.include? f_tag}
|
25
|
+
@feature_tags = nil
|
26
|
+
return
|
27
|
+
end
|
28
|
+
end
|
29
|
+
@feature_tags = nil
|
30
|
+
|
18
31
|
test_class = Class.new(opts[:testcase_class] || Coulda.default_testcase_class || Test::Unit::TestCase)
|
32
|
+
World.register_feature(test_class, name)
|
33
|
+
|
19
34
|
Coulda::assign_class_to_const test_class, name
|
20
35
|
test_class.class_eval &block if block_given?
|
21
36
|
test_class.assert_presence_of_intent
|
22
|
-
|
37
|
+
|
38
|
+
|
23
39
|
test_class
|
24
40
|
end
|
25
|
-
end
|
26
41
|
|
27
|
-
module Coulda
|
28
42
|
def self.default_testcase_class=(klass)
|
29
43
|
unless klass.is_a?(Class) && klass.ancestors.include?(Test::Unit::TestCase)
|
30
44
|
raise Exception, "Can only provide a Test::Unit::TestCase"
|
@@ -44,6 +58,16 @@ module Coulda
|
|
44
58
|
titleized_underscored_name = base_name.super_custom_underscore.gsub(/\b('?[a-z])/) { $1.upcase }
|
45
59
|
Object.const_set(titleized_underscored_name, test_class)
|
46
60
|
end
|
61
|
+
|
62
|
+
def process_command_line_tags
|
63
|
+
unless @processed_cmd_line_args
|
64
|
+
@processed_cmd_line_args = true
|
65
|
+
tags = ARGV.inject([]) { |m, a| m << a if a =~ /^tags=/; m }
|
66
|
+
@requested_tags = tags.map { |t| t.split("=")[1].split(",") }.flatten
|
67
|
+
end
|
68
|
+
end
|
47
69
|
end
|
48
70
|
|
49
71
|
include ::Coulda
|
72
|
+
|
73
|
+
|
data/lib/coulda/feature.rb
CHANGED
@@ -34,7 +34,7 @@ module Test
|
|
34
34
|
step = block
|
35
35
|
end
|
36
36
|
caller[0] =~ (/(.*):(.*)(:in)?/)
|
37
|
-
stmt = { :type => :#{stmt}, :text => text, :block => step, :file => $1, :line => $2 }
|
37
|
+
stmt = { :type => :#{stmt}, :text => text, :block => step, :file => $1, :line => $2, :scenario => current_scenario }
|
38
38
|
if text.is_a? Symbol
|
39
39
|
stmt[:method] = text
|
40
40
|
end
|
@@ -43,6 +43,9 @@ module Test
|
|
43
43
|
HERE
|
44
44
|
end
|
45
45
|
|
46
|
+
def Tag(name)
|
47
|
+
end
|
48
|
+
|
46
49
|
# Creates a Scenario instance and adds it to the Feature
|
47
50
|
def self.Scenario(scenario_name, &block)
|
48
51
|
@scenarios ||=[]
|
data/lib/coulda/pending.rb
CHANGED
@@ -2,23 +2,50 @@ module Test
|
|
2
2
|
module Unit
|
3
3
|
class TestCase
|
4
4
|
@@pending_cases = []
|
5
|
-
@@
|
5
|
+
@@error_contexts = []
|
6
|
+
@@pending_at_exit = false
|
7
|
+
@@exception_at_exit = false
|
6
8
|
|
7
9
|
# Loosely based upon Jeremy McAnally's pending
|
8
10
|
|
9
|
-
def
|
10
|
-
@@pending_cases << [scenario, statement]
|
11
|
+
def coulda_pending(txt)
|
11
12
|
print "P"
|
13
|
+
@@pending_cases << txt
|
12
14
|
|
13
15
|
@@at_exit ||= begin
|
14
16
|
at_exit do
|
15
17
|
puts "\nPending Cases:"
|
16
|
-
@@pending_cases.each do |
|
17
|
-
puts
|
18
|
+
@@pending_cases.each do |msg|
|
19
|
+
puts msg
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
24
|
+
|
25
|
+
def handle_exception(e, params = {})
|
26
|
+
stmt = params[:for_statement]
|
27
|
+
|
28
|
+
print "E"
|
29
|
+
@@error_contexts << params.merge(:exception => e)
|
30
|
+
|
31
|
+
@@exception_at_exit ||= begin
|
32
|
+
at_exit do
|
33
|
+
puts
|
34
|
+
puts "Exceptions"
|
35
|
+
puts "----------"
|
36
|
+
|
37
|
+
@@error_contexts.each_with_index do |ctx, i|
|
38
|
+
puts
|
39
|
+
puts "(#{i+1}) Feature: #{stmt[:scenario].feature.name}"
|
40
|
+
puts "Scenario: #{stmt[:scenario].name}"
|
41
|
+
puts "#{stmt[:type]} '#{stmt[:text]}'"
|
42
|
+
puts "In #{stmt[:file]} on line #{stmt[:line]}"
|
43
|
+
puts e.backtrace
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
22
49
|
end
|
23
50
|
end
|
24
51
|
end
|
data/lib/coulda/scenario.rb
CHANGED
@@ -16,23 +16,28 @@ module Coulda
|
|
16
16
|
def pending?
|
17
17
|
statements.empty? || has_pending_statements?
|
18
18
|
end
|
19
|
+
|
20
|
+
def feature
|
21
|
+
@my_feature
|
22
|
+
end
|
19
23
|
|
20
24
|
private
|
21
25
|
|
22
26
|
def create_and_provision_test_method_using(&block)
|
23
27
|
collect_scenario_statements_from &block
|
24
28
|
define_test_method_using do
|
25
|
-
self.class.current_scenario
|
29
|
+
scenario = self.class.current_scenario
|
30
|
+
scenario.statements.each do |stmt|
|
26
31
|
if stmt[:method]
|
27
32
|
if stmt[:block]
|
28
33
|
raise Exception.new "Passing a block to a method called-by-name is currently unhandle"
|
29
34
|
else
|
30
|
-
self.__send__(stmt[:method])
|
35
|
+
self.class.__send__(stmt[:method])
|
31
36
|
end
|
32
37
|
elsif stmt[:block]
|
33
38
|
self.instance_eval &(stmt[:block])
|
34
39
|
else
|
35
|
-
|
40
|
+
coulda_pending "#{stmt[:file]}:#{stmt[:line]}: Scenario '#{scenario.name}': #{stmt[:type]} '#{stmt[:text]}'"
|
36
41
|
break
|
37
42
|
end
|
38
43
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
namespace :coulda do
|
4
|
+
desc "Execute tagged tests only"
|
5
|
+
task :tagged_tests, :tag do |task, tag|
|
6
|
+
ARGV << "tags=#{tag["tag"]}"
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift("test")
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
test_files = Dir.glob(File.join('test', '**', '*_test.rb'))
|
13
|
+
test_files.each do |file|
|
14
|
+
require file
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coulda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 3
|
10
|
+
version: 0.6.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Evan David Light
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-23 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -45,8 +45,8 @@ files:
|
|
45
45
|
- LICENSE
|
46
46
|
- Rakefile
|
47
47
|
- README.rdoc
|
48
|
-
- VERSION
|
49
48
|
- lib/tasks/print_features.rake
|
49
|
+
- lib/tasks/tagged_tests.rake
|
50
50
|
- test/feature_test.rb
|
51
51
|
- test/scenario_test.rb
|
52
52
|
- test/test_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.5.3
|