ianwhite-pickle 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.1.4
2
+
3
+ * 1 major enhancement
4
+ * You can create multiple models with ease, for eg.
5
+ 'Given 10 users exist with role: "admin"'
6
+
7
+ * 1 minor enhancement
8
+ * You can do Pickle.configure (just like Webrat.configure)
9
+
10
+
1
11
  == 0.1.3 - Bugfix release
2
12
 
3
13
  * 1 minor enhancement
data/lib/pickle.rb CHANGED
@@ -15,5 +15,6 @@ if defined?(ActionController::Integration::Session)
15
15
  end
16
16
 
17
17
  # shortcuts for useful regexps when defining pickle steps
18
- CaptureModel = Pickle.parser.capture_model
19
- CaptureFields = Pickle.parser.capture_fields
18
+ CaptureModel = Pickle.parser.capture_model
19
+ CapturePluralFactory = Pickle.parser.capture_plural_factory
20
+ CaptureFields = Pickle.parser.capture_fields
data/lib/pickle/config.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  require 'ostruct'
2
2
 
3
3
  module Pickle
4
- def self.config(&block)
5
- returning(@config ||= Config.new) do |config|
6
- config.configure(&block) if block_given?
4
+ class << self
5
+ def config(&block)
6
+ @config ||= Config.new
7
+ ensure
8
+ @config.configure(&block) if block_given?
7
9
  end
10
+ alias_method :configure, :config
8
11
  end
9
12
 
10
13
  class Config
@@ -36,7 +36,11 @@ module Pickle
36
36
  def match_factory
37
37
  "(?:#{config.factory_names.map{|n| n.gsub('_','[_ ]')}.join('|')})"
38
38
  end
39
-
39
+
40
+ def match_plural_factory
41
+ "(?:#{config.factory_names.map{|n| n.pluralize.gsub('_','[_ ]')}.join('|')})"
42
+ end
43
+
40
44
  def match_indexed_model
41
45
  "(?:(?:#{match_index} )?#{match_factory})"
42
46
  end
@@ -2,7 +2,7 @@ module Pickle
2
2
  module Version
3
3
  Major = 0
4
4
  Minor = 1
5
- Tiny = 3
5
+ Tiny = 4
6
6
 
7
7
  String = [Major, Minor, Tiny].join('.')
8
8
  end
@@ -1,9 +1,9 @@
1
1
  <%= current_env %>
2
2
  # to configure pickle, uncomment the following lines
3
3
  # require 'pickle/config'
4
- # Pickle.config do |pickle|
5
- # pickle.adaptors = [:machinist]
6
- # pickle.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
4
+ # Pickle.configure do |config|
5
+ # config.adaptors = [:machinist]
6
+ # config.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
7
7
  # end
8
8
 
9
9
  require 'pickle'
@@ -8,6 +8,14 @@ Given(/^#{CaptureModel} exists with #{CaptureFields}$/) do |name, fields|
8
8
  create_model(name, fields)
9
9
  end
10
10
 
11
+ Given(/^(\d+) #{CapturePluralFactory} exist$/) do |amount, plural_factory|
12
+ amount.to_i.times { create_model(plural_factory.singularize) }
13
+ end
14
+
15
+ Given(/^(\d+) #{CapturePluralFactory} exist with #{CaptureFields}$/) do |amount, plural_factory, fields|
16
+ amount.to_i.times { create_model(plural_factory.singularize, fields) }
17
+ end
18
+
11
19
  Then(/^#{CaptureModel} should exist with #{CaptureFields}$/) do |name, fields|
12
20
  find_model(name, fields).should_not be_nil
13
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ianwhite-pickle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian White
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-31 00:00:00 -08:00
12
+ date: 2009-01-01 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15