blueprints 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.8.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{blueprints}
8
- s.version = "0.8.1"
8
+ s.version = "0.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrius Chamentauskas"]
12
- s.date = %q{2010-09-07}
12
+ s.date = %q{2010-09-23}
13
13
  s.default_executable = %q{blueprintify}
14
14
  s.description = %q{Another replacement for factories and fixtures. The library that lazy typists will love}
15
15
  s.email = %q{sinsiliux@gmail.com}
@@ -17,7 +17,7 @@ module Blueprints
17
17
 
18
18
  # Defines blueprint dependencies. Used internally, but can be used externally too.
19
19
  def depends_on(*scenarios)
20
- @parents = (@parents || []) + scenarios.map{|s| s.to_sym}
20
+ @parents = (@parents || []) + scenarios.map { |s| s.to_sym }
21
21
  self
22
22
  end
23
23
 
@@ -80,12 +80,13 @@ module Blueprints
80
80
  def self.normalize_attributes(attributes)
81
81
  attributes = attributes.dup
82
82
  attributes.each do |attr, value|
83
- attributes[attr] = value.value if value.is_a?(Blueprints::Dependency)
83
+ attributes[attr] = value.blueprint_value if value.respond_to?(:blueprint_value)
84
84
  if value.is_a? Symbol and value.to_s =~ /^@.+$/
85
85
  STDERR.puts "DEPRECATION WARNING: :@variables are deprecated in favor of `d` method"
86
86
  attributes[attr] = Blueprints::Namespace.root.context.instance_variable_get(value)
87
87
  end
88
88
  end
89
+ attributes
89
90
  end
90
91
 
91
92
  def build_parents
@@ -118,7 +119,7 @@ module Blueprints
118
119
  def parse_name(name)
119
120
  case name
120
121
  when Hash
121
- return name.keys.first.to_sym, [name.values.first].flatten.map{|sc| parse_name(sc).first}
122
+ return name.keys.first.to_sym, [name.values.first].flatten.map { |sc| parse_name(sc).first }
122
123
  when Symbol, String
123
124
  name = name.to_sym unless name == ''
124
125
  return name, []
@@ -11,6 +11,8 @@
11
11
  # d = Blueprints::Dependency.new(:blueprint).name.size
12
12
  # d.value # => 4 when @blueprint.name == 'John'
13
13
  class Blueprints::Dependency
14
+ instance_methods.each { |m| undef_method m if m =~ /^(to_|id$)/ }
15
+
14
16
  # Initializes new copy of Blueprints::Dependency with name, iv_name and options.
15
17
  def initialize(name, *args)
16
18
  @name = name
@@ -20,7 +22,7 @@ class Blueprints::Dependency
20
22
  end
21
23
 
22
24
  # Builds blueprint (if necessary) and returns the value of instance variable.
23
- def value
25
+ def blueprint_value
24
26
  Blueprints::RootNamespace.root.build @name => @options
25
27
  @registry.inject(Blueprints::RootNamespace.root.context.instance_variable_get(:"@#{@iv_name}")) do |value, (method, args, block)|
26
28
  value.send(method, *args, &block)
@@ -15,15 +15,15 @@ describe Blueprints::Dependency do
15
15
  end
16
16
 
17
17
  it "should allow getting instance variable value" do
18
- Blueprints::Dependency.new(:blueprint).value.should == @mock
18
+ Blueprints::Dependency.new(:blueprint).blueprint_value.should == @mock
19
19
  end
20
20
 
21
21
  it "should allow getting another instance variable" do
22
- Blueprints::Dependency.new(:blueprint, :value).value.should == @value
22
+ Blueprints::Dependency.new(:blueprint, :value).blueprint_value.should == @value
23
23
  end
24
24
 
25
25
  it "should allow passing options for building" do
26
- Blueprints::Dependency.new(:blueprint, :option => 'value').value.should == {:option => 'value'}
26
+ Blueprints::Dependency.new(:blueprint, :option => 'value').blueprint_value.should == {:option => 'value'}
27
27
  end
28
28
 
29
29
  it "should record all missing methods" do
@@ -34,6 +34,16 @@ describe Blueprints::Dependency do
34
34
  mock1.expects(:method2).with(1).returns(mock2 = mock)
35
35
  mock2.expects(:method3).with().yields(mock(:method4 => true)).returns(result = mock)
36
36
 
37
- dependency.value.should == result
37
+ dependency.blueprint_value.should == result
38
+ end
39
+
40
+ it "should record to_s, id and other standard methods" do
41
+ dependency = Blueprints::Dependency.new(:blueprint)
42
+ dependency.id.to_s
43
+
44
+ @mock.expects(:id).returns(mock1 = mock)
45
+ mock1.expects(:to_s).returns(result = mock)
46
+
47
+ dependency.blueprint_value.should == result
38
48
  end
39
49
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprints
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 1
10
- version: 0.8.1
9
+ - 2
10
+ version: 0.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrius Chamentauskas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-07 00:00:00 +03:00
18
+ date: 2010-09-23 00:00:00 +03:00
19
19
  default_executable: blueprintify
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency