coulda 0.5.3 → 0.5.5

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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'shoulda'
4
+ gem 'rr'
data/HISTORY CHANGED
@@ -83,3 +83,11 @@ Cleanup
83
83
  0.5.3
84
84
  -----
85
85
  - coulda:print_features better indicates which scenarios and which steps are pending
86
+
87
+ 0.5.4
88
+ -----
89
+ - Actually removing dependency from Jeremy McAnally's "pending" from the gemspec (woops)
90
+
91
+ 0.5.5
92
+ -----
93
+ - Adds Coulda#default_testcase_class and mutator to set a single testcase_class instead of Test::Unit::TestCase
@@ -21,6 +21,8 @@ Easy as pie.
21
21
  require 'coulda'
22
22
  include Coulda
23
23
 
24
+ Coulda.default_testcase_class = ActiveSupport::TestCase
25
+
24
26
  Feature "feature name" do
25
27
  in_order_to "foo"
26
28
  as_a "bar"
data/Rakefile CHANGED
@@ -1,39 +1,18 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
- require 'rake/rdoctask'
5
- require 'rake/gempackagetask'
6
-
7
- require 'lib/coulda/tasks'
8
4
 
9
5
  gem 'shoulda'
10
6
  require 'shoulda'
11
7
 
12
8
  # Test::Unit::UI::VERBOSE
13
- test_files_pattern = 'test/**/*_test.rb'
14
- src_files_pattern = 'src/**/*.rb'
15
-
16
- Rake::TestTask.new do |t|
17
- src_files = Dir[src_files_pattern]
9
+ Rake::TestTask.new('test') do |t|
10
+ t.libs << 'test'
11
+ src_files = Dir.glob('src/**/*.rb')
18
12
  src_files.each { |f| puts f; require f[0...-3] }
19
- t.pattern = test_files_pattern
20
- t.verbose = false
13
+ t.pattern = 'test/**/*_test.rb'
14
+ t.verbose = true
21
15
  end
22
16
 
23
- begin
24
- require 'jeweler'
25
- Jeweler::Tasks.new do |s|
26
- s.name = "coulda"
27
- s.authors = ["Evan David Light"]
28
- s.email = "evan@tiggerpalace.com"
29
- s.summary = "Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse"
30
- s.homepage = "http://evan.tiggerpalace.com/"
31
- s.description = "Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse"
32
- end
33
- rescue LoadError
34
- puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gems.github.com"
35
- end
36
-
37
-
38
17
  desc 'Default: run tests.'
39
18
  task :default => 'test'
@@ -5,70 +5,28 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{coulda}
8
- s.version = "0.5.3"
8
+ s.version = "0.5.5"
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{2009-12-08}
12
+ s.date = %q{2010-09-10}
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 = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
18
18
  ]
19
- s.files = [
20
- "HISTORY",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "coulda.gemspec",
26
- "example/feature_with_pending_scenario.rb",
27
- "example/macros_in_a_module.rb",
28
- "example/pending_feature.rb",
29
- "example/pending_feature_with_purpose.rb",
30
- "example/sample.rb",
31
- "example/simple_reuse_via_method.rb",
32
- "example/simple_scenario.rb",
33
- "geminstaller.yml",
34
- "lib/coulda.rb",
35
- "lib/coulda/feature.rb",
36
- "lib/coulda/scenario.rb",
37
- "lib/coulda/tasks.rb",
38
- "lib/coulda/pending.rb",
39
- "lib/coulda/tasks/print_features.rake",
40
- "lib/coulda/vendor/constantize.rb",
41
- "lib/coulda/vendor/underscore.rb",
42
- "lib/coulda/world.rb",
43
- "test/feature_test.rb",
44
- "test/integration/using_coulda_test.rb",
45
- "test/regression/issue_1_test.rb",
46
- "test/regression/pending_scenarios_test.rb",
47
- "test/scenario_test.rb",
48
- "test/test_helper.rb"
49
- ]
50
- s.homepage = %q{http://evan.tiggerpalace.com/}
19
+ s.files = Dir.glob('lib/**/*.rb') + Dir.glob('*')
20
+ s.homepage = %q{http://coulda.tiggerpalace.com}
51
21
  s.rdoc_options = ["--charset=UTF-8"]
52
22
  s.require_paths = ["lib"]
53
- s.rubygems_version = %q{1.3.5}
54
- s.summary = %q{Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse}
55
- s.test_files = [
56
- "test/feature_test.rb",
57
- "test/integration/using_coulda_test.rb",
58
- "test/regression/issue_1_test.rb",
59
- "test/regression/pending_scenarios_test.rb",
60
- "test/scenario_test.rb",
61
- "test/test_helper.rb"
62
- ]
63
- s.add_dependency 'pending', '>= 0.1.1'
23
+ s.rubygems_version = %q{1.3.7}
24
+ s.summary = %q{Test::Unit-based acceptance testing DSL}
25
+ s.test_files = Dir.glob('test/**')
64
26
 
65
27
  if s.respond_to? :specification_version then
66
28
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
29
  s.specification_version = 3
68
-
69
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
70
- else
71
- end
72
30
  else
73
31
  end
74
32
  end
@@ -14,7 +14,7 @@ require 'coulda/vendor/underscore'
14
14
  module Kernel
15
15
  # Factory method for Test::Unit::TestCase subclasses
16
16
  def Feature(name, opts = {}, &block)
17
- test_class = Class.new(opts[:testcase_class] || Test::Unit::TestCase)
17
+ test_class = Class.new(opts[:testcase_class] || Coulda.default_testcase_class || Test::Unit::TestCase)
18
18
  Coulda::assign_class_to_const test_class, name
19
19
  test_class.class_eval &block if block_given?
20
20
  test_class.assert_presence_of_intent
@@ -24,6 +24,17 @@ module Kernel
24
24
  end
25
25
 
26
26
  module Coulda
27
+ def self.default_testcase_class=(klass)
28
+ unless klass.is_a?(Class) && klass.ancestors.include?(Test::Unit::TestCase)
29
+ raise Exception, "Can only provide a Test::Unit::TestCase"
30
+ end
31
+ @class = klass
32
+ end
33
+
34
+ def self.default_testcase_class
35
+ @class
36
+ end
37
+
27
38
  def assign_class_to_const(test_class, potential_const)
28
39
  base_name = potential_const
29
40
  if potential_const !~ /^[a-zA-Z]/
@@ -1,10 +1,23 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
1
+ require 'test_helper'
2
2
 
3
3
  class FeatureTest < Test::Unit::TestCase
4
4
 
5
- should "be able to subclass any child class of TestCase" do
5
+ should "be able to specify a default TestCase class to subclass for all Features" do
6
6
  MyTestCase = Class.new(Test::Unit::TestCase)
7
- feature = Feature "a child class", :testcase_class => MyTestCase
7
+ Coulda.default_testcase_class = MyTestCase
8
+ feature = Feature "a child class"
9
+ assert feature.ancestors.include? MyTestCase
10
+ end
11
+
12
+ should "raise if the default TestCase class is not a Class" do
13
+ assert_raises Exception do
14
+ Coulda.default_testcase_class = "ohai"
15
+ end
16
+ end
17
+
18
+ should "be able to subclass any child class of TestCase" do
19
+ MyTestCase2 = Class.new(Test::Unit::TestCase)
20
+ feature = Feature "another child class", :testcase_class => MyTestCase2
8
21
  assert feature.ancestors.include? Test::Unit::TestCase
9
22
  end
10
23
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
1
+ require "test_helper"
2
2
 
3
3
  class ScenarioTest < Test::Unit::TestCase
4
4
  context "A Scenario" do
@@ -2,7 +2,6 @@ require 'test/unit'
2
2
  require 'rubygems' if RUBY_VERSION != "1.9.1"
3
3
  require 'shoulda'
4
4
 
5
- $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
6
5
  require 'coulda'
7
6
 
8
7
  include Coulda
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ hash: 1
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 5
10
+ version: 0.5.5
5
11
  platform: ruby
6
12
  authors:
7
13
  - Evan David Light
@@ -9,19 +15,10 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-08 00:00:00 -05:00
18
+ date: 2010-09-10 00:00:00 -04:00
13
19
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: pending
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.1.1
24
- version:
20
+ dependencies: []
21
+
25
22
  description: Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse
26
23
  email: evan@tiggerpalace.com
27
24
  executables: []
@@ -32,37 +29,28 @@ extra_rdoc_files:
32
29
  - LICENSE
33
30
  - README.rdoc
34
31
  files:
35
- - HISTORY
36
- - LICENSE
37
- - README.rdoc
38
- - Rakefile
39
- - VERSION
40
- - coulda.gemspec
41
- - example/feature_with_pending_scenario.rb
42
- - example/macros_in_a_module.rb
43
- - example/pending_feature.rb
44
- - example/pending_feature_with_purpose.rb
45
- - example/sample.rb
46
- - example/simple_reuse_via_method.rb
47
- - example/simple_scenario.rb
48
- - geminstaller.yml
49
- - lib/coulda.rb
50
32
  - lib/coulda/feature.rb
33
+ - lib/coulda/pending.rb
51
34
  - lib/coulda/scenario.rb
52
35
  - lib/coulda/tasks.rb
53
- - lib/coulda/pending.rb
54
- - lib/coulda/tasks/print_features.rake
55
36
  - lib/coulda/vendor/constantize.rb
56
37
  - lib/coulda/vendor/underscore.rb
57
38
  - lib/coulda/world.rb
39
+ - lib/coulda.rb
40
+ - coulda-0.5.5.gem
41
+ - coulda.gemspec
42
+ - Gemfile
43
+ - geminstaller.yml
44
+ - HISTORY
45
+ - LICENSE
46
+ - Rakefile
47
+ - README.rdoc
48
+ - VERSION
58
49
  - test/feature_test.rb
59
- - test/integration/using_coulda_test.rb
60
- - test/regression/issue_1_test.rb
61
- - test/regression/pending_scenarios_test.rb
62
50
  - test/scenario_test.rb
63
51
  - test/test_helper.rb
64
52
  has_rdoc: true
65
- homepage: http://evan.tiggerpalace.com/
53
+ homepage: http://coulda.tiggerpalace.com
66
54
  licenses: []
67
55
 
68
56
  post_install_message:
@@ -71,28 +59,31 @@ rdoc_options:
71
59
  require_paths:
72
60
  - lib
73
61
  required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
74
63
  requirements:
75
64
  - - ">="
76
65
  - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
77
69
  version: "0"
78
- version:
79
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
80
72
  requirements:
81
73
  - - ">="
82
74
  - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
83
78
  version: "0"
84
- version:
85
79
  requirements: []
86
80
 
87
81
  rubyforge_project:
88
- rubygems_version: 1.3.5
82
+ rubygems_version: 1.3.7
89
83
  signing_key:
90
84
  specification_version: 3
91
- summary: Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse
85
+ summary: Test::Unit-based acceptance testing DSL
92
86
  test_files:
93
87
  - test/feature_test.rb
94
- - test/integration/using_coulda_test.rb
95
- - test/regression/issue_1_test.rb
96
- - test/regression/pending_scenarios_test.rb
97
88
  - test/scenario_test.rb
98
89
  - test/test_helper.rb
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
- require 'coulda'
3
- include Coulda
4
-
5
- Feature "A pending feature" do
6
- in_order_to "accomplsih something else"
7
- as_a "user"
8
- i_want_to "do something"
9
-
10
- Scenario "that is pending"
11
- end
12
-
13
-
@@ -1,38 +0,0 @@
1
- require 'rubygems'
2
- require 'coulda'
3
- include Coulda
4
-
5
- module MyMacros
6
- def given_something_without_a_value
7
- Given "something without a value" do
8
- @no_value = nil
9
- end
10
- end
11
-
12
- def assert_variable_has_a_value
13
- assert(@no_value)
14
- end
15
- end
16
-
17
- Feature "Painfully obvious" do
18
- extend MyMacros
19
-
20
- in_order_to "demonstrate a simple test"
21
- as_a "coulda developer"
22
- i_want_to "provide a straight-forward scenario"
23
-
24
-
25
- Scenario "Describing something obvious" do
26
- given_something_without_a_value
27
-
28
- When "I give it a value" do
29
- @no_value = true
30
- end
31
-
32
- Then "it should have a value" do
33
- assert_variable_has_a_value
34
- end
35
- end
36
- end
37
-
38
-
@@ -1,5 +0,0 @@
1
- require 'rubygems'
2
- require 'coulda'
3
- include Coulda
4
-
5
- Feature "A pending feature"
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'coulda'
3
- include Coulda
4
-
5
- Feature "A pending feature" do
6
- in_order_to "accomplish something else"
7
- as_a "user"
8
- i_want_to "do something"
9
- end
10
-
@@ -1,33 +0,0 @@
1
- require 'rubygems'
2
- require 'coulda'
3
- include Coulda
4
-
5
- Feature "feature name" do
6
- in_order_to "foo"
7
- as_a "bar"
8
- i_want_to "blech"
9
-
10
- def something
11
- end
12
-
13
- def expectation
14
- end
15
-
16
- Scenario "pending scenario"
17
-
18
- Scenario "another scenario" do
19
- Given "a pending prereq"
20
- When "something happens" do
21
- something
22
- end
23
- Then "expect something else" do
24
- expectation
25
- end
26
- end
27
-
28
- Scenario "that is live" do
29
- Given "foo" do; end
30
- When "bar" do; end
31
- Then "blech" do; end
32
- end
33
- end
@@ -1,29 +0,0 @@
1
- require 'rubygems'
2
- require 'coulda'
3
- include Coulda
4
-
5
- Feature "Painfully obvious" do
6
- in_order_to "demonstrate a simple test"
7
- as_a "coulda developer"
8
- i_want_to "provide a straight-forward scenario"
9
-
10
- def something_without_a_value
11
- @no_value = nil
12
- end
13
-
14
- Scenario "Describing something obvious" do
15
- Given "something without a value" do
16
- something_without_a_value
17
- end
18
-
19
- When "I give it a value" do
20
- @no_value = true
21
- end
22
-
23
- Then "it should have a value" do
24
- assert(@no_value)
25
- end
26
- end
27
- end
28
-
29
-
@@ -1,25 +0,0 @@
1
- require 'rubygems'
2
- require 'coulda'
3
- include Coulda
4
-
5
- Feature "Painfully obvious" do
6
- in_order_to "demonstrate a simple test"
7
- as_a "coulda developer"
8
- i_want_to "provide a straight-forward scenario"
9
-
10
- Scenario "Describing something obvious" do
11
- Given "something without a value" do
12
- @no_value = nil
13
- end
14
-
15
- When "I give it a value" do
16
- @no_value = true
17
- end
18
-
19
- Then "it should have a value" do
20
- assert(@no_value)
21
- end
22
- end
23
- end
24
-
25
-
@@ -1,38 +0,0 @@
1
- namespace :coulda do
2
- desc "Print all features as plain text"
3
- task :print_features do
4
-
5
- $LOAD_PATH.unshift("test")
6
-
7
- require 'test/unit'
8
-
9
- # bug in test unit. Set to true to stop from running.
10
- Test::Unit.run = true
11
-
12
- require 'coulda'
13
-
14
- test_files = Dir.glob(File.join('test', '**', '*_test.rb'))
15
- test_files.each do |file|
16
- load file
17
- end
18
-
19
- Coulda::World.features.each do |feature, name|
20
- puts "Feature: #{name}"
21
- puts " In order to #{feature.in_order_to}" if feature.in_order_to
22
- puts " As a #{feature.as_a}" if feature.as_a
23
- puts " I want to #{feature.i_want_to}" if feature.i_want_to
24
- feature.scenarios.each do |scenario|
25
- puts
26
- print " "
27
- print "(**PENDING**) " if scenario.pending?
28
- puts "Scenario: #{scenario.name}"
29
- scenario.statements.each do |stmt|
30
- print " "
31
- print "(**PENDING**) " unless stmt[:block]
32
- puts "#{stmt[:type].to_s} #{stmt[:text]}"
33
- end
34
- end
35
- puts
36
- end
37
- end
38
- end
@@ -1,57 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "test_helper")
2
-
3
- require 'rr'
4
-
5
- Feature "Using Coulda", :testcase_class => Test::Unit::TestCase do
6
- include RR::Adapters::TestUnit
7
-
8
- in_order_to "perform lightweight integration/acceptance testing with Coulda"
9
- as_a "developer"
10
- i_want_to "have typical Coulda usage work"
11
-
12
- def some_method; end
13
-
14
- def prove_methods_from_then_invokes_method_on_feature
15
- assert true
16
- end
17
-
18
- Scenario "A pending scenario with a Given/When/Then without a block" do
19
- Given "this scenario which should be pending" do
20
- mock(self).pending(anything, anything).times(1)
21
- end
22
- When "an event happens"
23
- Then "should not error/fail because it is pending" do; end
24
- end
25
-
26
- Scenario "A scenario without a When" do
27
- Given "a scenario calling a Feature instance method" do; end
28
- Then "should pass if the method does not fail/error" do
29
- prove_methods_from_then_invokes_method_on_feature
30
- end
31
- end
32
-
33
- Scenario "that is live" do
34
- Given "no prerequisites" do; end
35
- When "no events" do; end
36
- Then "should pass" do; end
37
- end
38
-
39
- Scenario "A scenario with a lot of Ands" do
40
- Given "no prerequisites" do; end
41
- And "some more lack of prerequisites" do; end
42
- When "something doesn't happen" do; end
43
- And "something else doesn't happen" do; end
44
- Then "something else" do; end
45
- And "should pass" do; end
46
- end
47
-
48
- Scenario "A scenario that invokes a method by name" do
49
- Given "a method" do
50
- mock(self).some_method
51
- end
52
-
53
- When :some_method
54
-
55
- Then "'some_method' should have been called" do; end
56
- end
57
- end
@@ -1,39 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "test_helper")
2
-
3
- require 'rr'
4
-
5
- module GivenSomething
6
- def given_something
7
- Given "something" do; end
8
- end
9
- end
10
-
11
- # http://github.com/elight/coulda/issues#issue/1
12
- class Issue1Test < Test::Unit::TestCase
13
- include RR::Adapters::TestUnit
14
-
15
- context "A Feature that has a Scenario that invokes a 'Given/When/Then' called from a method" do
16
- setup do
17
- stub(self).pending { raise Exception.new }
18
-
19
- @feature_without_errors = Feature "Issue 1 feature" do
20
- extend GivenSomething
21
-
22
- in_order_to "foo"
23
- as_a "bar"
24
- i_want_to "blech"
25
-
26
- Scenario "my scenario" do
27
- given_something
28
- When "the when" do; end
29
- Then "the then" do; end
30
- end
31
- end
32
- end
33
-
34
- should "pass" do
35
- assert(run_feature(@feature_without_errors))
36
- end
37
- end
38
- end
39
-
@@ -1,31 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "test_helper")
2
- require 'rr'
3
-
4
- # http://github.com/elight/coulda/issues#issue/1
5
- class PendingScenariosTest < Test::Unit::TestCase
6
- include RR::Adapters::TestUnit
7
-
8
- context "A Scenario that has at least one pending step" do
9
- @@counter = 0
10
- setup do
11
- @scenario = nil
12
- @feature_without_errors = Feature "with a pending scenario step #{@@counter}" do
13
- include RR::Adapters::TestUnit
14
-
15
- @scenario = Scenario "my scenario" do
16
- Given "this scenario that will call #pending because it has a pending step" do
17
- mock(self).pending
18
- end
19
- When "I have this pending step"
20
- Then "the test should pass anyway because I mocked pending"
21
- end
22
- @@counter += 1
23
- end
24
- end
25
-
26
- should "pass" do
27
- assert(run_feature(@feature_without_errors))
28
- end
29
- end
30
- end
31
-