blindfold 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/blindfold.gemspec +2 -2
- data/lib/blindfold/helpers/db.rb +4 -7
- data/lib/blindfold/launcher.rb +14 -8
- data/lib/blindfold/xml/monkey.rb +14 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/blindfold.gemspec
CHANGED
data/lib/blindfold/helpers/db.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
module HelperMethods
|
2
|
-
|
2
|
+
# Wipe a database table completely or based on an array of ids
|
3
|
+
def wipe(name, ids=[])
|
4
|
+
ids = Array(ids) # allow a single id to be passed in
|
3
5
|
klass = name.to_s.singularize.camelize.constantize
|
4
|
-
klass.delete_all
|
5
|
-
end
|
6
|
-
|
7
|
-
def spawn(name, args={})
|
8
|
-
klass = name.to_s.singularize.camelize.constantize
|
9
|
-
klass.make(args)
|
6
|
+
ids.empty? ? klass.delete_all : klass.delete_all(['id IN (?)', ids])
|
10
7
|
end
|
11
8
|
end
|
data/lib/blindfold/launcher.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
class Launcher
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
mattr_accessor :spec_opts_file
|
3
|
+
mattr_accessor :blueprints_dir
|
4
|
+
mattr_accessor :matchers_dir
|
5
|
+
mattr_accessor :helpers_dir
|
6
|
+
|
7
|
+
# these all leave beneath the config dir
|
8
|
+
@@spec_opts_file = 'spec.opts'
|
9
|
+
@@blueprints_dir = 'blueprints'
|
10
|
+
@@matchers_dir = 'matchers'
|
11
|
+
@@helpers_dir = 'helpers'
|
6
12
|
|
7
13
|
def initialize(args={})
|
8
14
|
Blindfold.config_dir = args[:config_dir] if args.has_key?(:config_dir)
|
@@ -23,7 +29,7 @@ class Launcher
|
|
23
29
|
private
|
24
30
|
|
25
31
|
def init_helpers
|
26
|
-
helpers_dir = File.join(Blindfold.config_dir,
|
32
|
+
helpers_dir = File.join(Blindfold.config_dir, @@helpers_dir)
|
27
33
|
if Dir.exists?(helpers_dir)
|
28
34
|
Dir[File.join(helpers_dir,'**','*.rb')].each {|f| load f}
|
29
35
|
end
|
@@ -33,14 +39,14 @@ class Launcher
|
|
33
39
|
# Introduce all helper methods to Machinist
|
34
40
|
Machinist::Lathe.send :include, HelperMethods
|
35
41
|
# Load up all blueprints
|
36
|
-
blueprints_dir = File.join(Blindfold.config_dir,
|
42
|
+
blueprints_dir = File.join(Blindfold.config_dir, @@blueprints_dir)
|
37
43
|
if Dir.exists?(blueprints_dir)
|
38
44
|
Dir[File.join(blueprints_dir,'**','*_blueprint.rb')].each {|f| load f}
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
48
|
def init_matchers
|
43
|
-
matchers_dir = File.join(Blindfold.config_dir,
|
49
|
+
matchers_dir = File.join(Blindfold.config_dir, @@matchers_dir)
|
44
50
|
if Dir.exists?(matchers_dir)
|
45
51
|
Dir[File.join(matchers_dir,'**','*.rb')].each {|f| load f}
|
46
52
|
end
|
@@ -57,7 +63,7 @@ class Launcher
|
|
57
63
|
Spec::Runner.configuration.include(HelperMethods)
|
58
64
|
|
59
65
|
# Specify which spec.opts file to use
|
60
|
-
spec_opts = File.join(Blindfold.config_dir,
|
66
|
+
spec_opts = File.join(Blindfold.config_dir, @@spec_opts_file)
|
61
67
|
if File.exists?(spec_opts)
|
62
68
|
args << '-O' << spec_opts
|
63
69
|
end
|
data/lib/blindfold/xml/monkey.rb
CHANGED
@@ -3,6 +3,20 @@ module Nokogiri::XML
|
|
3
3
|
def elements(name)
|
4
4
|
xpath("//#{name}")
|
5
5
|
end
|
6
|
+
def element(name)
|
7
|
+
elements(name).first
|
8
|
+
end
|
9
|
+
end
|
10
|
+
class Element
|
11
|
+
def attribute_value(name)
|
12
|
+
attribute(name).value
|
13
|
+
end
|
14
|
+
def elements(name)
|
15
|
+
xpath(name)
|
16
|
+
end
|
17
|
+
def element(name)
|
18
|
+
elements(name).first
|
19
|
+
end
|
6
20
|
end
|
7
21
|
class NodeSet
|
8
22
|
def with_attributes(attributes)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blindfold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Bunch (fallwith)
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-25 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|