cucumber_factory 1.11.8 → 1.11.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/Gemfile.cucumber-1.3.lock +2 -2
- data/gemfiles/Gemfile.cucumber-2.4.lock +2 -2
- data/gemfiles/Gemfile.cucumber-3.0.lock +2 -2
- data/lib/cucumber_factory/switcher.rb +7 -1
- data/lib/cucumber_factory/version.rb +1 -1
- data/spec/cucumber_factory/steps_spec.rb +12 -6
- data/spec/support/database.rb +8 -0
- data/spec/support/models/movie.rb +1 -0
- data/spec/support/models/uuid_user.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf308118b2098c3650288d2da08549d6f1f51c07
|
4
|
+
data.tar.gz: 8325e52892d5331e2c5d9a0670ad8883e8519783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4111f40061523a16fb4845487beadc7ea8580e9bc47b7e701fadd8ced980cc4444b02fbdcc3b55c4f825b1dc7e7494988ef48f8b121c108ef0e31b31820cae5
|
7
|
+
data.tar.gz: '0186bd34d5f8325d5bd355d6eedc927f66f1c685b9166990af20a282f12394c340aed9d378c31fbdddcca99f1ac462762a5a6bc9b1c3bdb619a57e94733ef7b6'
|
@@ -5,7 +5,13 @@ module CucumberFactory
|
|
5
5
|
def find_last(klass)
|
6
6
|
# Don't use class.last, in sqlite that is not always the last inserted element
|
7
7
|
# If created_at is available prefer it over id as column for ordering so that we can handle UUIDs
|
8
|
-
|
8
|
+
primary_key = klass.primary_key
|
9
|
+
has_numeric_primary_key = klass.columns_hash[primary_key].type == :integer
|
10
|
+
order_column = if has_numeric_primary_key || !klass.column_names.include?('created_at')
|
11
|
+
primary_key
|
12
|
+
else
|
13
|
+
"created_at, #{primary_key}"
|
14
|
+
end
|
9
15
|
if active_record_version < 4
|
10
16
|
klass.find(:last, :order => order_column)
|
11
17
|
else
|
@@ -171,16 +171,22 @@ describe 'steps provided by cucumber_factory' do
|
|
171
171
|
before_sunset.reviewer.should == user
|
172
172
|
end
|
173
173
|
|
174
|
-
it "should give created_at precedence over id when saying 'above'
|
174
|
+
it "should give created_at precedence over id when saying 'above' if the primary key is not numeric" do
|
175
|
+
invoke_cucumber_step('there is a uuid user with the name "Jane" and the id "jane"')
|
176
|
+
invoke_cucumber_step('there is a uuid user with the name "John" and the id "john"')
|
177
|
+
UuidUser.find_by_name("John").update_attributes!(:created_at => 1.day.ago)
|
178
|
+
invoke_cucumber_step('there is a movie with the title "Before Sunset" and the uuid reviewer above')
|
179
|
+
before_sunset = Movie.find_by_title!("Before Sunset")
|
180
|
+
before_sunset.uuid_reviewer.name.should == "Jane"
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should ignore created_at if the primary key is numeric" do
|
175
184
|
invoke_cucumber_step('there is a user with the name "Jane"')
|
176
185
|
invoke_cucumber_step('there is a user with the name "John"')
|
177
186
|
User.find_by_name("John").update_attributes!(:created_at => 1.day.ago)
|
178
|
-
invoke_cucumber_step('there is a movie with the title "
|
179
|
-
invoke_cucumber_step('there is a movie with the title "Before Sunrise"')
|
180
|
-
invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer above and the prequel above')
|
187
|
+
invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer above')
|
181
188
|
before_sunset = Movie.find_by_title!("Before Sunset")
|
182
|
-
before_sunset.
|
183
|
-
before_sunset.reviewer.name.should == "Jane"
|
189
|
+
before_sunset.reviewer.name.should == "John"
|
184
190
|
end
|
185
191
|
|
186
192
|
it "should raise a proper error if there is no previous record when saying 'above'" do
|
data/spec/support/database.rb
CHANGED
@@ -5,6 +5,7 @@ Gemika::Database.new.rewrite_schema! do
|
|
5
5
|
t.integer :year
|
6
6
|
t.integer :prequel_id
|
7
7
|
t.integer :reviewer_id
|
8
|
+
t.string :uuid_reviewer_id
|
8
9
|
t.integer :box_office_result
|
9
10
|
end
|
10
11
|
|
@@ -19,6 +20,13 @@ Gemika::Database.new.rewrite_schema! do
|
|
19
20
|
t.datetime :created_at
|
20
21
|
end
|
21
22
|
|
23
|
+
create_table :uuid_users, :id => false do |t|
|
24
|
+
t.string :id
|
25
|
+
t.string :email
|
26
|
+
t.string :name
|
27
|
+
t.datetime :created_at
|
28
|
+
end
|
29
|
+
|
22
30
|
create_table :payments do |t|
|
23
31
|
t.text :comment
|
24
32
|
t.integer :amount
|
@@ -2,6 +2,7 @@ class Movie < ActiveRecord::Base
|
|
2
2
|
|
3
3
|
belongs_to :prequel, :class_name => "Movie"
|
4
4
|
belongs_to :reviewer, :class_name => "User"
|
5
|
+
belongs_to :uuid_reviewer, :class_name => "UuidUser"
|
5
6
|
|
6
7
|
validate do |record|
|
7
8
|
record.errors.add(:reviewer, 'may not be deleted') if record.reviewer and record.reviewer.deleted?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- spec/support/models/people/actor.rb
|
111
111
|
- spec/support/models/plain_ruby_class.rb
|
112
112
|
- spec/support/models/user.rb
|
113
|
+
- spec/support/models/uuid_user.rb
|
113
114
|
homepage: http://github.com/makandra/cucumber_factory
|
114
115
|
licenses:
|
115
116
|
- MIT
|