Skip to content

Commit

Permalink
Add a spec for prefixing nested contexts with the parent name.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Mar 5, 2012
1 parent 02f76e6 commit 8b80d6b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
4 changes: 4 additions & 0 deletions lib/mac_bacon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ def should(*args, &block)
end
end

def describe(*args, &block)
self.class.describe(*args, &block)
end

class << self
attr_reader :name, :block, :context_depth, :specifications

Expand Down
58 changes: 30 additions & 28 deletions test/spec_bacon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,34 +360,36 @@ def the_meaning_of_life
end
end

#describe 'describe arguments' do

#def check(ctx, name)
#ctx.ancestors.should.include Bacon::Context
#ctx.instance_variable_get('@name').should == name
#end

#it 'should work with string' do
#check(describe('string') {},'string')
#end

#it 'should work with symbols' do
#check(describe(:behaviour) {},'behaviour')
#end

#it 'should work with modules' do
#check(describe(Bacon) {},'Bacon')
#end

#it 'should work with namespaced modules' do
#check(describe(Bacon::Context) {},'Bacon::Context')
#end

#it 'should work with multiple arguments' do
#check(describe(Bacon::Context, :empty) {},'Bacon::Context empty')
#end

#end
describe 'describe arguments' do
def check(ctx, name)
ctx.ancestors.should.include Bacon::Context
ctx.instance_variable_get('@name').should == name
end

it 'should work with string' do
check(Kernel.send(:describe, 'string') {}, 'string')
end

it 'should work with symbols' do
check(Kernel.send(:describe, :behaviour) {}, 'behaviour')
end

it 'should work with modules' do
check(Kernel.send(:describe, Bacon) {}, 'Bacon')
end

it 'should work with namespaced modules' do
check(Kernel.send(:describe, Bacon::Context) {}, 'Bacon::Context')
end

it 'should work with multiple arguments' do
check(Kernel.send(:describe, Bacon::Context, :empty) {}, 'Bacon::Context empty')
end

it "prefixes the name of a nested context with that of the parent context" do
check(describe('are nested') {}, 'describe arguments are nested')
end
end


# TODO move to MacBacon specific spec?
Expand Down

0 comments on commit 8b80d6b

Please sign in to comment.