pickle 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,8 +1,19 @@
1
+ == 0.2.9 - 27 Apr 2010 (the #railscamp7 release)
2
+
3
+ * 5 improvements
4
+ * Fixed problem with verifying model attribute using strings with escaped quotes [Michael MacDonald]
5
+ * Added handling for positive and negative floats [Michael MacDonald, #railscamp7]
6
+ * Added handling of ruby integer syntax (e.g. 1_000_000) [Ian White]
7
+ * Modified the way pickle handles predicates to match rspec [Michael MacDonald, #railscamp7]
8
+ * Added step to assert size of an association (e.g. Then the user should have 4 friends) [Ian White]
9
+
10
+
1
11
  == 0.2.8 - 5 Apr 2010
2
12
 
3
13
  * 1 minor improvement
4
14
  * 'Then show me the email' works as expected now [#18]
5
15
 
16
+
6
17
  == 0.2.7 - 5 Apr 2010
7
18
 
8
19
  * 1 minor improvement
data/README.rdoc CHANGED
@@ -169,6 +169,13 @@ You can refer to other models in the fields
169
169
  "Given <b>n models</b> exist with <b>fields</b>", examples:
170
170
 
171
171
  Given 10 users exist with activated: false
172
+
173
+ "Given the following <b>models</b> exist:", examples:
174
+
175
+ Given the following users exist
176
+ | name | activated |
177
+ | Fred | false |
178
+ | Ethel | true |
172
179
 
173
180
  ==== Then steps
174
181
 
@@ -221,13 +228,14 @@ Many-to-one assocs: "Then <b>a model</b> should be [in|one of] <b>other model</b
221
228
  ===== Asserting predicate methods
222
229
 
223
230
  "Then <b>a model</b> should [be|have] [a|an] <b>predicate</b>", e.g.
224
-
225
- Then the user should have a status # => user.status?.should == true
226
- Then the car: "batmobile" should be fast # => car.fast?.should == true
231
+
232
+ Then the user should have a status # => user.status.should be_present
233
+ Then the user should have a stale password # => user.should have_stale_password
234
+ Then the car: "batmobile" should be fast # => car.should be_fast
227
235
 
228
236
  "Then <b>a model</b> should not [be|have] [a|an] <b>predicate</b>", e.g.
229
237
 
230
- Then person: "fred" should not be childless # => fred.childless?.should == false
238
+ Then person: "fred" should not be childless # => fred.should_not be_childless
231
239
 
232
240
  === Regexps for use in your own steps
233
241
 
data/Rakefile CHANGED
@@ -30,7 +30,7 @@ end
30
30
  namespace :rcov do
31
31
  desc "Verify RCov threshold for #{PluginName}"
32
32
  RCov::VerifyTask.new(:verify => :rcov) do |t|
33
- t.threshold = 98.67
33
+ t.threshold = 98.29
34
34
  t.index_html = File.join(File.dirname(__FILE__), 'doc/coverage/index.html')
35
35
  end
36
36
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.2.9
data/features/app/app.rb CHANGED
@@ -29,6 +29,7 @@ ActiveRecord::Migration.suppress_messages do
29
29
  create_table :users, :force => true do |t|
30
30
  t.string :name, :status, :email
31
31
  t.decimal :attitude_score, :precision => 4, :scale => 2
32
+ t.boolean :has_stale_password, :default => false
32
33
  end
33
34
  end
34
35
  end
@@ -4,10 +4,13 @@ Feature: I can easily create models from my blueprints
4
4
  I want to be able to create models with fields
5
5
  So that I can create models quickly and easily in my features
6
6
 
7
+ @wip
7
8
  Scenario: I create a user, and see if it looks right
8
- Given a user exists with name: "Fred"
9
+ Given a user exists with name: "Fred", has_stale_password: true
9
10
  Then the user should not have a status
10
-
11
+ And the user should have a stale password
12
+ And the user's name should be "Fred"
13
+
11
14
  Scenario: I create a user, and see if it looks right
12
15
  Given a user exists with name: "Fred", status: "crayzee"
13
16
  Then a user should exist with name: "Fred"
@@ -21,16 +24,22 @@ Feature: I can easily create models from my blueprints
21
24
 
22
25
  Scenario: I create positive and negative users
23
26
  Given a user exists with name: "Fred", attitude_score: +5.42
24
- And another user exists with name: "Ethel", attitude_score: -1.46
25
- Then 2 users should exist
27
+ And another user exists with name: "Ethel", attitude_score: -10
28
+ And another user exists with name: "Buddha", attitude_score: 2_000_000
29
+ Then 3 users should exist
26
30
  And the 1st user should be a positive person
27
31
  And the 2nd user should not be a positive person
28
-
32
+ And the 1st user's attitude_score should be 5.42
33
+ And the 2nd user's attitude_score should be -10
34
+ And the 3rd user's attitude_score should be 2_000_000
35
+ And the 3rd user's attitude_score should be 2000000
36
+
29
37
  Scenario: I create nil values
30
38
  Given a user exists with name: "Fred", attitude_score: nil
31
39
  Then 1 users should exist with attitude_score: nil
32
40
  And that user should be the first user
33
41
  And that user should have no attitude
42
+ And that user's attitude_score should be nil
34
43
 
35
44
  Scenario: create and find using tables
36
45
  Given the following users exist:
@@ -46,8 +46,12 @@ Feature: I can easily create models from my factories
46
46
  | fork |
47
47
  | the 1st fork |
48
48
  | the 2nd fork |
49
+ | the 2nd fork |
49
50
  Then the 1st tine should be in the 1st fork's tines
50
51
  And the 2nd tine should be in the 2nd fork's tines
52
+ And the 3rd tine should be in the 2nd fork's tines
53
+ And the 1st fork should have 1 tines
54
+ And the 2nd fork should have 2 tines
51
55
 
52
56
  Scenario: I create fork via a mapping
53
57
  Given killah fork exists
@@ -7,6 +7,7 @@ Feature: I can easily create models from my blueprints
7
7
  Scenario: I create a spoon, and see if it looks right
8
8
  Given a spoon exists
9
9
  Then the spoon should be round
10
+ And the spoon's round should be true
10
11
 
11
12
  Scenario: I create a non round spoon, and see if it looks right
12
13
  Given a spoon exists with round: false
@@ -62,12 +62,20 @@ end
62
62
 
63
63
  # assert model.predicate?
64
64
  Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
65
- model!(name).should send("be_#{predicate.gsub(' ', '_')}")
65
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
66
+ model!(name).should send("have_#{predicate.gsub(' ', '_')}")
67
+ else
68
+ model!(name).should send("be_#{predicate.gsub(' ', '_')}")
69
+ end
66
70
  end
67
71
 
68
72
  # assert not model.predicate?
69
73
  Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
70
- model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
74
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
75
+ model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
76
+ else
77
+ model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
78
+ end
71
79
  end
72
80
 
73
81
  # model.attribute.should eql(value)
@@ -79,9 +87,14 @@ Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |nam
79
87
  case expected
80
88
  when 'nil', 'true', 'false'
81
89
  actual_value.send(expectation, send("be_#{expected}"))
82
- when /^-?[0-9_]+$/
83
- actual_value.send(expectation, eql(expected.to_i))
90
+ when /^[+-]?[0-9_]+(\.\d+)?$/
91
+ actual_value.send(expectation, eql(expected.to_f))
84
92
  else
85
- actual_value.to_s.send(expectation, eql(expected))
93
+ actual_value.to_s.send(expectation, eql(eval(expected)))
86
94
  end
87
95
  end
96
+
97
+ # assert size of association
98
+ Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
99
+ model!(name).send(association).size.should == size.to_i
100
+ end
@@ -22,7 +22,7 @@ module Pickle
22
22
  end
23
23
 
24
24
  def match_value
25
- "(?:\"#{match_quoted}\"|nil|true|false|[+-]?\\d+(?:\\.\\d+)?)"
25
+ "(?:\"#{match_quoted}\"|nil|true|false|[+-]?[0-9_]+(?:\\.\\d+)?)"
26
26
  end
27
27
 
28
28
  def match_field
@@ -58,7 +58,7 @@ module Pickle
58
58
  end
59
59
 
60
60
  def match_predicate
61
- "(?:#{config.predicates.map{|m| m.to_s.sub(/\?$/,'').gsub('_','[_ ]')}.join('|')})"
61
+ "(?:#{config.predicates.map{|m| m.to_s.sub(/^has_/,'').sub(/\?$/,'').gsub('_','[_ ]')}.join('|')})"
62
62
  end
63
63
 
64
64
  # create capture analogues of match methods
data/pickle.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pickle}
8
- s.version = "0.2.8"
8
+ s.version = "0.2.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ian White"]
12
- s.date = %q{2010-04-05}
12
+ s.date = %q{2010-04-27}
13
13
  s.description = %q{Easy model creation and reference in your cucumber features}
14
14
  s.email = %q{ian.w.white@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -62,12 +62,20 @@ end
62
62
 
63
63
  # assert model.predicate?
64
64
  Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
65
- model!(name).should send("be_#{predicate.gsub(' ', '_')}")
65
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
66
+ model!(name).should send("have_#{predicate.gsub(' ', '_')}")
67
+ else
68
+ model!(name).should send("be_#{predicate.gsub(' ', '_')}")
69
+ end
66
70
  end
67
71
 
68
72
  # assert not model.predicate?
69
73
  Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
70
- model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
74
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
75
+ model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
76
+ else
77
+ model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
78
+ end
71
79
  end
72
80
 
73
81
  # model.attribute.should eql(value)
@@ -79,9 +87,14 @@ Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |nam
79
87
  case expected
80
88
  when 'nil', 'true', 'false'
81
89
  actual_value.send(expectation, send("be_#{expected}"))
82
- when /^-?[0-9_]+$/
83
- actual_value.send(expectation, eql(expected.to_i))
90
+ when /^[+-]?[0-9_]+(\.\d+)?$/
91
+ actual_value.send(expectation, eql(expected.to_f))
84
92
  else
85
- actual_value.to_s.send(expectation, eql(expected))
93
+ actual_value.to_s.send(expectation, eql(eval(expected)))
86
94
  end
87
95
  end
96
+
97
+ # assert size of association
98
+ Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
99
+ model!(name).send(association).size.should == size.to_i
100
+ end
@@ -102,6 +102,7 @@ describe Pickle::Email do
102
102
 
103
103
  describe "#save_and_open_emails" do
104
104
  before do
105
+ stub!(:open_in_browser)
105
106
  stub!(:emails).and_return(["Contents of Email 1"])
106
107
  @now = "2008-01-01".to_time
107
108
  Time.stub!(:now).and_return(@now)
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
3
3
  describe Pickle::Parser::Matchers do
4
4
  include Pickle::Parser::Matchers
5
5
 
6
- describe "(config: [factories: user, car, fast_car] [predicates: name, status, fancy?, super_fancy?]" do
6
+ describe "(config: [factories: user, car, fast_car] [predicates: name, status, fancy?, super_fancy?, has_style?, has_super_style?]" do
7
7
  def config
8
8
  @config ||= Pickle::Config.new do |c|
9
9
  c.factories = {
@@ -11,7 +11,7 @@ describe Pickle::Parser::Matchers do
11
11
  'car' => mock('factory'),
12
12
  'fast_car' => mock('factory')
13
13
  }
14
- c.predicates = %w(name status fancy? super_fancy?)
14
+ c.predicates = %w(name status fancy? super_fancy? has_style? has_super_style?)
15
15
  end
16
16
  end
17
17
 
@@ -50,8 +50,8 @@ describe Pickle::Parser::Matchers do
50
50
  atom_should_match :match_model, ['a user', '1st fast car', 'the 23rd fast_car', 'the user: "fred flinstone"']
51
51
  atom_should_not_match :match_model, ['a giraffe', 'a 1st faster car: "jim"', 'an event created']
52
52
 
53
- atom_should_match :match_predicate, ['name', 'status', 'fancy', 'super fancy', 'super_fancy']
54
- atom_should_not_match :match_predicate, ['nameo', 'increment', 'not a predicate']
53
+ atom_should_match :match_predicate, ['name', 'status', 'fancy', 'super fancy', 'super_fancy', 'style', 'super style', 'super_style']
54
+ atom_should_not_match :match_predicate, ['nameo', 'increment', 'not a predicate', 'has style']
55
55
 
56
56
  atom_should_match :match_factory, ['user', 'fast car', 'fast_car', 'car']
57
57
  atom_should_not_match :match_factory, ['users', 'faster car', 'event created']
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 8
9
- version: 0.2.8
8
+ - 9
9
+ version: 0.2.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ian White
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-05 00:00:00 +01:00
17
+ date: 2010-04-27 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20