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 CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/blindfold.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'blindfold'
5
- gem.version = '0.0.2'
6
- gem.date = %{2010-06-24}
5
+ gem.version = '0.0.3'
6
+ gem.date = %{2010-06-25}
7
7
 
8
8
  gem.authors = ["James Bunch (fallwith)"]
9
9
  gem.email = nil
@@ -1,11 +1,8 @@
1
1
  module HelperMethods
2
- def wipe(name)
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
@@ -1,8 +1,14 @@
1
1
  class Launcher
2
- SPEC_OPTS_FILE = 'spec.opts'
3
- BLUEPRINTS_DIR = 'blueprints' # lives within config_dir
4
- MATCHERS_DIR = 'matchers' # lives within config_dir
5
- HELPERS_DIR = 'helpers' # lives within config_dir
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, HELPERS_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, BLUEPRINTS_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, MATCHERS_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, SPEC_OPTS_FILE)
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
@@ -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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
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-24 00:00:00 -07:00
18
+ date: 2010-06-25 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency