merb_screw_unit 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +170 -0
- data/Rakefile +70 -0
- data/TODO +15 -0
- data/app/controllers/application.rb +5 -0
- data/app/controllers/main.rb +7 -0
- data/app/helpers/application_helper.rb +76 -0
- data/app/views/layout/merb_screw_unit.html.erb +37 -0
- data/app/views/main/index.html.erb +1 -0
- data/lib/merb_screw_unit/merbtasks.rb +166 -0
- data/lib/merb_screw_unit/slicetasks.rb +18 -0
- data/lib/merb_screw_unit.rb +84 -0
- data/public/javascripts/jquery-1.2.3.js +3408 -0
- data/public/javascripts/jquery.fn.js +29 -0
- data/public/javascripts/jquery.print.js +108 -0
- data/public/javascripts/master.js +0 -0
- data/public/javascripts/screw.behaviors.js +91 -0
- data/public/javascripts/screw.builder.js +84 -0
- data/public/javascripts/screw.events.js +38 -0
- data/public/javascripts/screw.matchers.js +74 -0
- data/public/javascripts/screw.mock.js +78 -0
- data/public/stylesheets/master.css +2 -0
- data/public/stylesheets/screw.css +90 -0
- data/spec/controllers/main_spec.rb +61 -0
- data/spec/merb_screw_unit_spec.rb +130 -0
- data/spec/spec_helper.rb +44 -0
- data/stubs/app/controllers/application.rb +2 -0
- data/stubs/app/controllers/main.rb +2 -0
- metadata +111 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "MerbScrewUnit (module)" do
|
4
|
+
|
5
|
+
it "should have proper specs"
|
6
|
+
|
7
|
+
# Feel free to remove the specs below
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
Merb::Router.prepare { |r| r.add_slice(:MerbScrewUnit) } if standalone?
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
Merb::Router.reset! if standalone?
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be registered in Merb::Slices.slices" do
|
18
|
+
Merb::Slices.slices.should include(MerbScrewUnit)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be registered in Merb::Slices.paths" do
|
22
|
+
Merb::Slices.paths[MerbScrewUnit.name].should == current_slice_root
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have an :identifier property" do
|
26
|
+
MerbScrewUnit.identifier.should == "merb_screw_unit"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have an :identifier_sym property" do
|
30
|
+
MerbScrewUnit.identifier_sym.should == :merb_screw_unit
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a :root property" do
|
34
|
+
MerbScrewUnit.root.should == Merb::Slices.paths[MerbScrewUnit.name]
|
35
|
+
MerbScrewUnit.root_path('app').should == current_slice_root / 'app'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a :file property" do
|
39
|
+
MerbScrewUnit.file.should == current_slice_root / 'lib' / 'merb_screw_unit.rb'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have metadata properties" do
|
43
|
+
MerbScrewUnit.description.should == "MerbScrewUnit is a chunky Merb slice!"
|
44
|
+
MerbScrewUnit.version.should == "0.0.1"
|
45
|
+
MerbScrewUnit.author.should == "YOUR NAME"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have :routes and :named_routes properties" do
|
49
|
+
MerbScrewUnit.routes.should_not be_empty
|
50
|
+
MerbScrewUnit.named_routes[:merb_screw_unit_index].should be_kind_of(Merb::Router::Route)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have an url helper method for slice-specific routes" do
|
54
|
+
MerbScrewUnit.url(:controller => 'main', :action => 'show', :format => 'html').should == "/merb_screw_unit/main/show.html"
|
55
|
+
MerbScrewUnit.url(:merb_screw_unit_index, :format => 'html').should == "/merb_screw_unit/index.html"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have a config property (Hash)" do
|
59
|
+
MerbScrewUnit.config.should be_kind_of(Hash)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should have bracket accessors as shortcuts to the config" do
|
63
|
+
MerbScrewUnit[:foo] = 'bar'
|
64
|
+
MerbScrewUnit[:foo].should == 'bar'
|
65
|
+
MerbScrewUnit[:foo].should == MerbScrewUnit.config[:foo]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should have a :layout config option set" do
|
69
|
+
MerbScrewUnit.config[:layout].should == :merb_screw_unit
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have a dir_for method" do
|
73
|
+
app_path = MerbScrewUnit.dir_for(:application)
|
74
|
+
app_path.should == current_slice_root / 'app'
|
75
|
+
[:view, :model, :controller, :helper, :mailer, :part].each do |type|
|
76
|
+
MerbScrewUnit.dir_for(type).should == app_path / "#{type}s"
|
77
|
+
end
|
78
|
+
public_path = MerbScrewUnit.dir_for(:public)
|
79
|
+
public_path.should == current_slice_root / 'public'
|
80
|
+
[:stylesheet, :javascript, :image].each do |type|
|
81
|
+
MerbScrewUnit.dir_for(type).should == public_path / "#{type}s"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should have a app_dir_for method" do
|
86
|
+
root_path = MerbScrewUnit.app_dir_for(:root)
|
87
|
+
root_path.should == Merb.root / 'slices' / 'merb_screw_unit'
|
88
|
+
app_path = MerbScrewUnit.app_dir_for(:application)
|
89
|
+
app_path.should == root_path / 'app'
|
90
|
+
[:view, :model, :controller, :helper, :mailer, :part].each do |type|
|
91
|
+
MerbScrewUnit.app_dir_for(type).should == app_path / "#{type}s"
|
92
|
+
end
|
93
|
+
public_path = MerbScrewUnit.app_dir_for(:public)
|
94
|
+
public_path.should == Merb.dir_for(:public) / 'slices' / 'merb_screw_unit'
|
95
|
+
[:stylesheet, :javascript, :image].each do |type|
|
96
|
+
MerbScrewUnit.app_dir_for(type).should == public_path / "#{type}s"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should have a public_dir_for method" do
|
101
|
+
public_path = MerbScrewUnit.public_dir_for(:public)
|
102
|
+
public_path.should == '/slices' / 'merb_screw_unit'
|
103
|
+
[:stylesheet, :javascript, :image].each do |type|
|
104
|
+
MerbScrewUnit.public_dir_for(type).should == public_path / "#{type}s"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should have a public_path_for method" do
|
109
|
+
public_path = MerbScrewUnit.public_dir_for(:public)
|
110
|
+
MerbScrewUnit.public_path_for("path", "to", "file").should == public_path / "path" / "to" / "file"
|
111
|
+
[:stylesheet, :javascript, :image].each do |type|
|
112
|
+
MerbScrewUnit.public_path_for(type, "path", "to", "file").should == public_path / "#{type}s" / "path" / "to" / "file"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should have a app_path_for method" do
|
117
|
+
MerbScrewUnit.app_path_for("path", "to", "file").should == MerbScrewUnit.app_dir_for(:root) / "path" / "to" / "file"
|
118
|
+
MerbScrewUnit.app_path_for(:controller, "path", "to", "file").should == MerbScrewUnit.app_dir_for(:controller) / "path" / "to" / "file"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should have a slice_path_for method" do
|
122
|
+
MerbScrewUnit.slice_path_for("path", "to", "file").should == MerbScrewUnit.dir_for(:root) / "path" / "to" / "file"
|
123
|
+
MerbScrewUnit.slice_path_for(:controller, "path", "to", "file").should == MerbScrewUnit.dir_for(:controller) / "path" / "to" / "file"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should keep a list of path component types to use when copying files" do
|
127
|
+
(MerbScrewUnit.mirrored_components & MerbScrewUnit.slice_paths.keys).length.should == MerbScrewUnit.mirrored_components.length
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'merb-core'
|
3
|
+
require 'merb-slices'
|
4
|
+
require 'spec'
|
5
|
+
|
6
|
+
# Add merb_screw_unit.rb to the search path
|
7
|
+
Merb::Plugins.config[:merb_slices][:auto_register] = true
|
8
|
+
Merb::Plugins.config[:merb_slices][:search_path] = File.join(File.dirname(__FILE__), '..', 'lib', 'merb_screw_unit.rb')
|
9
|
+
|
10
|
+
# Using Merb.root below makes sure that the correct root is set for
|
11
|
+
# - testing standalone, without being installed as a gem and no host application
|
12
|
+
# - testing from within the host application; its root will be used
|
13
|
+
Merb.start_environment(
|
14
|
+
:testing => true,
|
15
|
+
:adapter => 'runner',
|
16
|
+
:environment => ENV['MERB_ENV'] || 'test',
|
17
|
+
:merb_root => Merb.root,
|
18
|
+
:session_store => 'memory'
|
19
|
+
)
|
20
|
+
|
21
|
+
module Merb
|
22
|
+
module Test
|
23
|
+
module SliceHelper
|
24
|
+
|
25
|
+
# The absolute path to the current slice
|
26
|
+
def current_slice_root
|
27
|
+
@current_slice_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
28
|
+
end
|
29
|
+
|
30
|
+
# Whether the specs are being run from a host application or standalone
|
31
|
+
def standalone?
|
32
|
+
Merb.root == ::MerbScrewUnit.root
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Spec::Runner.configure do |config|
|
40
|
+
config.include(Merb::Test::ViewHelper)
|
41
|
+
config.include(Merb::Test::RouteHelper)
|
42
|
+
config.include(Merb::Test::ControllerHelper)
|
43
|
+
config.include(Merb::Test::SliceHelper)
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb_screw_unit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yehuda Katz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-03 00:00:00 +03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.4
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: merb-slices
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.4
|
34
|
+
version:
|
35
|
+
description: Merb Slice that provides support for Screw.Unit testing
|
36
|
+
email: ykatz@engineyard.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
|
+
- LICENSE
|
44
|
+
files:
|
45
|
+
- LICENSE
|
46
|
+
- README
|
47
|
+
- Rakefile
|
48
|
+
- TODO
|
49
|
+
- lib/merb_screw_unit
|
50
|
+
- lib/merb_screw_unit/merbtasks.rb
|
51
|
+
- lib/merb_screw_unit/slicetasks.rb
|
52
|
+
- lib/merb_screw_unit.rb
|
53
|
+
- spec/controllers
|
54
|
+
- spec/controllers/main_spec.rb
|
55
|
+
- spec/merb_screw_unit_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
- app/controllers
|
58
|
+
- app/controllers/application.rb
|
59
|
+
- app/controllers/main.rb
|
60
|
+
- app/helpers
|
61
|
+
- app/helpers/application_helper.rb
|
62
|
+
- app/views
|
63
|
+
- app/views/layout
|
64
|
+
- app/views/layout/merb_screw_unit.html.erb
|
65
|
+
- app/views/main
|
66
|
+
- app/views/main/index.html.erb
|
67
|
+
- public/javascripts
|
68
|
+
- public/javascripts/jquery-1.2.3.js
|
69
|
+
- public/javascripts/jquery.fn.js
|
70
|
+
- public/javascripts/jquery.print.js
|
71
|
+
- public/javascripts/master.js
|
72
|
+
- public/javascripts/screw.behaviors.js
|
73
|
+
- public/javascripts/screw.builder.js
|
74
|
+
- public/javascripts/screw.events.js
|
75
|
+
- public/javascripts/screw.matchers.js
|
76
|
+
- public/javascripts/screw.mock.js
|
77
|
+
- public/stylesheets
|
78
|
+
- public/stylesheets/master.css
|
79
|
+
- public/stylesheets/screw.css
|
80
|
+
- stubs/app
|
81
|
+
- stubs/app/controllers
|
82
|
+
- stubs/app/controllers/application.rb
|
83
|
+
- stubs/app/controllers/main.rb
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: http://merbivore.com
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project: merb
|
106
|
+
rubygems_version: 1.2.0
|
107
|
+
signing_key:
|
108
|
+
specification_version: 2
|
109
|
+
summary: Merb Slice that provides support for Screw.Unit testing
|
110
|
+
test_files: []
|
111
|
+
|