josevalim-nested_scenarios 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +8 -2
- data/lib/nested_scenarios.rb +9 -18
- data/lib/{builder.rb → nested_scenarios/builder.rb} +0 -0
- data/lib/{fixtures.rb → nested_scenarios/fixtures.rb} +0 -0
- data/lib/{join.rb → nested_scenarios/join.rb} +1 -1
- data/lib/nested_scenarios/nested_scenarios.rb +20 -0
- metadata +5 -5
- data/init.rb +0 -11
data/README
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
NestedScenarios v0.1
|
2
|
-
|
1
|
+
NestedScenarios v0.1.1
|
2
|
+
======================
|
3
3
|
|
4
4
|
This plugin is based on FixtureScenarios and FixtureScenarioBuilder.
|
5
5
|
It includes both worlds in just one plugin with some fixes, new features
|
@@ -34,6 +34,12 @@ In RAILS_ROOT/config/environment.rb:
|
|
34
34
|
|
35
35
|
config.gem "josevalim-nested_scenarios", :lib => "nested_scenarios", :source => "http://gems.github.com"
|
36
36
|
|
37
|
+
If you want it as plugin, just do:
|
38
|
+
|
39
|
+
cd myapp
|
40
|
+
git clone git://github.com/josevalim/nested_scenarios.git
|
41
|
+
rm -rf vendor/plugins/nested_scenarios/.git
|
42
|
+
|
37
43
|
== Why
|
38
44
|
|
39
45
|
You may, from time to time, wish to build your fixtures entirely in Ruby.
|
data/lib/nested_scenarios.rb
CHANGED
@@ -1,20 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
if RAILS_ENV == 'test'
|
2
|
+
require 'test/unit/testcase'
|
3
|
+
require 'test/unit/testsuite'
|
4
|
+
require 'active_record/fixtures'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
connection.delete "DELETE FROM #{table_name}", 'Fixture Delete'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.tables
|
18
|
-
ActiveRecord::Base.connection.tables - @@skip_tables
|
19
|
-
end
|
6
|
+
dir = File.dirname(__FILE__)
|
7
|
+
require File.join(dir, 'nested_scenarios', 'builder')
|
8
|
+
require File.join(dir, 'nested_scenarios', 'fixtures')
|
9
|
+
require File.join(dir, 'nested_scenarios', 'join')
|
10
|
+
require File.join(dir, 'nested_scenarios', 'nested_scenarios')
|
20
11
|
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class NestedScenarios
|
2
|
+
cattr_accessor :record_name_fields, :skip_tables
|
3
|
+
@@record_name_fields = %w( name username title )
|
4
|
+
@@skip_tables = %w( schema_migrations )
|
5
|
+
|
6
|
+
def self.delete_tables(table_names = self.tables)
|
7
|
+
connection = ActiveRecord::Base.connection
|
8
|
+
ActiveRecord::Base.silence do
|
9
|
+
connection.disable_referential_integrity do
|
10
|
+
(table_names - @@skip_tables).each do |table_name|
|
11
|
+
connection.delete "DELETE FROM #{table_name}", 'Fixture Delete'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.tables
|
18
|
+
ActiveRecord::Base.connection.tables - @@skip_tables
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: josevalim-nested_scenarios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -25,11 +25,11 @@ files:
|
|
25
25
|
- MIT-LICENSE
|
26
26
|
- README
|
27
27
|
- Rakefile
|
28
|
-
- init.rb
|
29
|
-
- lib/join.rb
|
30
|
-
- lib/fixtures.rb
|
31
28
|
- lib/nested_scenarios.rb
|
32
|
-
- lib/builder.rb
|
29
|
+
- lib/nested_scenarios/builder.rb
|
30
|
+
- lib/nested_scenarios/fixtures.rb
|
31
|
+
- lib/nested_scenarios/join.rb
|
32
|
+
- lib/nested_scenarios/nested_scenarios.rb
|
33
33
|
- tasks/builder_tasks.rake
|
34
34
|
has_rdoc: true
|
35
35
|
homepage: http://github.com/josevalim/nested_scenarios
|
data/init.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
if RAILS_ENV == 'test'
|
2
|
-
require 'test/unit/testcase'
|
3
|
-
require 'test/unit/testsuite'
|
4
|
-
|
5
|
-
require 'active_record/fixtures'
|
6
|
-
|
7
|
-
require File.join(File.dirname(__FILE__), 'lib', 'join')
|
8
|
-
require File.join(File.dirname(__FILE__), 'lib', 'nested_scenarios')
|
9
|
-
require File.join(File.dirname(__FILE__), 'lib', 'builder')
|
10
|
-
require File.join(File.dirname(__FILE__), 'lib', 'fixtures')
|
11
|
-
end
|