Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added missing configuration for assign shams.

  • Loading branch information...
commit 44ae4efd8a61114032316e3c0a03746c8d9340a5 1 parent e8cebb7
Pan Thomakos authored
Showing with 16 additions and 0 deletions.
  1. +5 −0 lib/sham/config.rb
  2. +11 −0 spec/lib/sham/config_spec.rb
5 lib/sham/config.rb
View
@@ -1,4 +1,5 @@
require 'sham/shammable'
+require 'sham/config/assign'
require 'sham/config/attributes'
require 'sham/config/parameters'
require 'sham/config/empty'
@@ -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
11 spec/lib/sham/config_spec.rb
View
@@ -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|
Please sign in to comment.
Something went wrong with that request. Please try again.