A SharedExampleGroup can be created within another ExampleGroup.
git-svn-id: http://rspec.rubyforge.org/svn/trunk@3296 410327ef-2207-0410-a325-f78bbcb22a5a
| |   |
| 1 | | * ExampleGroupMethods#xspecify aliases #xit |
| 2 | | |
| 3 | 1 | == Version 1.1.4 (trunk) |
| 4 | 2 | |
| 5 | 3 | * Applied patch from Bob Cotton: Nested ExampleGroups do not have a spec_path. Closes #224. |
| … | … | |
| 5 | 5 | * Allow any type of render in view specs. Closes #57. |
| 6 | 6 | * Applied patch from Coda Hale to get rspec calling autotest's :red hook. Closes #279. |
| 7 | 7 | * Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271. |
| 8 | * ExampleGroupMethods#xspecify aliases #xit |
| 9 | * A SharedExampleGroup can be created within another ExampleGroup. |
| 8 | 10 | |
| 9 | 11 | == Version 1.1.3 |
| 10 | 12 | |
| toggle raw diff |
--- a/rspec/CHANGES
+++ b/rspec/CHANGES
@@ -1,5 +1,3 @@
-* ExampleGroupMethods#xspecify aliases #xit
-
== Version 1.1.4 (trunk)
* Applied patch from Bob Cotton: Nested ExampleGroups do not have a spec_path. Closes #224.
@@ -7,6 +5,8 @@
* Allow any type of render in view specs. Closes #57.
* Applied patch from Coda Hale to get rspec calling autotest's :red hook. Closes #279.
* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
+* ExampleGroupMethods#xspecify aliases #xit
+* A SharedExampleGroup can be created within another ExampleGroup.
== Version 1.1.3
|
| |   |
| 36 | 36 | def describe(*args, &example_group_block) |
| 37 | 37 | args << {} unless Hash === args.last |
| 38 | 38 | if example_group_block |
| 39 | | args.last[:spec_path] = eval("caller(0)[1]", example_group_block) unless args.last[:spec_path] |
| 40 | | self.subclass("Subclass") do |
| 41 | | describe(*args) |
| 42 | | module_eval(&example_group_block) |
| 39 | params = args.last |
| 40 | params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path] |
| 41 | if params[:shared] |
| 42 | SharedExampleGroup.new(*args, &example_group_block) |
| 43 | else |
| 44 | self.subclass("Subclass") do |
| 45 | describe(*args) |
| 46 | module_eval(&example_group_block) |
| 47 | end |
| 43 | 48 | end |
| 44 | 49 | else |
| 45 | 50 | set_description(*args) |
| toggle raw diff |
--- a/rspec/lib/spec/example/example_group_methods.rb
+++ b/rspec/lib/spec/example/example_group_methods.rb
@@ -36,10 +36,15 @@ module Spec
def describe(*args, &example_group_block)
args << {} unless Hash === args.last
if example_group_block
- args.last[:spec_path] = eval("caller(0)[1]", example_group_block) unless args.last[:spec_path]
- self.subclass("Subclass") do
- describe(*args)
- module_eval(&example_group_block)
+ params = args.last
+ params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path]
+ if params[:shared]
+ SharedExampleGroup.new(*args, &example_group_block)
+ else
+ self.subclass("Subclass") do
+ describe(*args)
+ module_eval(&example_group_block)
+ end
end
else
set_description(*args) |
| |   |
| 6 | 6 | TINY = 3 |
| 7 | 7 | RELEASE_CANDIDATE = nil |
| 8 | 8 | |
| 9 | | BUILD_TIME_UTC = 20080211053912 |
| 9 | BUILD_TIME_UTC = 20080211062900 |
| 10 | 10 | |
| 11 | 11 | STRING = [MAJOR, MINOR, TINY].join('.') |
| 12 | 12 | TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_') |
| toggle raw diff |
--- a/rspec/lib/spec/version.rb
+++ b/rspec/lib/spec/version.rb
@@ -6,7 +6,7 @@ module Spec
TINY = 3
RELEASE_CANDIDATE = nil
- BUILD_TIME_UTC = 20080211053912
+ BUILD_TIME_UTC = 20080211062900
STRING = [MAJOR, MINOR, TINY].join('.')
TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
|
| |   |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | describe "#describe" do |
| 28 | | attr_reader :child_example_group |
| 29 | | before do |
| 30 | | @child_example_group = @example_group.describe("Another ExampleGroup") do |
| 31 | | it "should pass" do |
| 32 | | true.should be_true |
| 28 | describe "when creating an ExampleGroup" do |
| 29 | attr_reader :child_example_group |
| 30 | before do |
| 31 | @child_example_group = @example_group.describe("Another ExampleGroup") do |
| 32 | it "should pass" do |
| 33 | true.should be_true |
| 34 | end |
| 33 | 35 | end |
| 34 | 36 | end |
| 35 | | end |
| 36 | 37 | |
| 37 | | it "should create a subclass of the ExampleGroup when passed a block" do |
| 38 | | child_example_group.superclass.should == @example_group |
| 39 | | @options.example_groups.should include(child_example_group) |
| 38 | it "should create a subclass of the ExampleGroup when passed a block" do |
| 39 | child_example_group.superclass.should == @example_group |
| 40 | @options.example_groups.should include(child_example_group) |
| 41 | end |
| 42 | |
| 43 | it "should not inherit examples" do |
| 44 | child_example_group.examples.length.should == 1 |
| 45 | end |
| 40 | 46 | end |
| 41 | 47 | |
| 42 | | it "should not inherit examples" do |
| 43 | | child_example_group.examples.length.should == 1 |
| 48 | describe "when creating a SharedExampleGroup" do |
| 49 | attr_reader :name, :shared_example_group |
| 50 | before do |
| 51 | @name = "A Shared ExampleGroup" |
| 52 | @shared_example_group = @example_group.describe(name, :shared => true) do |
| 53 | it "should pass" do |
| 54 | true.should be_true |
| 55 | end |
| 56 | end |
| 57 | end |
| 58 | |
| 59 | after do |
| 60 | SharedExampleGroup.shared_example_groups.delete_if do |registered_shared_example_group| |
| 61 | registered_shared_example_group == shared_example_group |
| 62 | end |
| 63 | end |
| 64 | |
| 65 | it "should create a SharedExampleGroup" do |
| 66 | SharedExampleGroup.find_shared_example_group(name).should == shared_example_group |
| 67 | end |
| 44 | 68 | end |
| 69 | |
| 45 | 70 | end |
| 46 | 71 | |
| 47 | 72 | describe "#it" do |
| toggle raw diff |
--- a/rspec/spec/spec/example/example_group_methods_spec.rb
+++ b/rspec/spec/spec/example/example_group_methods_spec.rb
@@ -25,23 +25,48 @@ module Spec
end
describe "#describe" do
- attr_reader :child_example_group
- before do
- @child_example_group = @example_group.describe("Another ExampleGroup") do
- it "should pass" do
- true.should be_true
+ describe "when creating an ExampleGroup" do
+ attr_reader :child_example_group
+ before do
+ @child_example_group = @example_group.describe("Another ExampleGroup") do
+ it "should pass" do
+ true.should be_true
+ end
end
end
- end
- it "should create a subclass of the ExampleGroup when passed a block" do
- child_example_group.superclass.should == @example_group
- @options.example_groups.should include(child_example_group)
+ it "should create a subclass of the ExampleGroup when passed a block" do
+ child_example_group.superclass.should == @example_group
+ @options.example_groups.should include(child_example_group)
+ end
+
+ it "should not inherit examples" do
+ child_example_group.examples.length.should == 1
+ end
end
- it "should not inherit examples" do
- child_example_group.examples.length.should == 1
+ describe "when creating a SharedExampleGroup" do
+ attr_reader :name, :shared_example_group
+ before do
+ @name = "A Shared ExampleGroup"
+ @shared_example_group = @example_group.describe(name, :shared => true) do
+ it "should pass" do
+ true.should be_true
+ end
+ end
+ end
+
+ after do
+ SharedExampleGroup.shared_example_groups.delete_if do |registered_shared_example_group|
+ registered_shared_example_group == shared_example_group
+ end
+ end
+
+ it "should create a SharedExampleGroup" do
+ SharedExampleGroup.find_shared_example_group(name).should == shared_example_group
+ end
end
+
end
describe "#it" do |