mocked_fixtures 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,14 @@
1
+ == 0.3.0 2008-09-19
2
+ * Removed sqlserver adapter stuff - use my plugin sqlserver_adapter_mods if need arises
3
+ * Added more specs
4
+
1
5
  == 0.2.0 2008-09-04
2
6
 
3
7
  * New features:
4
8
  * Added blocks to mock fixture accessors to allow neater customisation of mock objects as they are loaded
5
9
  * Refactored hooks for loading mock fixtures on test setup. Much simpler and handles Rails 2.0 and 2.1
6
10
  without load order issues with rspec-rails
7
-
11
+
8
12
  == 0.1.0 2008-09-03
9
13
 
10
14
  * 1 major enhancement:
@@ -8,7 +8,6 @@ config/hoe.rb
8
8
  config/requirements.rb
9
9
  init.rb
10
10
  lib/mocked_fixtures.rb
11
- lib/mocked_fixtures/connection_adapters/sqlserver_adapter.rb
12
11
  lib/mocked_fixtures/mock_connection.rb
13
12
  lib/mocked_fixtures/mock_factory.rb
14
13
  lib/mocked_fixtures/mock_fixtures.rb
@@ -21,7 +20,6 @@ lib/mocked_fixtures/testcase.rb
21
20
  lib/mocked_fixtures/version.rb
22
21
  script/console
23
22
  script/txt2html
24
- spec/connection_adapters/sqlserver_adapter_spec.rb
25
23
  spec/mock_connection_spec.rb
26
24
  spec/mock_factory_spec.rb
27
25
  spec/mock_fixtures_spec.rb
data/README.txt CHANGED
@@ -9,33 +9,33 @@
9
9
 
10
10
  == DESCRIPTION:
11
11
 
12
- Yes, lets laugh at those silly fixtures with their silly yaml or comma
12
+ Yes, lets laugh at those silly fixtures with their silly yaml or comma
13
13
  separated values! Ha ha ha! Don't they know how passe they are. All the cool kids
14
14
  are mocking and stubbing. Get with the times fixtures!
15
15
 
16
16
  Well actually fixtures still have their place. Especially with the foxy fixtures
17
- extensions added to Rails 2.0, they are now much easier to use. Problem is the
18
- undesirable database overhead that comes with reloading your fixtures for every
19
- test. Also, in controller and view tests, the database layer is unnecessary and
17
+ extensions added to Rails 2.0, they are now much easier to use. Problem is the
18
+ undesirable database overhead that comes with reloading your fixtures for every
19
+ test. Also, in controller and view tests, the database layer is unnecessary and
20
20
  using mock objects for test isolation is often preferred.
21
21
 
22
22
  This poses another challenge of the often tedious creation those mocks to return
23
- the values you need for tests much like you did for your fixtures. But what if
24
- you could reuse those fixtures as mocks where you don't need real ActiveRecord
23
+ the values you need for tests much like you did for your fixtures. But what if
24
+ you could reuse those fixtures as mocks where you don't need real ActiveRecord
25
25
  objects. Well thats where mocked_fixtures comes in.
26
26
 
27
27
  This plugin helps by allowing you use your fixtures as disconnected mock objects
28
- which never touch the database when loaded or used. So you can now keep using
28
+ which never touch the database when loaded or used. So you can now keep using
29
29
  those thoughtfully crafted fixtures in your controller and view tests but minus
30
30
  the database overhead.
31
31
 
32
32
  A mocked fixture is a mock model object with all the model attributes stubbed
33
- out to return the values from the fixture if defined. If no fixture value was
33
+ out to return the values from the fixture if defined. If no fixture value was
34
34
  defined then a nil is returned for the attribute method as you would expect.
35
- There are no attribute setters defined on the object as they are left for you
35
+ There are no attribute setters defined on the object as they are left for you
36
36
  to do as necessary.
37
37
 
38
- The attributes for each model are read from the schema.rb file to avoid any
38
+ The attributes for each model are read from the schema.rb file to avoid any
39
39
  database access at all!
40
40
 
41
41
  == FEATURES/PROBLEMS:
@@ -50,13 +50,13 @@ database access at all!
50
50
 
51
51
  What it doesn't do:
52
52
 
53
- * Touch the database. This means that the fixtures are not inserted in the
53
+ * Touch the database. This means that the fixtures are not inserted in the
54
54
  tables, thats not what the plugin is for.
55
55
  * Create mock objects with the attribute setters. Only reader methods.
56
56
 
57
57
 
58
58
  Disclaimer:
59
- It is worth noting that the plugin is highly coupled to the Rails fixtures
59
+ It is worth noting that the plugin is highly coupled to the Rails fixtures
60
60
  implementation and so would likely break with future changes to the fixtures API.
61
61
 
62
62
  == SYNOPSIS:
@@ -65,28 +65,28 @@ To get going you installed as a gem you need to require the plugin at the top
65
65
  of your test_helper or spec_helper file. If you installed as a Rails plugin then
66
66
  you can skip that step.
67
67
 
68
- If you are using test/unit then you need specify which mocking library you
68
+ If you are using test/unit then you need specify which mocking library you
69
69
  are using in your test_helper like so:
70
70
 
71
71
  class Test::Unit::TestCase
72
-
72
+
73
73
  # can be one of :flexmock or :mocha
74
- self.mock_fixtures_with :flexmock
74
+ self.mock_fixtures_with :flexmock
75
75
  end
76
-
76
+
77
77
  If you are using Rspec you need to set it in the configure block:
78
78
 
79
79
  Spec::Runner.configure do |config|
80
-
80
+
81
81
  # can be one of :rspec, :flexmock or :mocha
82
82
  config.mock_fixtures_with :rspec
83
83
  end
84
84
 
85
- If you are using something other than the supported libraries then you get an
85
+ If you are using something other than the supported libraries then you get an
86
86
  error alerting the plugin can't be used with that library. You can then write you own
87
- interface to the plugin for that library if you want. See the files in
87
+ interface to the plugin for that library if you want. See the files in
88
88
  lib/mocked_fixtures/mocks and the spec for mock fixture objects in spec/mock_factory_spec.rb.
89
-
89
+
90
90
  On to the good stuff. Now if you have a Company model and fixture for the model
91
91
  like this
92
92
 
@@ -101,19 +101,19 @@ or spec at the top
101
101
  mock_fixtures :companies
102
102
 
103
103
  def setup
104
- @company = mock_companies(:megacorp)
104
+ @company = mock_companies(:megacorp)
105
105
  end
106
-
106
+
107
107
  def test_does_something
108
108
  assert_equal @company.moto, 'Do Evil'
109
109
  end
110
110
  end
111
-
112
- All the attributes will be stubbed to return the values from the fixture. The
111
+
112
+ All the attributes will be stubbed to return the values from the fixture. The
113
113
  fixture is generated using the internal Rails fixtures class, so any of fixture
114
114
  tricks, such as association labels and automatically generated ids, will work.
115
115
 
116
- If you want more than one fixture, then like normal fixtures you list the
116
+ If you want more than one fixture, then like normal fixtures you list the
117
117
  fixture keys to get back an array of the objects.
118
118
 
119
119
  @companies = mock_companies(:megacorp, :bigstuff)
@@ -124,6 +124,15 @@ To quickly grab all of the fixtures you call use the :all option
124
124
  @companies = mock_companies(:all)
125
125
 
126
126
 
127
+ You can also pass a block to the fixture accessor method to neatly customize the mock
128
+ object for local use
129
+
130
+ @company = mock_companies(:megacorp) do |c|
131
+ c.stub!(:some_method).and_return('special value')
132
+ end
133
+
134
+ The block is called on all mock fixtures returned.
135
+
127
136
  Like regular fixtures you can also declare global mock fixtures to pre-load for all
128
137
  your tests. Because the mock fixtures don't access the database it doesn't slow down
129
138
  the running of tests like global fixtures can.
@@ -131,33 +140,34 @@ the running of tests like global fixtures can.
131
140
  To setup global mock fixtures, in your test_helper put:
132
141
 
133
142
  class Test::Unit::TestCase
134
-
143
+
135
144
  self.global_mock_fixtures = :companies
136
145
  end
137
-
146
+
138
147
  If you are using Rspec you need to set it in the configure block:
139
148
 
140
149
  Spec::Runner.configure do |config|
141
-
150
+
142
151
  config.global_mock_fixtures = :companies
143
152
  end
144
153
 
145
154
  You can also set the global to :all and all fixtures will be loaded as mocks. This
146
- can add some test startup time if you have a lot of fixtures but shouldn't slow
155
+ can add some test startup time if you have a lot of fixtures but shouldn't slow
147
156
  down your tests when running at all. Might use a bit of memory though.
148
157
 
149
158
  Thats all for now, so mock on!
150
159
 
151
160
 
152
161
  NOTE:
153
- If you use MS SQL Server then you need to apply a fix for this adapter to
154
- correctly dump primary keys when not named 'id'. Just drop this line in an
155
- initializer file
162
+ If you use MS SQL Server then you may need to apply a fix for this adapter to
163
+ correctly dump primary keys when not named 'id'. I have a plugin to help with that
164
+ and other minor adapter issues. To install it
165
+
166
+ ./script/plugin install git://github.com/adzap/sqlserver_adapter_mods.git
156
167
 
157
- require 'mocked_fixtures/connection_adapters/sqlserver_adapter'
168
+ Once installed you then need to do a dump. Um, keep your pants on, I mean a database
169
+ dump with
158
170
 
159
- You then need to do a dump. Um, keep your pants on, I mean a database dump with
160
-
161
171
  rake db:schema:dump
162
172
 
163
173
  Now the schema.rb file should be complete.
@@ -1,7 +1,7 @@
1
1
  module MockedFixtures
2
2
  class MockConnection
3
3
  attr_accessor :schema, :loaded_fixtures, :current_fixture_label
4
-
4
+
5
5
  # mock column class which is used in Fixtures class insert_fixtures method
6
6
  class Column
7
7
  attr_accessor :name, :type
@@ -9,31 +9,31 @@ module MockedFixtures
9
9
  @name, @type = name, type
10
10
  end
11
11
  end
12
-
12
+
13
13
  def initialize
14
14
  @schema = @@schema ||= MockedFixtures::SchemaParser.load_schema
15
15
  @columns = {}
16
16
  @loaded_fixtures = {}
17
17
  end
18
-
18
+
19
19
  # stores full fixture after association values loaded and type casting
20
20
  def insert_fixture(fixture, table_name)
21
21
  loaded_fixtures[table_name] ||= {}
22
22
  loaded_fixtures[table_name][@current_fixture_label] = type_cast_fixture(fixture, table_name)
23
23
  end
24
-
24
+
25
25
  def type_cast_fixture(fixture, table_name)
26
- fixture.to_hash.inject({}) do |new_hash, row|
26
+ fixture.to_hash.inject({}) do |new_hash, (k, v)|
27
27
  begin
28
- type = @schema[table_name.to_s][:columns].assoc(row[0])[1]
29
- new_hash[row[0].to_sym] = type_cast_value(type, row[1])
28
+ type = @schema[table_name.to_s][:columns].assoc(k)[1]
29
+ new_hash[k.to_sym] = type_cast_value(type, v)
30
30
  new_hash
31
31
  rescue
32
- raise "Mock fixture key '#{row[0]}' not found in schema '#{table_name}'"
32
+ raise "Mock fixture key '#{k}' not found in schema '#{table_name}'"
33
33
  end
34
34
  end
35
35
  end
36
-
36
+
37
37
  # Modified from ActiveRecord::Column class.
38
38
  def type_cast_value(type, value)
39
39
  return nil if value.nil?
@@ -52,8 +52,8 @@ module MockedFixtures
52
52
  when :boolean then column.value_to_boolean(value)
53
53
  else value
54
54
  end
55
- end
56
-
55
+ end
56
+
57
57
  def columns(table_name)
58
58
  @columns[table_name] ||= @schema[table_name.to_s][:columns].collect {|c| Column.new(c[0], c[1]) }
59
59
  end
@@ -1,7 +1,7 @@
1
1
  module MockedFixtures
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 2
4
+ MINOR = 3
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -2,5 +2,62 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe MockedFixtures::MockConnection do
4
4
 
5
+ before do
6
+ @conn = MockedFixtures::MockConnection.new
7
+ end
8
+
9
+ it "should return schema columns for table as MockedFixtures::MockConnection::Column instances" do
10
+ @conn.columns(['companies']).should have(5).instances_of(MockedFixtures::MockConnection::Column)
11
+ end
12
+
13
+ describe "type_cast_value" do
14
+ it "should return correct value for integer type" do
15
+ cast(:integer, '1').should == 1
16
+ end
17
+
18
+ it "should return correct value for string type" do
19
+ cast(:string, '1').should == '1'
20
+ end
21
+
22
+ it "should return correct value for date type" do
23
+ cast(:date, '2008-01-01').should == Date.new(2008, 1, 1)
24
+ end
25
+
26
+ it "should return correct value for datetime type" do
27
+ cast(:datetime, '2008-01-01').should == Time.mktime(2008, 1, 1)
28
+ end
29
+
30
+ def cast(type, value)
31
+ @conn.type_cast_value(type, value)
32
+ end
33
+ end
34
+
35
+ it "should type cast fixture" do
36
+ fixture = Fixture.new([['cid', '1'],['name', 'Mega Corp'], ['created_at', '2008-01-02 03:04:05.1']], Company)
37
+ @conn.type_cast_fixture(fixture, 'companies').should === {:cid => 1, :name => 'Mega Corp', :created_at => Time.mktime(2008,1,2,3,4,5,100000)}
38
+ end
39
+
40
+ it 'should insert fixture' do
41
+ @conn.instance_variable_set(:@current_fixture_label, :mega_corp)
42
+ fixture = Fixture.new([['cid', '1'],['name', 'Mega Corp'], ['created_at', '2008-01-02 03:04:05.1']], Company)
43
+ cast_fixture = @conn.type_cast_fixture(fixture, 'companies')
44
+
45
+ @conn.insert_fixture(fixture, 'companies')
46
+ @conn.loaded_fixtures.should == {'companies' => {:mega_corp => cast_fixture} }
47
+ end
48
+
49
+ describe "Column" do
50
+ before do
51
+ @column = MockedFixtures::MockConnection::Column.new('cid', 'integer')
52
+ end
53
+
54
+ it "should return column name" do
55
+ @column.name.should == 'cid'
56
+ end
57
+
58
+ it "should return column type" do
59
+ @column.type.should == 'integer'
60
+ end
61
+ end
5
62
 
6
63
  end
@@ -1,25 +1,25 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe MockedFixtures::MockFixtures do
4
-
4
+
5
5
  before(:all) do
6
6
  # just making sure we don't hit the database at all
7
- ActiveRecord::Base.connection.disconnect! rescue nil
7
+ disconnect_db
8
8
  end
9
-
10
- after(:all) do
11
- ActiveRecord::Base.connection.reconnect! rescue nil
9
+
10
+ after(:all) do
11
+ connect_db
12
12
  end
13
-
13
+
14
14
  before(:each) do
15
15
  @fixture_path = Test::Unit::TestCase.fixture_path
16
- end
16
+ end
17
17
 
18
18
  it "should return primary key for fixture table" do
19
19
  fixtures = MockedFixtures::MockFixtures.create_fixtures(@fixture_path, [:companies])
20
20
  fixtures[0].primary_key_name.should == 'cid'
21
- end
22
-
21
+ end
22
+
23
23
  it "should create fixtures" do
24
24
  fixtures = MockedFixtures::MockFixtures.create_fixtures(@fixture_path, [:companies])
25
25
  fixtures.should have(1).instance_of(Fixture)
@@ -30,5 +30,5 @@ describe MockedFixtures::MockFixtures do
30
30
  fixtures = MockedFixtures::MockFixtures.create_fixtures(@fixture_path, [:employees])
31
31
  fixtures.first['adam'][:company_id].should == Fixtures.identify('mega_corp')
32
32
  end
33
-
33
+
34
34
  end
@@ -38,41 +38,21 @@ Test::Unit::TestCase.fixture_path = File.expand_path(File.dirname(__FILE__) + '/
38
38
  ActiveRecord::Migration.verbose = false
39
39
 
40
40
  ActiveRecord::Base.configurations['sqlite'] = {
41
- :adapter => 'sqlite3',
41
+ :adapter => 'sqlite3',
42
42
  :database => ':memory:'
43
43
  }
44
44
 
45
- ActiveRecord::Base.configurations['mssql'] = {
46
- :adapter => 'sqlserver',
47
- :host => 'localhost',
48
- :mode => 'odbc',
49
- :dsn => 'activerecord_unittest',
50
- :database => 'activerecord_unittest',
51
- :username => 'rails',
52
- :password => nil
53
- }
54
-
55
45
  ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['sqlite'])
56
46
 
57
47
  module SpecHelpers
58
- def self.included(base)
59
- base.extend ClassMethods
60
- end
61
-
62
- module ClassMethods
63
- def connect_db(config)
64
- before(:all) do
65
- ActiveRecord::Base.connection.disconnect! rescue nil
66
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[config])
67
- require 'resources/schema'
68
- end
69
- end
70
-
71
- def disconnect_db
72
- after(:all) do
73
- ActiveRecord::Base.connection.disconnect! rescue nil
74
- end
75
- end
48
+ def connect_db(config='sqlite')
49
+ ActiveRecord::Base.connection.disconnect! rescue nil
50
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[config])
51
+ require 'resources/schema'
52
+ end
53
+
54
+ def disconnect_db
55
+ ActiveRecord::Base.connection.disconnect! rescue nil
76
56
  end
77
57
  end
78
58
 
@@ -1,75 +1,75 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe 'Test::Unit::TestCase', "when extended with mocked_fixtures" do
4
-
4
+
5
5
  def klass
6
6
  Test::Unit::TestCase
7
7
  end
8
-
8
+
9
9
  it "should include the mock_fixtures class method" do
10
10
  klass.methods.should include('mock_fixtures')
11
- end
12
-
11
+ end
12
+
13
13
  it "should include aliased setup method for mock fixtures" do
14
14
  klass.instance_methods.should include('setup_with_mock_fixtures')
15
15
  end
16
-
16
+
17
17
  it "should include global_mock_fixtures method" do
18
18
  klass.methods.should include('global_mock_fixtures')
19
19
  end
20
-
20
+
21
21
  it "should define mock fixture accessor methods" do
22
22
  klass.setup_mock_fixture_accessors(['companies'])
23
23
  klass.instance_methods.should include('mock_companies')
24
24
  end
25
-
25
+
26
26
  it "should return all fixture table names" do
27
27
  klass.all_fixture_table_names.should include('employees', 'companies')
28
28
  end
29
-
29
+
30
30
  describe "global mock fixtures" do
31
31
  it "should be included for loading" do
32
32
  klass.global_mock_fixtures = :companies
33
33
  klass.mock_fixtures :employees
34
34
  klass.mock_fixture_table_names.should include('companies')
35
35
  end
36
-
36
+
37
37
  it "should include all fixtures if equals :all" do
38
38
  klass.global_mock_fixtures = :all
39
39
  klass.mock_fixture_table_names.should include('employees', 'companies')
40
40
  end
41
41
  end
42
-
42
+
43
43
  describe "mocked fixture accessors" do
44
- mock_fixtures :companies, :employees
45
-
44
+ mock_fixtures :companies, :employees
45
+
46
46
  before(:all) do
47
47
  Test::Unit::TestCase.mock_fixtures_with :rspec
48
48
  end
49
-
49
+
50
50
  it "should return single mock fixture object" do
51
51
  mock_companies(:mega_corp).name.should == 'Mega Corporation'
52
52
  end
53
-
53
+
54
54
  it "should return all named fixtures as array" do
55
55
  mock_employees(:adam, :jane).size.should == 2
56
56
  end
57
-
57
+
58
58
  it "should return all fixtures when passed :all option" do
59
59
  mock_employees(:all).size.should == 2
60
60
  end
61
-
61
+
62
62
  it "should raise error when fixture cannot be found" do
63
63
  lambda { mock_companies(:non_fixture) }.should raise_error(StandardError, /No fixture named 'non_fixture'/)
64
64
  end
65
-
65
+
66
66
  it "should call block on mock object requested" do
67
67
  employee = mock_employees(:adam) do |e|
68
68
  e.stub!(:last_name).and_return('MEEHAN')
69
69
  end
70
70
  employee.last_name.should == "MEEHAN"
71
71
  end
72
-
72
+
73
73
  it "should call block on all mock objects requested" do
74
74
  employees = mock_employees(:adam, :jane) do |e|
75
75
  e.stub!(:last_name).and_return('same')
@@ -77,13 +77,10 @@ describe 'Test::Unit::TestCase', "when extended with mocked_fixtures" do
77
77
  employees.all? {|e| e.last_name.should == "same" }
78
78
  end
79
79
  end
80
-
80
+
81
81
  describe "regular fixtures" do
82
82
  fixtures :companies
83
-
84
- connect_db('sqlite')
85
- disconnect_db
86
-
83
+
87
84
  it "should be loaded" do
88
85
  companies(:mega_corp).should_not be_nil
89
86
  end
@@ -1,86 +1,11 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
- <title>
8
- mocked_fixtures
9
- </title>
10
- <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
- <style>
12
-
13
- </style>
14
- <script type="text/javascript">
15
- window.onload = function() {
16
- settings = {
17
- tl: { radius: 10 },
18
- tr: { radius: 10 },
19
- bl: { radius: 10 },
20
- br: { radius: 10 },
21
- antiAlias: true,
22
- autoPad: true,
23
- validTags: ["div"]
24
- }
25
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
26
- versionBox.applyCornersToAll();
27
- }
28
- </script>
29
- </head>
30
- <body>
31
- <div id="main">
32
-
33
- <h1>mocked_fixtures</h1>
34
- <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/mocked_fixtures"; return false'>
35
- <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/mocked_fixtures" class="numbers">0.1.0</a>
37
- </div>
38
- <h1>&amp;#x2192; &#8216;mocked_fixtures&#8217;</h1>
39
- <h2>What</h2>
40
- <h2>Installing</h2>
41
- <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">mocked_fixtures</span></pre></p>
42
- <h2>The basics</h2>
43
- <h2>Demonstration of usage</h2>
44
- <h2>Forum</h2>
45
- <p><a href="http://groups.google.com/group/mocked_fixtures">http://groups.google.com/group/mocked_fixtures</a></p>
46
- <p><span class="caps">TODO</span> &#8211; create Google Group &#8211; mocked_fixtures</p>
47
- <h2>How to submit patches</h2>
48
- <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
49
- <p><span class="caps">TODO</span> &#8211; pick <span class="caps">SVN</span> or Git instructions</p>
50
- <p>The trunk repository is <code>svn://rubyforge.org/var/svn/mocked_fixtures/trunk</code> for anonymous access.</p>
51
- <p><span class="caps">OOOORRRR</span></p>
52
- <p>You can fetch the source from either:</p>
53
- <ul>
54
- <li>rubyforge: <span class="caps">MISSING</span> IN <span class="caps">ACTION</span></li>
55
- </ul>
56
- <p><span class="caps">TODO</span> &#8211; You can not created a RubyForge project, OR have not run <code>rubyforge config</code><br />
57
- yet to refresh your local rubyforge data with this projects&#8217; id information.</p>
58
- <p>When you do this, this message will magically disappear!</p>
59
- <p>Or you can hack website/index.txt and make it all go away!!</p>
60
- <ul>
61
- <li>github: <a href="http://github.com/GITHUB_USERNAME/mocked_fixtures/tree/master">http://github.com/GITHUB_USERNAME/mocked_fixtures/tree/master</a></li>
62
- </ul>
63
- <pre>git clone git://github.com/GITHUB_USERNAME/mocked_fixtures.git</pre>
64
- <p><span class="caps">TODO</span> &#8211; add &#8220;github_username: username&#8221; to ~/.rubyforge/user-config.yml and newgem will reuse it for future projects.</p>
65
- <ul>
66
- <li>gitorious: <a href="git://gitorious.org/mocked_fixtures/mainline.git">git://gitorious.org/mocked_fixtures/mainline.git</a></li>
67
- </ul>
68
- <pre>git clone git://gitorious.org/mocked_fixtures/mainline.git</pre>
69
- <h3>Build and test instructions</h3>
70
- <pre>cd mocked_fixtures
71
- rake test
72
- rake install_gem</pre>
73
- <h2>License</h2>
74
- <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
75
- <h2>Contact</h2>
76
- <p>Comments are welcome. Send an email to <a href="mailto:FIXME"><span class="caps">FIXME</span> full name</a> email via the <a href="http://groups.google.com/group/mocked_fixtures">forum</a></p>
77
- <p class="coda">
78
- <a href="FIXME email">FIXME full name</a>, 25th July 2008<br>
79
- Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
80
- </p>
81
- </div>
82
-
83
- <!-- insert site tracking codes here, like Google Urchin -->
84
-
85
- </body>
86
- </html>
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
4
+ <title>mocked_fixtures</title>
5
+
6
+ </head>
7
+ <body id="body">
8
+ <p>This page has not yet been created for RubyGem <code>mocked_fixtures</code></p>
9
+ <p>To the developer: To generate it, update website/index.txt and run the rake task <code>website</code> to generate this <code>index.html</code> file.</p>
10
+ </body>
11
+ </html>
@@ -21,6 +21,8 @@ h2. Forum
21
21
 
22
22
  "http://groups.google.com/group/mocked_fixtures":http://groups.google.com/group/mocked_fixtures
23
23
 
24
+ TODO - create Google Group - mocked_fixtures
25
+
24
26
  h2. How to submit patches
25
27
 
26
28
  Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocked_fixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-04 00:00:00 +10:00
12
+ date: 2008-09-19 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -47,7 +47,6 @@ files:
47
47
  - config/requirements.rb
48
48
  - init.rb
49
49
  - lib/mocked_fixtures.rb
50
- - lib/mocked_fixtures/connection_adapters/sqlserver_adapter.rb
51
50
  - lib/mocked_fixtures/mock_connection.rb
52
51
  - lib/mocked_fixtures/mock_factory.rb
53
52
  - lib/mocked_fixtures/mock_fixtures.rb
@@ -60,7 +59,6 @@ files:
60
59
  - lib/mocked_fixtures/version.rb
61
60
  - script/console
62
61
  - script/txt2html
63
- - spec/connection_adapters/sqlserver_adapter_spec.rb
64
62
  - spec/mock_connection_spec.rb
65
63
  - spec/mock_factory_spec.rb
66
64
  - spec/mock_fixtures_spec.rb
@@ -1,25 +0,0 @@
1
- # This adds the method to find the primary key for the schema dumper so that
2
- # the schema will correctly define the primary key. Need to get this into the
3
- # real adapter obviously, though the project seems almost dead.
4
- module MockedFixtures
5
- module ConnectionAdapters
6
- module SQLServerAdapter
7
-
8
- # Returns a table's primary key and belonging sequence (not applicable to SQL server).
9
- def pk_and_sequence_for(table_name)
10
- @connection["AutoCommit"] = false
11
- keys = []
12
- execute("EXEC sp_helpindex '#{table_name}'") do |handle|
13
- if handle.column_info.any?
14
- pk_index = handle.detect {|index| index[1] =~ /primary key/ }
15
- keys << pk_index[2] if pk_index
16
- end
17
- end
18
- keys.length == 1 ? [keys.first, nil] : nil
19
- ensure
20
- @connection["AutoCommit"] = true
21
- end
22
-
23
- end
24
- end
25
- end
@@ -1,31 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- begin
4
- gem 'activerecord-sqlserver-adapter'
5
- require 'active_record/connection_adapters/sqlserver_adapter'
6
- require 'mocked_fixtures/connection_adapters/sqlserver_adapter'
7
- rescue LoadError, StandardError
8
- puts 'Testing ActiveRecord SQLServer Adapter skipped'
9
- end
10
-
11
- if defined?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
12
-
13
- ActiveRecord::ConnectionAdapters::SQLServerAdapter.send(:include, MockedFixtures::ConnectionAdapters::SQLServerAdapter)
14
-
15
- describe MockedFixtures::ConnectionAdapters::SQLServerAdapter do
16
- connect_db('mssql')
17
-
18
- it "should allow SchemDumper to dump primary key option for pk other than 'id'" do
19
- schema = StringIO.new
20
- dumper = ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, schema)
21
- schema.rewind
22
- schema.read.should match(/create_table "companies", :primary_key => "cid"/)
23
- end
24
-
25
- it "should return primary key and sequence" do
26
- ActiveRecord::Base.connection.pk_and_sequence_for('companies').should == ['cid', nil]
27
- end
28
-
29
- disconnect_db
30
- end
31
- end