waves-rspec 0.2.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.tar.gz.sig ADDED
Binary file
data/History.txt ADDED
@@ -0,0 +1,5 @@
1
+ === 1.0.0 / 2008-03-06
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
data/License.txt ADDED
@@ -0,0 +1,24 @@
1
+ == LICENSE:
2
+
3
+ (The MIT License)
4
+
5
+ Copyright (c) 2008 Pascal Belloncle (http://blog.nanorails.com)
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ 'Software'), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,18 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ generators/rspec/templates/spec.opts
7
+ generators/rspec/templates/spec_helper.rb
8
+ generators/rspec_controller/templates/controller_spec.rb.erb
9
+ generators/rspec_model/templates/model_spec.rb.erb
10
+ lib/waves-rspec.rb
11
+ lib/waves-rspec/tasks.rb
12
+ lib/waves-rspec/version.rb
13
+ spec/spec.opts
14
+ spec/spec_helper.rb
15
+ spec/tasks/generate_controller_spec.rb
16
+ spec/tasks/generate_model_spec.rb
17
+ spec/tasks/generate_rspec_spec.rb
18
+ tasks/waves-rspec.rake
data/README.txt ADDED
@@ -0,0 +1,69 @@
1
+ = waves-rspec
2
+
3
+ * http://blog.nanorails.com/waves-rspec
4
+ * http://rubyforge.org/projects/waves-rspec/
5
+
6
+ == DESCRIPTION:
7
+
8
+ RSpec support for the Waves Framework
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * creates a spec skeleton wit
13
+ rake generate:rspec
14
+
15
+ * Adds Spec generation to waves generators
16
+ rake generate:model name=...
17
+ rake generate:controller name=...
18
+
19
+ * Adds tasks to run specs
20
+ rake spec
21
+
22
+ == SYNOPSIS:
23
+ * requires a "test" configuration. Add ./configurations/test.rb (modeled on configurations/development.rb)
24
+
25
+ Example:
26
+
27
+ $ waves test5
28
+ ** Creating new Waves application ...
29
+ ** Application created!
30
+ $ cd test5
31
+ ## Add require 'waves-spec' in rakefile
32
+ $ mkdir db
33
+ ## Create test configuration with (for example) [database :adapter => 'sqlite', :database => 'db/test5_test']
34
+ $ rake generate:rspec
35
+ $ rake generate:model name=task
36
+ (in /Users/psq/src/waves/test5)
37
+ ** spec/models created
38
+ ** spec/models/task_spec.rb created
39
+ $ rake schema:migration name=task
40
+ ## Fill migration
41
+ $ rake schema:migrate mode=test --trace
42
+ (in /Users/psq/src/waves/test5)
43
+ ** Invoke schema:migrate (first_time)
44
+ ** Execute schema:migrate
45
+ $ rake spec
46
+ (in /Users/psq/src/waves/test5)
47
+ Ruby/Extensions: String#starts_with? is already defined; not overwriting
48
+ .
49
+
50
+ Finished in 0.190411 seconds
51
+
52
+ 1 example, 0 failures
53
+
54
+
55
+ == REQUIREMENTS:
56
+
57
+ * waves
58
+
59
+ == INSTALL:
60
+
61
+ * sudo gem install waves-rspec
62
+
63
+ * add "require 'waves-rspec" to your Rakefile
64
+
65
+ == DEVELOPING WITH WAVES LOCALLY
66
+ easiest it to install as a local gem inside waves with
67
+
68
+ rake package
69
+ gem install --local pkg/*.gem -i [WAVE_APP]/gems/
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/waves-rspec.rb'
6
+
7
+ Hoe.new('waves-rspec', WavesRspec::VERSION::STRING) do |p|
8
+ p.rubyforge_name = 'waves-rspec'
9
+ p.author = 'Pascal Belloncle (nano RAILS)'
10
+ p.email = 'psq@nanorails.com'
11
+ # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
12
+ # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
13
+ # p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
14
+ end
15
+
16
+ # vim: syntax=Ruby
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
@@ -0,0 +1,30 @@
1
+ # This file is copied to ~/spec when you run 'rake generate:rspec' from the project root directory.
2
+
3
+ if File.exist?(waves_src = File.join(File.dirname(__FILE__), '..', 'waves'))
4
+ $:.unshift(File.join(waves_src, 'lib'))
5
+ end
6
+
7
+ ENV["mode"] = "test"
8
+ require 'rubygems'
9
+ require 'waves'
10
+ require 'spec'
11
+ Waves::Console.load(:mode => ENV['mode'])
12
+
13
+ require File.join(File.dirname(__FILE__), "..", "configurations", "test")
14
+
15
+ Spec::Runner.configure do |config|
16
+ # config.something = value
17
+
18
+ # Does this work?
19
+ # You can declare fixtures for each behaviour like this:
20
+ # describe "...." do
21
+ # fixtures :table_a, :table_b
22
+ #
23
+ # Alternatively, if you prefer to declare them only once, you can
24
+ # do so here, like so ...
25
+ #
26
+ # config.global_fixtures = :table_a, :table_b
27
+ #
28
+ # If you declare global fixtures, be aware that they will be declared
29
+ # for all of your examples, even those that don't use them.
30
+ end
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__) , '..', 'spec_helper')
2
+
3
+ describe "testing spec" do
4
+
5
+ it "should work" do
6
+ C = <%= name %>::Controllers::<%= controller %>
7
+ c = C.new(1)
8
+ c.request.should == 1
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__) , '..', 'spec_helper')
2
+
3
+ describe "testing spec" do
4
+
5
+ it "should work" do
6
+ M = <%= name %>::Models
7
+ M::<%= model %>.all.size.should == 0
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require "waves-rspec/version"
4
+ require "waves-rspec/tasks"
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), %w[.. .. tasks], '**/*.rake')].each { |rake| load rake }
@@ -0,0 +1,9 @@
1
+ module WavesRspec #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 2
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'waves'
3
+ require 'spec'
4
+
5
+ # Code from Coda Hale
6
+ def describe_rake_task(task_name, filename, &block)
7
+ require "rake"
8
+
9
+ describe "Rake task #{task_name}" do
10
+ attr_reader :task
11
+
12
+ before(:all) do
13
+ @rake = Rake::Application.new
14
+ Rake.application = @rake
15
+ load filename
16
+ @task = Rake::Task[task_name]
17
+ end
18
+
19
+ after(:all) do
20
+ Rake.application = nil
21
+ end
22
+
23
+ def invoke!
24
+ for action in task.instance_eval { @actions }
25
+ instance_eval(&action)
26
+ end
27
+ end
28
+
29
+ def tmppath(*paths)
30
+ parts = [File.dirname(__FILE__), "tmp"]
31
+ parts << (@root_time ||= Time.now.to_i.to_s)
32
+ parts += paths
33
+ # parts << rand().to_s.split(".").last
34
+ parts.collect! {|path| path.to_s}
35
+ path = File.join(*parts)
36
+ attempts = 10
37
+ while File.exists?(path)
38
+ path.succ!
39
+ attempts -= 1
40
+ raise "Unable to find a good temp pathname: #{path.inspect}" if attempts.zero?
41
+ end
42
+
43
+ File.expand_path(path)
44
+ end
45
+
46
+ def cleanup
47
+ path = File.expand_path(File.join(File.dirname(__FILE__), "tmp"))
48
+ FileUtils.rm_rf(path)
49
+ end
50
+
51
+ instance_eval(&block)
52
+ end
53
+ end
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe_rake_task "generate:controller", "tasks/waves-rspec.rake" do
4
+
5
+ module MyTestApp
6
+ end
7
+
8
+ before(:each) do
9
+ @app = tmppath(:app)
10
+ FileUtils.mkdir_p(@app)
11
+ ENV['name'] = 'my_controller'
12
+ Waves::Configurations::Default.stub!(:root).and_return(@app)
13
+ Waves.stub!(:application).and_return(MyTestApp)
14
+ end
15
+
16
+ after(:each) do
17
+ cleanup
18
+ end
19
+
20
+ it "should create spec/controller directory" do
21
+ stub!(:puts)
22
+ invoke!
23
+ File.exist?(@app / 'spec' / 'controllers').should == true
24
+ end
25
+
26
+ it "should create spec/controller/my_controller_spec.rb file" do
27
+ stub!(:puts)
28
+ invoke!
29
+ File.exist?(@app / 'spec' / 'controllers' / "#{ENV['name']}_spec.rb").should == true
30
+ end
31
+
32
+ end
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe_rake_task "generate:model", "tasks/waves-rspec.rake" do
4
+
5
+ module MyTestApp
6
+ end
7
+
8
+ before(:each) do
9
+ @app = tmppath(:app)
10
+ FileUtils.mkdir_p(@app)
11
+ ENV['name'] = 'my_model'
12
+ Waves::Configurations::Default.stub!(:root).and_return(@app)
13
+ Waves.stub!(:application).and_return(MyTestApp)
14
+ end
15
+
16
+ after(:each) do
17
+ cleanup
18
+ end
19
+
20
+ it "should create spec/model directory" do
21
+ stub!(:puts)
22
+ invoke!
23
+ File.exist?(@app / 'spec' / 'models').should == true
24
+ end
25
+
26
+ it "should create spec/model/my_model_spec.rb file" do
27
+ stub!(:puts)
28
+ invoke!
29
+ File.exist?(@app / 'spec' / 'models' / "#{ENV['name']}_spec.rb").should == true
30
+ end
31
+
32
+ end
@@ -0,0 +1,54 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe_rake_task "generate:rspec", "tasks/waves-rspec.rake" do
4
+
5
+ before(:each) do
6
+ @app = tmppath(:app)
7
+ FileUtils.mkdir_p(@app)
8
+ Waves::Configurations::Default.stub!(:root).and_return(@app)
9
+ end
10
+
11
+ after(:each) do
12
+ cleanup
13
+ end
14
+
15
+ it "should create spec directory" do
16
+ stub!(:puts)
17
+ invoke!
18
+ File.exist?(@app / 'spec').should == true
19
+ end
20
+
21
+ it "should create spec_helper.rb" do
22
+ stub!(:puts)
23
+ invoke!
24
+ File.exist?(@app / 'spec' / 'spec_helper.rb').should == true
25
+ end
26
+
27
+ it "should create specs.opt file" do
28
+ stub!(:puts)
29
+ invoke!
30
+ File.exist?(@app / 'spec' / 'spec.opts').should == true
31
+ end
32
+
33
+ it "should output the creation messages" do
34
+ should_receive(:puts).with("** spec created") do
35
+ should_receive(:puts).with("** spec/spec.opts created") do
36
+ should_receive(:puts).with("** spec/spec_helper.rb created")
37
+ end
38
+ end
39
+ invoke!
40
+ end
41
+
42
+ it "should not override the files it they are already there" do
43
+ FileUtils.mkdir_p(@app / 'spec')
44
+ FileUtils.touch(@app / 'spec' / 'spec.opts')
45
+ FileUtils.touch(@app / 'spec' / 'spec_helper.rb')
46
+ should_receive(:puts).with("** spec exists") do
47
+ should_receive(:puts).with("** spec/spec.opts exists") do
48
+ should_receive(:puts).with("** spec/spec_helper.rb exists")
49
+ end
50
+ end
51
+ invoke!
52
+ end
53
+
54
+ end
@@ -0,0 +1,88 @@
1
+ require 'fileutils'
2
+
3
+ begin
4
+ require 'spec'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'spec'
8
+ end
9
+ begin
10
+ require 'spec/rake/spectask'
11
+ rescue LoadError
12
+ puts <<-EOS
13
+ To use rspec for testing you must install rspec gem:
14
+ gem install rspec
15
+ EOS
16
+ exit(0)
17
+ end
18
+
19
+ desc "Run the specs under spec"
20
+ Spec::Rake::SpecTask.new do |t|
21
+ t.spec_opts = ['--options', "spec/spec.opts"]
22
+ t.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
24
+
25
+ namespace :generate do
26
+ desc 'Generate everything needed to use RSpec'
27
+ task :rspec do |task|
28
+ templates = File.expand_path(File.dirname(__FILE__) / '..' / 'generators' / 'rspec' / 'templates')
29
+ chdir Waves::Configurations::Default.root do
30
+ generate_dir("spec")
31
+ generate_file(templates / 'spec.opts', 'spec' / 'spec.opts')
32
+ generate_file(templates / 'spec_helper.rb', 'spec' / 'spec_helper.rb')
33
+ end
34
+ end
35
+
36
+ desc 'Generate a new model'
37
+ task :model do |task|
38
+ templates = File.expand_path(File.dirname(__FILE__) / '..' / 'generators' / 'rspec_model' / 'templates')
39
+ chdir Waves::Configurations::Default.root do
40
+ dir = 'spec' / 'models'
41
+ generate_dir(dir)
42
+
43
+ name = Waves.application.to_s
44
+ model = ENV['name'].camel_case
45
+ generate_file('', dir / "#{ENV['name']}_spec.rb") do
46
+ Erubis::Eruby.new(File.read(templates / 'model_spec.rb.erb')).result(binding)
47
+ end
48
+ end
49
+ end
50
+
51
+ desc 'Generate a new controller'
52
+ task :controller do |task|
53
+ templates = File.expand_path(File.dirname(__FILE__) / '..' / 'generators' / 'rspec_controller' / 'templates')
54
+ chdir Waves::Configurations::Default.root do
55
+ dir = 'spec' / 'controllers'
56
+ generate_dir(dir)
57
+
58
+ name = Waves.application.to_s
59
+ controller = ENV['name'].camel_case
60
+ generate_file('', dir / "#{ENV['name']}_spec.rb") do
61
+ Erubis::Eruby.new(File.read(templates / 'controller_spec.rb.erb')).result(binding)
62
+ end
63
+ end
64
+ end
65
+
66
+ def generate_dir(dir, force=false)
67
+ if File.exist?(dir) && !force
68
+ puts("** #{dir} exists")
69
+ else
70
+ FileUtils.mkdir_p(dir)
71
+ puts("** #{dir} created")
72
+ end
73
+ end
74
+
75
+ def generate_file(source, dest, force = false, &block)
76
+ if File.exist?(dest) && !force
77
+ puts("** #{dest} exists")
78
+ else
79
+ if block_given?
80
+ File.write(dest, yield)
81
+ else
82
+ FileUtils.cp(source, dest)
83
+ end
84
+ puts("** #{dest} created")
85
+ end
86
+ end
87
+
88
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: waves-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Pascal Belloncle (nano RAILS)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANwc3Ex
14
+ GTAXBgoJkiaJk/IsZAEZFgluYW5vcmFpbHMxEzARBgoJkiaJk/IsZAEZFgNjb20w
15
+ HhcNMDgwMjA0MDgzOTU3WhcNMDkwMjAzMDgzOTU3WjA+MQwwCgYDVQQDDANwc3Ex
16
+ GTAXBgoJkiaJk/IsZAEZFgluYW5vcmFpbHMxEzARBgoJkiaJk/IsZAEZFgNjb20w
17
+ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9ArQhN6DW+QBDgRR4dYn1
18
+ F6Y4O4Gmetew3JHLuNHPuTHZxYoallfj+Kq/9GBh+gaxCWECem621M4DcHug2qzR
19
+ y28ojmdCwIs3vVp8HSVpPgsTCYU1hTazcf6m1n1GJzK7/Cn5tVpKtmpggMg3KRet
20
+ B/gLZ7V+Wmobwc9hMOq7M1EJWGGu6RO4O3AVATJbhJJrxik7fudIIxVsQXHXfSbM
21
+ 4I+ckDg8rXQFLT05ZaeXluykbgpaBbqukEkmXdcRq7r+xHQiifyukW91/hOcI0VI
22
+ uymCxquaoBe6BbJyCGAqS/LAx9ghUeauiupXk7MQ2SJZR52EsAgsLwk6S6sdnmVl
23
+ AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQqXXgt
24
+ NiMYFw60w5BVh9ZfZ35vYzANBgkqhkiG9w0BAQUFAAOCAQEABp1bJbQA89xE2eUQ
25
+ P70MsQxPARP9WDZ3K8/U3iwWxFBwqBkN3rA1huu9ffDSGKuReLt1peHrITUuTGwX
26
+ XH1kvHzCs+GMxWYvvz07NNhM+Y+mAgqpKrZnLhoWrrQyz0TEUpCmoUgDzc1evn6V
27
+ 1pyu7zUQ6TFX20kYzOupVAwLfhaUv9Smj1YI/YI8lkqNJqpJLbm6Ib0Gr/sLkY/E
28
+ o1mnIpaqkxNMBS+u8/ToejKdRYOtoXb5134I8WSbkVH2mTHlVgLPVRR2uqxxyQTD
29
+ bYaWAJcLlC+oPUfD5uc2DkmnjUyAWSIEVQcL20dwU8WbYWp/oFmiRpvgYk4LLFs2
30
+ TCvXyw==
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2008-03-15 00:00:00 -07:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.1
44
+ version:
45
+ description: RSpec support for the Waves Framework
46
+ email: psq@nanorails.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - History.txt
53
+ - License.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ files:
57
+ - History.txt
58
+ - License.txt
59
+ - Manifest.txt
60
+ - README.txt
61
+ - Rakefile
62
+ - generators/rspec/templates/spec.opts
63
+ - generators/rspec/templates/spec_helper.rb
64
+ - generators/rspec_controller/templates/controller_spec.rb.erb
65
+ - generators/rspec_model/templates/model_spec.rb.erb
66
+ - lib/waves-rspec.rb
67
+ - lib/waves-rspec/tasks.rb
68
+ - lib/waves-rspec/version.rb
69
+ - spec/spec.opts
70
+ - spec/spec_helper.rb
71
+ - spec/tasks/generate_controller_spec.rb
72
+ - spec/tasks/generate_model_spec.rb
73
+ - spec/tasks/generate_rspec_spec.rb
74
+ - tasks/waves-rspec.rake
75
+ has_rdoc: true
76
+ homepage: http://blog.nanorails.com/waves-rspec
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --main
80
+ - README.txt
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
95
+ requirements: []
96
+
97
+ rubyforge_project: waves-rspec
98
+ rubygems_version: 1.0.0
99
+ signing_key:
100
+ specification_version: 2
101
+ summary: RSpec support for the Waves Framework
102
+ test_files: []
103
+
metadata.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ g����Ū��0H�ő6�^�Qus�k�9� �v�d7��
2
+ �"��E{ҁ�VZ�q�NY����;-��.�$/��� ����8��7M=&���#�� ����)$��]�#����^"�؎�2��I�kD�_f����54��w�� $�Ɍn��;����Ө�̀��K��z�k��CMi��|�G}�F�<z�gh �ހb��rS9��u$����)
3
+ ^��$�:RH(�����E���`�P
4
+ �Ej�`��hWJ