|
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 |
| 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 commit comments