riot 0.9.10 → 0.9.11

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.10
1
+ 0.9.11
@@ -71,12 +71,12 @@ module Riot
71
71
  # Asserts that an instance variable is defined for the result of the assertion. Value of instance
72
72
  # variable is expected to not be nil
73
73
  # setup { User.new(:email => "foo@bar.baz") }
74
- # asserts("foo") { topic }.assigns(:email)
74
+ # topic.assigns(:email)
75
75
  #
76
76
  # If a value is provided in addition to the variable name, the actual value of the instance variable
77
77
  # must equal the expected value
78
- # setup { User.new(:emmail => "foo@bar.baz") }
79
- # asserts("foo") { topic }.assigns(:email, "foo@bar.baz")
78
+ # setup { User.new(:email => "foo@bar.baz") }
79
+ # topic.assigns(:email, "foo@bar.baz")
80
80
  def assigns(variable, expected_value=nil)
81
81
  actual_value = actual.instance_variable_get("@#{variable}")
82
82
  return fail("expected @#{variable} to be assigned a value") if actual_value.nil?
@@ -4,7 +4,7 @@ module Riot
4
4
  attr_reader :description, :assertions, :situation
5
5
  def initialize(description, reporter, parent=nil, &context_block)
6
6
  @description, @reporter, @parent = description, reporter, parent
7
- @assertions = []
7
+ @setups, @assertions = [], []
8
8
  @situation = Situation.new
9
9
  bootstrap(@situation)
10
10
  instance_eval(&context_block) if block_given? # running the context
@@ -13,8 +13,10 @@ module Riot
13
13
 
14
14
  # Walk it out. Call setup from parent first
15
15
  def bootstrap(a_situation)
16
- run_setup(a_situation, &@parent.bootstrap(a_situation)) if @parent
17
- @setup
16
+ @parent.bootstrap(a_situation).each do |setup_block|
17
+ run_setup(a_situation, &setup_block)
18
+ end if @parent
19
+ @setups
18
20
  end
19
21
 
20
22
  def report
@@ -26,7 +28,8 @@ module Riot
26
28
  # DSLee stuff
27
29
 
28
30
  def setup(&block)
29
- run_setup(situation, &(@setup = block))
31
+ @setups << block
32
+ run_setup(situation, &block)
30
33
  end
31
34
 
32
35
  def context(description, &block) Context.new(description, @reporter, self, &block); end
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{riot}
8
- s.version = "0.9.10"
8
+ s.version = "0.9.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin 'Gus' Knowlden"]
12
- s.date = %q{2009-10-15}
12
+ s.date = %q{2009-10-19}
13
13
  s.description = %q{An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks. Protest the slow test.}
14
14
  s.email = %q{gus@gusg.us}
15
15
  s.extra_rdoc_files = [
@@ -74,3 +74,4 @@ Gem::Specification.new do |s|
74
74
  else
75
75
  end
76
76
  end
77
+
@@ -54,15 +54,15 @@ end # basic context
54
54
 
55
55
  context "nested context" do
56
56
  setup do
57
- @parent_context = Riot::Context.new("foo", Riot::NilReport.new)
58
- @parent_context.setup { @test_counter = 0; @foo = "bar" }
59
- @parent_context.asserts("truthiness") { @test_counter += 1; true }
60
- @parent_context
57
+ test_context = Riot::Context.new("foo", Riot::NilReport.new)
58
+ test_context.setup { @test_counter = 0; @foo = "bar" }
59
+ test_context.asserts("truthiness") { @test_counter += 1; true }
60
+ test_context
61
61
  end
62
62
 
63
63
  context "inner context with own setup" do
64
64
  setup do
65
- test_context = @parent_context.context("baz")
65
+ test_context = topic.context("baz")
66
66
  test_context.setup { @test_counter += 10 }
67
67
  test_context
68
68
  end
@@ -72,7 +72,34 @@ context "nested context" do
72
72
  end
73
73
 
74
74
  context "inner context without its own setup" do
75
- setup { @parent_context.context("bum") }
75
+ setup { topic.context("bum") }
76
76
  asserts("parent setup is called") { topic.situation }.assigns(:foo, "bar")
77
77
  end
78
78
  end
79
+
80
+ #
81
+ # Multiple setups in a context
82
+
83
+ context "multiple setups" do
84
+ setup do
85
+ test_context = Riot::Context.new("foo", Riot::NilReport.new)
86
+ test_context.setup { @foo = "bar" }
87
+ test_context.setup { @baz = "boo" }
88
+ test_context
89
+ end
90
+
91
+ asserts("foo") { topic.situation }.assigns(:foo, "bar")
92
+ asserts("bar") { topic.situation }.assigns(:baz, "boo")
93
+
94
+ context "in the parent of a nested context" do
95
+ setup do
96
+ test_context = topic.context("goo")
97
+ test_context.setup { @goo = "car" }
98
+ test_context
99
+ end
100
+
101
+ asserts("foo") { topic.situation }.assigns(:foo, "bar")
102
+ asserts("bar") { topic.situation }.assigns(:baz, "boo")
103
+ asserts("goo") { topic.situation }.assigns(:goo, "car")
104
+ end # in the parent of a nested context
105
+ end # multiple setups
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin 'Gus' Knowlden
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-15 00:00:00 -05:00
12
+ date: 2009-10-19 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15