jeremymcanally-context 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestContext < Test::Unit::TestCase
4
+ def test_can_write_tests_without_context
5
+ assert true
6
+ end
7
+
8
+ def test_context_aliases
9
+ [:context, :contexts, :describe, :describes, :group, :specify, :specifies].each do |method_alias|
10
+ assert self.class.respond_to?(method_alias)
11
+ end
12
+ end
13
+
14
+ context "A new context" do
15
+ context "when not nested" do
16
+ before do
17
+ @context = Class.new(Test::Unit::TestCase).context("When testing") do
18
+ def test_this_thing
19
+ true
20
+ end
21
+ end
22
+ end
23
+
24
+ it "should set the context name" do
25
+ assert_equal "When testing", @context.context_name
26
+ end
27
+
28
+ it "should be a Test::Unit::TestCase" do
29
+ assert @context.ancestors.include?(Test::Unit::TestCase)
30
+ end
31
+ end
32
+
33
+ context "when nested" do
34
+ before do
35
+ @context = self.class.context("and we're testing") do
36
+ def self.nested
37
+ @nested
38
+ end
39
+
40
+ @nested = context "should be nested" do
41
+ def test_this_thing
42
+ true
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ it "should set a nested context's name" do
49
+ assert_equal "A new context when nested and we're testing should be nested", @context.nested.context_name
50
+ end
51
+
52
+ it "should also be a Test::Unit::TestCase" do
53
+ assert @context.nested.ancestors.include?(Test::Unit::TestCase)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestCoreExt < Test::Unit::TestCase
4
+ context "A string" do
5
+ it "should be converted to method name" do
6
+ assert :this_is_fun, "this is fun".to_method_name
7
+ end
8
+
9
+ it "should be downcased when converted" do
10
+ assert :this_is_a_blast, "THIS is A BlASt".to_method_name
11
+ end
12
+
13
+ it "should change spaces to _" do
14
+ assert :this_has_been_great, "This has been great".to_method_name
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/context'
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestLifecycle < Test::Unit::TestCase
4
+ context "A before block" do
5
+ it "should define a setup method" do
6
+ self.class.before { true }
7
+ assert self.class.method_defined?(:setup)
8
+ end
9
+ end
10
+
11
+ context "An after block" do
12
+ it "should define a teardown method" do
13
+ self.class.after { true }
14
+ assert self.class.method_defined?(:teardown)
15
+ end
16
+ end
17
+ end
data/test/test_test.rb ADDED
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTest < Test::Unit::TestCase
4
+ def test_test_aliases
5
+ [:test, :it, :should, :tests].each do |method_alias|
6
+ assert self.class.respond_to?(method_alias)
7
+ end
8
+ end
9
+
10
+ context "A test block" do
11
+ it "should create a test_xxx method" do
12
+ self.class.test("should create a test method") { true }
13
+
14
+ assert self.respond_to?(:test_a_test_block_should_create_a_test_method)
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jeremymcanally-context
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy McAnally
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-03 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: If you've ever wanted contexts in your Test::Unit tests, then context is for you. Your tests will be easier to read and write without all the magic and extra code smell!
17
+ email: jeremy@entp.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - History.txt
24
+ - Manifest.txt
25
+ - README.rdoc
26
+ files:
27
+ - README.rdoc
28
+ - Rakefile
29
+ - context.gemspec
30
+ - History.txt
31
+ - License.txt
32
+ - Manifest.txt
33
+ - PostInstall.txt
34
+ - config/hoe.rb
35
+ - config/requirements.rb
36
+ - lib/context.rb
37
+ - lib/context/version.rb
38
+ - lib/context/lifecycle.rb
39
+ - lib/context/suite.rb
40
+ - lib/context/context.rb
41
+ - lib/context/shared_behavior.rb
42
+ - lib/context/test.rb
43
+ - lib/context/core_ext/string.rb
44
+ - setup.rb
45
+ has_rdoc: true
46
+ homepage: http://github.com/jeremymcanally/context
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --main
50
+ - README.rdoc
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.2.0
69
+ signing_key:
70
+ specification_version: 2
71
+ summary: Contexts and DSL sugar for your tests
72
+ test_files:
73
+ - test/test_context.rb
74
+ - test/test_core_ext.rb
75
+ - test/test_lifecycle.rb
76
+ - test/test_test.rb
77
+ - test/test_helper.rb