Skip to content

Commit

Permalink
Added missing configuration for assign shams.
Browse files Browse the repository at this point in the history
  • Loading branch information
panthomakos committed Jun 13, 2012
1 parent e8cebb7 commit 44ae4ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/sham/config.rb
@@ -1,4 +1,5 @@
require 'sham/shammable'
require 'sham/config/assign'
require 'sham/config/attributes'
require 'sham/config/parameters'
require 'sham/config/empty'
Expand Down Expand Up @@ -26,6 +27,10 @@ def initialize klass, name
@name = name
end

def assign(&config)
@klass.add_sham_config(@name, Sham::Config::Assign.new(config))
end

def attributes(&config)
@klass.add_sham_config(@name, Sham::Config::Attributes.new(config))
end
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/sham/config_spec.rb
Expand Up @@ -151,6 +151,17 @@ class B; end
end
end

it 'configures assign shams' do
Sham.config(parent) do |c|
c.assign{ { :first => 'first' } }
end

instance = stub
parent.stub(:new){ instance }
instance.should_receive(:first=).with('first')
parent.sham!.should == instance
end

it 'configures attribute shams' do
attributes = { :first => 'first', :last => 'last' }
Sham.config(parent) do |c|
Expand Down

0 comments on commit 44ae4ef

Please sign in to comment.