sinsiliux-hornsby 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -49,13 +49,21 @@ duplicating data.
49
49
 
50
50
  == Setup
51
51
 
52
- Install the plugin:
52
+ The easiest way to install this gem for Ruby on Rails is just add this line to config/environment.rb (or config/environments/test.rb):
53
53
 
54
- ./script/plugin install git://github.com/lachie/hornsby.git
54
+ config.gem 'sinsiliux-hornsby', :lib => 'hornsby', :source => 'http://gems.github.com'
55
+
56
+ If you’re not using rails, then you can install it through command line
57
+
58
+ gem sources -a http://gems.github.com
59
+ sudo gem install sinsiliux-hornsby
60
+
61
+ Lastly you could use it as plugin:
62
+
63
+ ruby script/plugin install git://github.com/sinsiliux/hornsby.git
55
64
 
56
65
  Add the following to spec_helper.rb
57
66
 
58
- # by default this loads scenarios from RAILS_ROOT/spec/hornsby_scenarios.rb
59
67
  Spec::Runner.configure do |config|
60
68
  ...
61
69
 
@@ -63,10 +71,9 @@ Add the following to spec_helper.rb
63
71
  end
64
72
 
65
73
  configure_rspec supports two parameters:
66
- * filename - file with hornsby scenarios
74
+ * filename - file with hornsby scenarios (by default Rails.root/spec/hornsby_scenarios.rb)
67
75
  * scenarios - list of hornsby scenarios that should be preloaded (available in all tests, never reloaded so they're much faster)
68
76
 
69
-
70
77
  == Advanced Usage
71
78
 
72
79
  Its just ruby, right? So go nuts:
data/lib/hornsby.rb CHANGED
@@ -70,7 +70,7 @@ class Hornsby
70
70
  end
71
71
 
72
72
  def self.skip_tables
73
- %w( schema_info )
73
+ %w( schema_info schema_migrations )
74
74
  end
75
75
 
76
76
  def self.copy_ivars(to, reload = false)
@@ -139,4 +139,8 @@ module HornsbySpecHelper
139
139
  Hornsby.build(*names)
140
140
  Hornsby.copy_ivars(self)
141
141
  end
142
- end
142
+
143
+ def hornsby_clear
144
+ Hornsby.delete_tables
145
+ end
146
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__)+'/../lib/hornsby'
1
+ require File.dirname(__FILE__)+'/../hornsby'
2
2
 
3
3
  namespace :hornsby do
4
4
 
@@ -9,4 +9,4 @@ namespace :hornsby do
9
9
  ::Hornsby.build(ENV['SCENARIO'])
10
10
  end
11
11
 
12
- end
12
+ end
data/spec/hornsby_spec.rb CHANGED
@@ -74,6 +74,11 @@ describe Hornsby, 'with preloaded cherry scenario' do
74
74
  it "should create big cherry" do
75
75
  @big_cherry.species.should == 'cherry'
76
76
  end
77
+
78
+ it "should clear scenarios when calling hornsby_clear" do
79
+ hornsby_clear
80
+ Fruit.count.should == 0
81
+ end
77
82
  end
78
83
 
79
84
  describe Hornsby, 'with many apples scenario' do
@@ -82,11 +87,11 @@ describe Hornsby, 'with many apples scenario' do
82
87
  end
83
88
 
84
89
  it "should create only one apple" do
85
- Fruit.all(:conditions => 'species = "apple"').count.should == 1
90
+ Fruit.all(:conditions => 'species = "apple"').size.should == 1
86
91
  end
87
92
 
88
93
  it "should create only two cherries even if they were preloaded" do
89
- Fruit.all(:conditions => 'species = "cherry"').count.should == 2
94
+ Fruit.all(:conditions => 'species = "cherry"').size.should == 2
90
95
  end
91
96
 
92
97
  it "should contain cherries in basket if basket is loaded in test and cherries preloaded" do
@@ -94,6 +99,26 @@ describe Hornsby, 'with many apples scenario' do
94
99
  end
95
100
  end
96
101
 
102
+ describe Hornsby, 'transactions' do
103
+ before do
104
+ hornsby_scenario :just_apple
105
+ end
106
+
107
+ it "should drop only inner transaction" do
108
+ @apple.reload.should_not be_nil
109
+ begin
110
+ ActiveRecord::Base.transaction do
111
+ f = Fruit.create(:species => 'orange')
112
+ f.reload.should_not be_nil
113
+ raise 'some error'
114
+ end
115
+ rescue
116
+ end
117
+ @apple.reload.should_not be_nil
118
+ Fruit.find_by_species('orange').should be_nil
119
+ end
120
+ end
121
+
97
122
  #describe Hornsby, "with pitted namespace" do
98
123
  # before do
99
124
  # Hornsby.build('pitted:peach').copy_ivars(self)
@@ -102,4 +127,4 @@ end
102
127
  # it "should have @peach" do
103
128
  # @peach.species.should == 'peach'
104
129
  # end
105
- #end
130
+ #end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require 'fileutils'
2
2
  require 'activerecord'
3
+ begin
4
+ require 'mysqlplus'
5
+ rescue LoadError
6
+ end
3
7
 
4
8
  spec_dir = File.dirname(__FILE__)
5
9
  Dir.chdir spec_dir
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinsiliux-hornsby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrius Chamentauskas