blueprints 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +82 -18
- data/LICENSE +1 -1
- data/README.rdoc +38 -8
- data/Rakefile +11 -35
- data/blueprints.gemspec +29 -123
- data/features/support/env.rb +7 -10
- data/lib/blueprints.rb +68 -12
- data/lib/blueprints/blueprint.rb +39 -19
- data/lib/blueprints/buildable.rb +92 -74
- data/lib/blueprints/configuration.rb +18 -4
- data/lib/blueprints/context.rb +148 -5
- data/lib/blueprints/database_cleaner_fix.rb +9 -0
- data/lib/blueprints/dependency.rb +32 -21
- data/lib/blueprints/eval_context.rb +51 -0
- data/lib/blueprints/extensions.rb +115 -0
- data/lib/blueprints/extensions/rspec.rb +3 -1
- data/lib/blueprints/helper.rb +52 -20
- data/lib/blueprints/namespace.rb +31 -12
- data/lib/blueprints/root_namespace.rb +24 -25
- data/lib/blueprints/version.rb +3 -0
- data/spec/{active_record/blueprint.rb → blueprint.rb} +14 -17
- data/spec/{active_record/blueprints_spec.rb → blueprints_spec.rb} +40 -59
- data/spec/spec_helper.rb +34 -0
- data/spec/support/active_record/database.yml.example +7 -0
- data/spec/support/active_record/initializer.rb +15 -0
- data/spec/{active_record/fixtures → support/active_record}/schema.rb +0 -0
- data/spec/support/dm-core/initializer.rb +31 -0
- data/spec/support/mongo_mapper/database.yml.example +2 -0
- data/spec/support/mongo_mapper/initializer.rb +20 -0
- data/spec/support/mongoid/database.yml.example +2 -0
- data/spec/support/mongoid/initializer.rb +23 -0
- data/spec/support/none/initializer.rb +63 -0
- data/spec/unit/active_record_spec.rb +1 -6
- data/spec/unit/blueprint_spec.rb +91 -20
- data/spec/unit/blueprints_spec.rb +44 -0
- data/spec/unit/buildable_spec.rb +37 -6
- data/spec/unit/configuration_spec.rb +11 -0
- data/spec/unit/context_spec.rb +100 -0
- data/spec/unit/dependency_spec.rb +24 -19
- data/spec/unit/eval_context_spec.rb +56 -0
- data/spec/unit/fixtures.rb +61 -0
- data/spec/unit/namespace_spec.rb +59 -11
- data/spec/unit/spec_helper.rb +8 -16
- data/test/blueprints_test.rb +40 -59
- data/test/test_helper.rb +6 -16
- data/test_all.sh +45 -0
- metadata +178 -61
- data/VERSION +0 -1
- data/lib/blueprints/core_ext.rb +0 -69
- data/lib/blueprints/file_context.rb +0 -37
- data/spec/active_record/fixtures/database.yml.example +0 -8
- data/spec/active_record/fixtures/fruit.rb +0 -3
- data/spec/active_record/fixtures/tree.rb +0 -4
- data/spec/active_record/spec_helper.rb +0 -37
- data/spec/no_db/blueprint.rb +0 -9
- data/spec/no_db/blueprints_spec.rb +0 -45
- data/spec/no_db/fixtures/fruit.rb +0 -15
- data/spec/no_db/spec_helper.rb +0 -14
- data/spec/test_all.sh +0 -39
@@ -1,37 +0,0 @@
|
|
1
|
-
module Blueprints
|
2
|
-
# Module that blueprints file is executed against. Defined <tt>blueprint</tt> and <tt>namespace</tt> methods.
|
3
|
-
class FileContext
|
4
|
-
@@current = nil
|
5
|
-
cattr_accessor :current
|
6
|
-
attr_reader :file
|
7
|
-
|
8
|
-
def initialize(file)
|
9
|
-
file = Pathname.new(file)
|
10
|
-
@file = file.relative_path_from(Blueprints.config.root)
|
11
|
-
FileContext.current = self
|
12
|
-
instance_eval(File.read(file))
|
13
|
-
FileContext.current = nil
|
14
|
-
end
|
15
|
-
|
16
|
-
# Creates a new blueprint by name and block passed
|
17
|
-
def blueprint(name, &block)
|
18
|
-
Blueprint.new(name, @file, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Creates new namespace by name, and evaluates block against it.
|
22
|
-
def namespace(name)
|
23
|
-
old_namespace = Namespace.root
|
24
|
-
namespace = Namespace.new(name)
|
25
|
-
Namespace.root = namespace
|
26
|
-
yield
|
27
|
-
old_namespace.add_child(namespace)
|
28
|
-
Namespace.root = old_namespace
|
29
|
-
namespace
|
30
|
-
end
|
31
|
-
|
32
|
-
# Wrapper around Blueprints::Dependency.new. See Blueprints::Dependency for more information.
|
33
|
-
def d(*args)
|
34
|
-
Dependency.new(*args)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'logger'
|
3
|
-
version = ENV['RAILS']
|
4
|
-
gem 'activerecord', version == '3' ? '>= 3.0.0.beta' : "~> #{version}" if version
|
5
|
-
require 'active_record'
|
6
|
-
|
7
|
-
Dir.chdir File.join(File.dirname(__FILE__), '..', '..')
|
8
|
-
|
9
|
-
ActiveRecord::Base.logger = Logger.new("debug.log")
|
10
|
-
|
11
|
-
databases = YAML::load(IO.read("spec/active_record/fixtures/database.yml"))
|
12
|
-
db_info = databases[ENV["DB"] || "test"]
|
13
|
-
ActiveRecord::Base.establish_connection(db_info)
|
14
|
-
|
15
|
-
config_class = if version.to_s[0, 1] == '3'
|
16
|
-
gem 'rspec', '>= 2.0.0.beta'
|
17
|
-
require 'rspec'
|
18
|
-
RSpec
|
19
|
-
else
|
20
|
-
require 'spec'
|
21
|
-
Spec::Runner
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'lib/blueprints'
|
25
|
-
require 'spec/active_record/fixtures/fruit'
|
26
|
-
require 'spec/active_record/fixtures/tree'
|
27
|
-
|
28
|
-
config_class.configure do |config|
|
29
|
-
config.mock_with :mocha
|
30
|
-
end
|
31
|
-
|
32
|
-
Blueprints.enable do |config|
|
33
|
-
config.root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
34
|
-
config.filename = 'spec/active_record/blueprint.rb'
|
35
|
-
config.prebuild = :big_cherry
|
36
|
-
config.transactions = !ENV["NO_TRANSACTIONS"]
|
37
|
-
end
|
data/spec/no_db/blueprint.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
describe Blueprints do
|
4
|
-
it "should build cherry blueprint" do
|
5
|
-
build :cherry
|
6
|
-
@cherry.should_not be_nil
|
7
|
-
@cherry.should be_instance_of(Fruit)
|
8
|
-
@cherry.species.should == 'cherry'
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should not build cherry if not asked" do
|
12
|
-
@cherry.should == nil
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "prebuilt blueprints" do
|
16
|
-
it "big cherry should have size of 10 even if it was changed in test below" do
|
17
|
-
@big_cherry.size.should == 10
|
18
|
-
@big_cherry.size = 15
|
19
|
-
end
|
20
|
-
|
21
|
-
it "big cherry should have size of 10 even if it was changed in test above" do
|
22
|
-
@big_cherry.size.should == 10
|
23
|
-
@big_cherry.size = 13
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "build per describe" do
|
28
|
-
build_blueprint :cherry
|
29
|
-
|
30
|
-
it "should have cherry" do
|
31
|
-
@cherry.should_not be_nil
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should have correct cherry species" do
|
35
|
-
@cherry.species.should == 'cherry'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should allow shortened forms of blueprint for any type of object" do
|
40
|
-
build :apple
|
41
|
-
@apple.should_not be_nil
|
42
|
-
@apple.species.should == 'apple'
|
43
|
-
@apple.size.should == 3
|
44
|
-
end
|
45
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class Fruit
|
2
|
-
attr_accessor :species, :size
|
3
|
-
include Blueprints::Blueprintable
|
4
|
-
|
5
|
-
def initialize(species, size = 5)
|
6
|
-
@species = species
|
7
|
-
@size = size
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def self.blueprint_object(attrs)
|
13
|
-
new(attrs[:species], attrs[:size])
|
14
|
-
end
|
15
|
-
end
|
data/spec/no_db/spec_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
Dir.chdir File.join(File.dirname(__FILE__), '..', '..')
|
2
|
-
|
3
|
-
require 'spec/autorun'
|
4
|
-
require 'lib/blueprints'
|
5
|
-
require 'spec/no_db/fixtures/fruit'
|
6
|
-
|
7
|
-
Spec::Runner.configure do |config|
|
8
|
-
config.mock_with :mocha
|
9
|
-
end
|
10
|
-
|
11
|
-
Blueprints.enable do |config|
|
12
|
-
config.root = File.expand_path(File.join(File.dirname(__FILE__)))
|
13
|
-
config.prebuild = :big_cherry
|
14
|
-
end
|
data/spec/test_all.sh
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
function e {
|
3
|
-
echo ''
|
4
|
-
echo '----------------------------------------'
|
5
|
-
echo $1
|
6
|
-
echo '----------------------------------------'
|
7
|
-
}
|
8
|
-
|
9
|
-
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
|
10
|
-
|
11
|
-
e "Normal spec"
|
12
|
-
spec spec/active_record/blueprints_spec.rb
|
13
|
-
|
14
|
-
e "Without transactions"
|
15
|
-
NO_TRANSACTIONS=true spec spec/active_record/blueprints_spec.rb
|
16
|
-
|
17
|
-
e "With no db"
|
18
|
-
spec spec/no_db/blueprints_spec.rb
|
19
|
-
|
20
|
-
e "With Test::Unit"
|
21
|
-
rake rspec_to_test
|
22
|
-
ruby test/blueprints_test.rb
|
23
|
-
|
24
|
-
e "With Cucumber"
|
25
|
-
cucumber features/blueprints.feature
|
26
|
-
|
27
|
-
e "With Rails 3"
|
28
|
-
rvm 1.8.7
|
29
|
-
RAILS=3 rspec spec/active_record/blueprints_spec.rb
|
30
|
-
|
31
|
-
e "With ruby 1.9.1"
|
32
|
-
rvm 1.9.1
|
33
|
-
spec spec/active_record/blueprints_spec.rb
|
34
|
-
|
35
|
-
e "With ruby 1.8.6"
|
36
|
-
rvm 1.8.6
|
37
|
-
spec spec/active_record/blueprints_spec.rb
|
38
|
-
|
39
|
-
rvm system
|