mocked_fixtures 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +49 -0
- data/README.txt +206 -0
- data/Rakefile +4 -0
- data/TODO.txt +5 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/init.rb +2 -0
- data/lib/mocked_fixtures/connection_adapters/sqlserver_adapter.rb +25 -0
- data/lib/mocked_fixtures/mock_connection.rb +61 -0
- data/lib/mocked_fixtures/mock_factory.rb +12 -0
- data/lib/mocked_fixtures/mock_fixtures.rb +58 -0
- data/lib/mocked_fixtures/mocks/flexmock.rb +35 -0
- data/lib/mocked_fixtures/mocks/mocha.rb +47 -0
- data/lib/mocked_fixtures/mocks/rspec.rb +40 -0
- data/lib/mocked_fixtures/schema_parser.rb +30 -0
- data/lib/mocked_fixtures/spec/configuration.rb +19 -0
- data/lib/mocked_fixtures/testcase.rb +122 -0
- data/lib/mocked_fixtures/version.rb +9 -0
- data/lib/mocked_fixtures.rb +15 -0
- data/script/console +10 -0
- data/script/txt2html +82 -0
- data/spec/connection_adapters/sqlserver_adapter_spec.rb +44 -0
- data/spec/mock_connection_spec.rb +6 -0
- data/spec/mock_factory_spec.rb +59 -0
- data/spec/mock_fixtures_spec.rb +30 -0
- data/spec/resources/companies.yml +3 -0
- data/spec/resources/company.rb +5 -0
- data/spec/resources/employee.rb +3 -0
- data/spec/resources/employees.yml +8 -0
- data/spec/resources/schema.rb +18 -0
- data/spec/rspec-rails/MIT-LICENSE +31 -0
- data/spec/rspec-rails/mocks.rb +115 -0
- data/spec/rspec-rails/rails_example_group.rb +27 -0
- data/spec/rspec-rails/rspec-rails.rb +15 -0
- data/spec/schema_parser_spec.rb +41 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/testcase_spec.rb +73 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- data/website/index.html +86 -0
- data/website/index.txt +81 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +117 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe MockedFixtures::SchemaParser do
|
4
|
+
attr_accessor :schema
|
5
|
+
|
6
|
+
before do
|
7
|
+
@schema = MockedFixtures::SchemaParser.load_schema
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should parser schema file and return hash" do
|
11
|
+
schema.should be_a_kind_of(Hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return schema hash with keys for each fixture file" do
|
15
|
+
schema.should have_key("companies")
|
16
|
+
schema.should have_key("employees")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return schema hash with 2 keys" do
|
20
|
+
schema.keys.size.should eql(2)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return schema table with columns in array" do
|
24
|
+
schema["companies"][:columns].should == [["cid", "integer"],
|
25
|
+
["name", "string"],
|
26
|
+
["address", "string"],
|
27
|
+
["created_at", "datetime"],
|
28
|
+
["updated_at", "datetime"]]
|
29
|
+
|
30
|
+
schema["employees"][:columns].should == [["id", "integer"],
|
31
|
+
["company_id", "integer"],
|
32
|
+
["first_name", "string"],
|
33
|
+
["last_name", "string"],
|
34
|
+
["created_at", "datetime"],
|
35
|
+
["updated_at", "datetime"]]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should get primary key from table definition options" do
|
39
|
+
schema["companies"][:primary_key].should == 'cid'
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
2
|
+
$:.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
|
7
|
+
require 'active_record'
|
8
|
+
require 'active_record/fixtures'
|
9
|
+
require 'active_support'
|
10
|
+
|
11
|
+
require 'rspec-rails/rspec-rails'
|
12
|
+
|
13
|
+
require 'mocked_fixtures/schema_parser'
|
14
|
+
require 'mocked_fixtures/testcase'
|
15
|
+
require 'mocked_fixtures/mock_fixtures'
|
16
|
+
require 'mocked_fixtures/mock_factory'
|
17
|
+
require 'mocked_fixtures/mock_connection'
|
18
|
+
|
19
|
+
require 'resources/company'
|
20
|
+
require 'resources/employee'
|
21
|
+
|
22
|
+
|
23
|
+
MockedFixtures::SchemaParser.schema_path = File.expand_path(File.dirname(__FILE__) + '/resources/schema.rb')
|
24
|
+
|
25
|
+
Test::Unit::TestCase.fixture_path = File.expand_path(File.dirname(__FILE__) + '/resources')
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Test::Unit::TestCase, "extended with mocked_fixtures" do
|
4
|
+
|
5
|
+
def klass
|
6
|
+
Test::Unit::TestCase
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should include the mock_fixtures class method" do
|
10
|
+
klass.methods.should include('mock_fixtures')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should include aliased setup method for mock fixtures" do
|
14
|
+
klass.instance_methods.should include('setup_with_mock_fixtures')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should include global_mock_fixtures method" do
|
18
|
+
klass.methods.should include('global_mock_fixtures')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should define mock fixture accessor methods" do
|
22
|
+
klass.setup_mock_fixture_accessors(['companies'])
|
23
|
+
klass.instance_methods.should include('mock_companies')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return all fixture table names" do
|
27
|
+
klass.all_fixture_table_names.should == ['employees', 'companies']
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "global mock fixtures" do
|
31
|
+
it "should be included for loading" do
|
32
|
+
klass.global_mock_fixtures = :companies
|
33
|
+
klass.mock_fixtures :employees
|
34
|
+
klass.mock_fixture_table_names.should include('companies')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should include all fixtures if equals :all" do
|
38
|
+
klass.global_mock_fixtures = :all
|
39
|
+
klass.mock_fixture_table_names.should == ['employees', 'companies']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "mocked fixture accessor" do
|
44
|
+
mock_fixtures :companies, :employees
|
45
|
+
|
46
|
+
before(:all) do
|
47
|
+
Test::Unit::TestCase.mock_fixtures_with :rspec
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return single mock fixture object" do
|
51
|
+
mock_companies(:mega_corp).name.should == 'Mega Corporation'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return all named fixtures as array" do
|
55
|
+
mock_employees(:adam, :jane).size.should == 2
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return all fixtures when passed :all option" do
|
59
|
+
mock_employees(:all).size.should == 2
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should raise error when fixture cannot be found" do
|
63
|
+
lambda { mock_companies(:non_fixture) }.should raise_error(StandardError, /No fixture named 'non_fixture'/)
|
64
|
+
end
|
65
|
+
|
66
|
+
#it "should execute block on mock object requested" do
|
67
|
+
# employee = mock_employees(:adam) do |employee|
|
68
|
+
# employee.stub!(:last_name).and_return(employee.last_name.upcase)
|
69
|
+
# end
|
70
|
+
# employee.last_name.should == "MEEHAN"
|
71
|
+
#end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :manifest do
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
+
task :refresh do
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
+
end
|
34
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
data/website/index.html
ADDED
@@ -0,0 +1,86 @@
|
|
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>&#x2192; ‘mocked_fixtures’</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> – create Google Group – 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’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> – 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> – 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’ 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> – add “github_username: username” 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>
|
data/website/index.txt
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
h1. mocked_fixtures
|
2
|
+
|
3
|
+
h1. → 'mocked_fixtures'
|
4
|
+
|
5
|
+
|
6
|
+
h2. What
|
7
|
+
|
8
|
+
|
9
|
+
h2. Installing
|
10
|
+
|
11
|
+
<pre syntax="ruby">sudo gem install mocked_fixtures</pre>
|
12
|
+
|
13
|
+
h2. The basics
|
14
|
+
|
15
|
+
|
16
|
+
h2. Demonstration of usage
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
h2. Forum
|
21
|
+
|
22
|
+
"http://groups.google.com/group/mocked_fixtures":http://groups.google.com/group/mocked_fixtures
|
23
|
+
|
24
|
+
h2. How to submit patches
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
28
|
+
TODO - pick SVN or Git instructions
|
29
|
+
|
30
|
+
The trunk repository is <code>svn://rubyforge.org/var/svn/mocked_fixtures/trunk</code> for anonymous access.
|
31
|
+
|
32
|
+
OOOORRRR
|
33
|
+
|
34
|
+
You can fetch the source from either:
|
35
|
+
|
36
|
+
<% if rubyforge_project_id %>
|
37
|
+
|
38
|
+
* rubyforge: "http://rubyforge.org/scm/?group_id=<%= rubyforge_project_id %>":http://rubyforge.org/scm/?group_id=<%= rubyforge_project_id %>
|
39
|
+
|
40
|
+
<pre>git clone git://rubyforge.org/mocked_fixtures.git</pre>
|
41
|
+
|
42
|
+
<% else %>
|
43
|
+
|
44
|
+
* rubyforge: MISSING IN ACTION
|
45
|
+
|
46
|
+
TODO - You can not created a RubyForge project, OR have not run <code>rubyforge config</code>
|
47
|
+
yet to refresh your local rubyforge data with this projects' id information.
|
48
|
+
|
49
|
+
When you do this, this message will magically disappear!
|
50
|
+
|
51
|
+
Or you can hack website/index.txt and make it all go away!!
|
52
|
+
|
53
|
+
<% end %>
|
54
|
+
|
55
|
+
* github: "http://github.com/GITHUB_USERNAME/mocked_fixtures/tree/master":http://github.com/GITHUB_USERNAME/mocked_fixtures/tree/master
|
56
|
+
|
57
|
+
<pre>git clone git://github.com/GITHUB_USERNAME/mocked_fixtures.git</pre>
|
58
|
+
|
59
|
+
|
60
|
+
TODO - add "github_username: username" to ~/.rubyforge/user-config.yml and newgem will reuse it for future projects.
|
61
|
+
|
62
|
+
|
63
|
+
* gitorious: "git://gitorious.org/mocked_fixtures/mainline.git":git://gitorious.org/mocked_fixtures/mainline.git
|
64
|
+
|
65
|
+
<pre>git clone git://gitorious.org/mocked_fixtures/mainline.git</pre>
|
66
|
+
|
67
|
+
h3. Build and test instructions
|
68
|
+
|
69
|
+
<pre>cd mocked_fixtures
|
70
|
+
rake test
|
71
|
+
rake install_gem</pre>
|
72
|
+
|
73
|
+
|
74
|
+
h2. License
|
75
|
+
|
76
|
+
This code is free to use under the terms of the MIT license.
|
77
|
+
|
78
|
+
h2. Contact
|
79
|
+
|
80
|
+
Comments are welcome. Send an email to "FIXME full name":mailto:FIXME email via the "forum":http://groups.google.com/group/mocked_fixtures
|
81
|
+
|