shenandoah 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.markdown CHANGED
@@ -1,3 +1,10 @@
1
+ 0.1.0
2
+ =====
3
+
4
+ * Supports easier configuration with rails
5
+ * script/generate shenandoah to outfit a rails project
6
+ * script/generate shen_spec *name* to generate a spec and a fixture
7
+
1
8
  shenandoah 0.0.0
2
9
  ================
3
10
 
data/README.markdown CHANGED
@@ -62,7 +62,31 @@ To start the shell:
62
62
 
63
63
  ### Use with Rails
64
64
 
65
- TODO
65
+ Add a config.gem entry in environment.rb:
66
+
67
+ config.gem "shenandoah", :version => '0.1.0', :lib => false
68
+
69
+ Install the rake tasks:
70
+
71
+ $ script/generate shenandoah
72
+
73
+ In a rails project, Shenandoah will look for specs in `spec/javascript`, `examples/javascript`, or `test/javascript`. The main path is `public/javascripts`.
74
+
75
+ To run the specs from the command line:
76
+
77
+ $ rake shen:spec
78
+
79
+ To run an individual spec file called "application_spec.js":
80
+
81
+ $ rake shen:spec SHEN_SPEC=application
82
+
83
+ To start the server:
84
+
85
+ $ rake shen:serve
86
+
87
+ To start the shell:
88
+
89
+ $ rake shen:shell
66
90
 
67
91
  ### Use with rake (in general)
68
92
 
@@ -142,17 +166,13 @@ It's very easy to add support for Prototype. Here's an example spec:
142
166
  More Examples
143
167
  -------------
144
168
 
145
- TODO.
146
-
147
- <!--
148
- To see Shenandoah in action inside a working Rails app, check out the [Shenandoah sample application](http://github.com/relevance/shenandoah-rails-sample-app). Among other things, this sample app includes examples of:
169
+ To see Shenandoah in action inside a working Rails app, check out the [Shenandoah sample application](http://github.com/rsutphin/shenandoah-rails-sample-app). Among other things, this sample app includes examples of:
149
170
 
150
171
  * using nested `describe` functions
151
172
  * setting up per-spec HTML "fixtures"
152
173
  * stubbing functions
153
174
  * mocking functions
154
175
  * running the javascript specs as part of your default Rake task
155
- -->
156
176
 
157
177
  JavaScript API
158
178
  --------------
data/Rakefile CHANGED
@@ -17,6 +17,7 @@ begin
17
17
  gem.add_runtime_dependency('sinatra', '>= 0.9.2')
18
18
  gem.add_runtime_dependency('haml', '>= 2.0.9')
19
19
  gem.add_runtime_dependency('rake')
20
+ gem.add_runtime_dependency('rails', '>= 2.1.0')
20
21
 
21
22
  # Have to use rspec 1.2.4 for buildr compat
22
23
  gem.add_development_dependency('rspec', '= 1.2.4')
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 0
3
+ :minor: 1
4
4
  :patch: 0
@@ -0,0 +1,27 @@
1
+ require 'shenandoah/locator'
2
+
3
+ module Shenandoah
4
+ module Rails
5
+ class Locator < Shenandoah::DefaultLocator
6
+ def initialize(options={})
7
+ super(
8
+ :main_path => File.join(RAILS_ROOT, options[:main_path] || "public/javascripts"),
9
+ :spec_path => File.join(RAILS_ROOT, options[:spec_path] || select_spec_subpath),
10
+ :tmp_path => File.join(RAILS_ROOT, "tmp/shenandoah")
11
+ )
12
+ end
13
+
14
+ private
15
+
16
+ def select_spec_subpath
17
+ %w(spec examples).each do |candidate|
18
+ if File.directory?(File.join(RAILS_ROOT, candidate))
19
+ return "#{candidate}/javascript"
20
+ end
21
+ end
22
+
23
+ "test/javascript" # default
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ # This class is just sugar for initing Shenandoah::Tasks with a rails locator
2
+
3
+ require 'shenandoah/tasks'
4
+ require 'shenandoah/rails/locator'
5
+
6
+ module Shenandoah
7
+ module Rails
8
+ class Tasks < Shenandoah::Tasks
9
+ protected
10
+
11
+ def default_locator_type
12
+ Locator
13
+ end
14
+ end
15
+ end
16
+ end
@@ -12,7 +12,7 @@ module Shenandoah
12
12
  if options[:locator]
13
13
  options[:locator]
14
14
  else
15
- DefaultLocator.new(options)
15
+ default_locator_type.new(options)
16
16
  end
17
17
  @runner = Shenandoah::Runner.new(@locator)
18
18
  create_serve_task
@@ -33,6 +33,10 @@ module Shenandoah
33
33
 
34
34
  protected
35
35
 
36
+ def default_locator_type
37
+ DefaultLocator
38
+ end
39
+
36
40
  def create_serve_task
37
41
  task('shen:serve') do |t|
38
42
  Shenandoah::Server.set :locator, @locator
@@ -0,0 +1,27 @@
1
+ require 'rails_generator'
2
+ require 'shenandoah/rails/locator'
3
+
4
+ module Shenandoah
5
+ module Generators
6
+ class ShenSpecGenerator < ::Rails::Generator::NamedBase
7
+ def manifest
8
+ spec_path = Shenandoah::Rails::Locator.new.spec_path.sub %r{^#{RAILS_ROOT}/}, ''
9
+ record do |m|
10
+ m.directory "#{spec_path}/#{File.dirname(file_path)}"
11
+ m.template 'javascript_spec.js.erb', "#{spec_path}/#{file_path}_spec.js"
12
+ m.template 'fixture.html.erb', "#{spec_path}/#{file_path}.html"
13
+ end
14
+ end
15
+
16
+ def file_path
17
+ super.sub /_spec$/, ''
18
+ end
19
+
20
+ def javascript_class_name
21
+ klass, *mods_rev = class_name.sub(/Spec$/, '').split('::').reverse
22
+ mod_spec = mods_rev.reverse.collect { |m| m.downcase }.join('.')
23
+ [mod_spec, klass].reject { |p| p == "" }.join '.'
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+ <title><%= file_name %>.js | JavaScript Testing Results</title>
6
+ <link rel="stylesheet" href="/screw.css" type="text/css" charset="utf-8" />
7
+ <script type="text/javascript" src="/shenandoah/browser-runner.js"></script>
8
+ </head>
9
+
10
+ <body>
11
+ <!-- Put any HTML fixture elements here. -->
12
+ </body>
13
+ </html>
@@ -0,0 +1,8 @@
1
+ require_spec('spec_helper.js');
2
+ require_main('<%= file_path %>.js');
3
+
4
+ describe('<%= javascript_class_name %>', function () {
5
+ it("needs tests", function () {
6
+ expect("you").to(include, "some tests");
7
+ });
8
+ });
@@ -0,0 +1,21 @@
1
+ require 'rails_generator'
2
+ require 'shenandoah/rails/locator'
3
+
4
+ module Shenandoah
5
+ module Generators
6
+ class ShenandoahGenerator < ::Rails::Generator::Base
7
+ def manifest
8
+ spec_path = Shenandoah::Rails::Locator.new.spec_path.sub %r{^#{RAILS_ROOT}/}, ''
9
+ record do |m|
10
+ m.directory "lib/tasks"
11
+ m.file "shenandoah.rake", "lib/tasks/shenandoah.rake"
12
+
13
+ m.directory spec_path
14
+ m.file "spec_helper.js", "#{spec_path}/spec_helper.js"
15
+ m.file "application_spec.js", "#{spec_path}/application_spec.js"
16
+ m.file "application.html", "#{spec_path}/application.html"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+ <title>Application | JavaScript Testing Results</title>
6
+ <link rel="stylesheet" href="/screw.css" type="text/css" charset="utf-8" />
7
+ <script type="text/javascript" src="/shenandoah/browser-runner.js"></script>
8
+ </head>
9
+
10
+ <body>
11
+ <!-- Put any HTML fixture elements here. -->
12
+ <div class="select_me"/>
13
+ <span class="select_me"/>
14
+ <div class="dont_select_me"/>
15
+ </body>
16
+ </html>
@@ -0,0 +1,14 @@
1
+ require_spec('spec_helper.js');
2
+ require_main('application.js');
3
+
4
+ Screw.Unit(function () {
5
+ describe("Your application javascript", function () {
6
+ it("does something", function () {
7
+ expect("hello").to(equal, "hello");
8
+ });
9
+
10
+ it("accesses the DOM from fixtures/application.html", function () {
11
+ expect($('.select_me').length).to(equal, 2);
12
+ });
13
+ });
14
+ });
@@ -0,0 +1,2 @@
1
+ require 'shenandoah/rails/tasks'
2
+ Shenandoah::Rails::Tasks.new
@@ -0,0 +1 @@
1
+ // Use this file to require common dependencies or to setup useful test functions.
data/shenandoah.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{shenandoah}
5
- s.version = "0.0.0"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rhett Sutphin"]
9
- s.date = %q{2009-06-14}
9
+ s.date = %q{2009-06-16}
10
10
  s.email = %q{rhett@detailedbalance.net}
11
11
  s.extra_rdoc_files = [
12
12
  "ChangeLog.markdown",
@@ -51,34 +51,53 @@ Gem::Specification.new do |s|
51
51
  "lib/shenandoah/javascript/console/runner.js",
52
52
  "lib/shenandoah/javascript/console/shell.js.erb",
53
53
  "lib/shenandoah/locator.rb",
54
+ "lib/shenandoah/rails/locator.rb",
55
+ "lib/shenandoah/rails/tasks.rb",
54
56
  "lib/shenandoah/runner.rb",
55
57
  "lib/shenandoah/server.rb",
56
58
  "lib/shenandoah/server/views/index.haml",
57
59
  "lib/shenandoah/tasks.rb",
60
+ "rails_generators/shen_spec/shen_spec_generator.rb",
61
+ "rails_generators/shen_spec/templates/fixture.html.erb",
62
+ "rails_generators/shen_spec/templates/javascript_spec.js.erb",
63
+ "rails_generators/shenandoah/shenandoah_generator.rb",
64
+ "rails_generators/shenandoah/templates/application.html",
65
+ "rails_generators/shenandoah/templates/application_spec.js",
66
+ "rails_generators/shenandoah/templates/shenandoah.rake",
67
+ "rails_generators/shenandoah/templates/spec_helper.js",
58
68
  "shenandoah.gemspec",
69
+ "spec/rails_generators/shen_spec_generator_spec.rb",
70
+ "spec/rails_generators/shenandoah_generator_spec.rb",
71
+ "spec/rails_generators/spec_helper.rb",
59
72
  "spec/shenandoah/buildr/locator_spec.rb",
60
73
  "spec/shenandoah/buildr/shenandoah_tasks_spec.rb",
61
74
  "spec/shenandoah/buildr/spec_helper.rb",
62
75
  "spec/shenandoah/buildr/test_framework_spec.rb",
63
76
  "spec/shenandoah/locator_spec.rb",
77
+ "spec/shenandoah/rails/locator_spec.rb",
78
+ "spec/shenandoah/rails/tasks_spec.rb",
64
79
  "spec/shenandoah/runner_spec.rb",
65
80
  "spec/shenandoah/server_spec.rb",
66
81
  "spec/shenandoah/tasks_spec.rb",
67
82
  "spec/spec_helper.rb"
68
83
  ]
69
- s.has_rdoc = true
70
84
  s.homepage = %q{http://github.com/rsutphin/shenandoah}
71
85
  s.rdoc_options = ["--charset=UTF-8"]
72
86
  s.require_paths = ["lib"]
73
87
  s.rubyforge_project = %q{detailedbalance}
74
- s.rubygems_version = %q{1.3.1}
88
+ s.rubygems_version = %q{1.3.4}
75
89
  s.summary = %q{A javascript test framework for buildr, rails, and other ruby-built projects}
76
90
  s.test_files = [
77
- "spec/shenandoah/buildr/locator_spec.rb",
91
+ "spec/rails_generators/shen_spec_generator_spec.rb",
92
+ "spec/rails_generators/shenandoah_generator_spec.rb",
93
+ "spec/rails_generators/spec_helper.rb",
94
+ "spec/shenandoah/buildr/locator_spec.rb",
78
95
  "spec/shenandoah/buildr/shenandoah_tasks_spec.rb",
79
96
  "spec/shenandoah/buildr/spec_helper.rb",
80
97
  "spec/shenandoah/buildr/test_framework_spec.rb",
81
98
  "spec/shenandoah/locator_spec.rb",
99
+ "spec/shenandoah/rails/locator_spec.rb",
100
+ "spec/shenandoah/rails/tasks_spec.rb",
82
101
  "spec/shenandoah/runner_spec.rb",
83
102
  "spec/shenandoah/server_spec.rb",
84
103
  "spec/shenandoah/tasks_spec.rb",
@@ -87,12 +106,13 @@ Gem::Specification.new do |s|
87
106
 
88
107
  if s.respond_to? :specification_version then
89
108
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
90
- s.specification_version = 2
109
+ s.specification_version = 3
91
110
 
92
111
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
93
112
  s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
94
113
  s.add_runtime_dependency(%q<haml>, [">= 2.0.9"])
95
114
  s.add_runtime_dependency(%q<rake>, [">= 0"])
115
+ s.add_runtime_dependency(%q<rails>, [">= 2.1.0"])
96
116
  s.add_development_dependency(%q<rspec>, ["= 1.2.4"])
97
117
  s.add_development_dependency(%q<rack-test>, [">= 0.3.0"])
98
118
  s.add_development_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
@@ -106,6 +126,7 @@ Gem::Specification.new do |s|
106
126
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
107
127
  s.add_dependency(%q<haml>, [">= 2.0.9"])
108
128
  s.add_dependency(%q<rake>, [">= 0"])
129
+ s.add_dependency(%q<rails>, [">= 2.1.0"])
109
130
  s.add_dependency(%q<rspec>, ["= 1.2.4"])
110
131
  s.add_dependency(%q<rack-test>, [">= 0.3.0"])
111
132
  s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
@@ -120,6 +141,7 @@ Gem::Specification.new do |s|
120
141
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
121
142
  s.add_dependency(%q<haml>, [">= 2.0.9"])
122
143
  s.add_dependency(%q<rake>, [">= 0"])
144
+ s.add_dependency(%q<rails>, [">= 2.1.0"])
123
145
  s.add_dependency(%q<rspec>, ["= 1.2.4"])
124
146
  s.add_dependency(%q<rack-test>, [">= 0.3.0"])
125
147
  s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
@@ -0,0 +1,81 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ require 'rails_generator/scripts/generate'
4
+
5
+ describe "shen_spec generator" do
6
+ include Shenandoah::Spec::RailsRoot
7
+ include Shenandoah::Spec::UseGenerators
8
+
9
+ def generate(name='common')
10
+ Rails::Generator::Scripts::Generate.new.run(["shen_spec", name, "-q"])
11
+ end
12
+
13
+ describe "generation" do
14
+ %w(spec test examples).each do |dir|
15
+ describe "when the rails project has a #{dir}" do
16
+ before do
17
+ FileUtils.mkdir "#{RAILS_ROOT}/#{dir}"
18
+ generate
19
+ end
20
+
21
+ it "puts the HTML fixture in the right place" do
22
+ File.exist?("#{RAILS_ROOT}/#{dir}/javascript/common.html").should be_true
23
+ end
24
+
25
+ it "puts the JavaScript spec in the right place" do
26
+ File.exist?("#{RAILS_ROOT}/#{dir}/javascript/common_spec.js").should be_true
27
+ end
28
+ end
29
+ end
30
+
31
+ {
32
+ 'common' => ['common', 'Common'],
33
+ 'some_spec' => ['some', 'Some'],
34
+ 'models/hat' => ['models/hat', 'models.Hat'],
35
+ 'models/helicopter_spec' => ['models/helicopter', 'models.Helicopter'],
36
+ 'themes/light/alison' => ['themes/light/alison', 'themes.light.Alison']
37
+ }.each do |input, (expected_filename, expected_classname)|
38
+ describe "for '#{input}'" do
39
+ before do
40
+ generate(input)
41
+ end
42
+
43
+ describe "the HTML" do
44
+ before do
45
+ @html = File.read("#{RAILS_ROOT}/test/javascript/#{expected_filename}.html")
46
+ end
47
+
48
+ it "includes the name in the title" do
49
+ @html.should =~ %r{<title>#{expected_filename}.js | JavaScript Testing Results</title>}
50
+ end
51
+
52
+ it "includes the runner script" do
53
+ @html.should =~ %r{src="/shenandoah/browser-runner.js"}
54
+ end
55
+
56
+ it "includes screw.css" do
57
+ @html.should =~ %r{href="/screw.css"}
58
+ end
59
+ end
60
+
61
+ describe "the JS" do
62
+ before do
63
+ @js = File.read("#{RAILS_ROOT}/test/javascript/#{expected_filename}_spec.js")
64
+ end
65
+
66
+ it "requires the spec_helper" do
67
+ @js.should =~ %r{require_spec\('spec_helper.js'\);}
68
+ end
69
+
70
+ it "requires the presumed main file" do
71
+ @js.should =~ %r{require_main\('#{expected_filename}.js'\);}
72
+ end
73
+
74
+ it "describes the main file" do
75
+ @js.should =~ %r{describe\('#{expected_classname}', function \(\) \{}
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,80 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ require 'rails_generator/scripts/generate'
4
+
5
+ describe "shenandoah generator" do
6
+ include Shenandoah::Spec::RailsRoot
7
+ include Shenandoah::Spec::UseGenerators
8
+
9
+ def generate
10
+ Rails::Generator::Scripts::Generate.new.run(["shenandoah", "-q"])
11
+ end
12
+
13
+ describe "generation" do
14
+ describe "of lib/tasks/shenandoh.rake" do
15
+ before do
16
+ generate
17
+ @path = "#{RAILS_ROOT}/lib/tasks/shenandoah.rake"
18
+ end
19
+
20
+ it "happens" do
21
+ File.exist?(@path).should be_true
22
+ end
23
+
24
+ it "has the right content" do
25
+ content = File.read(@path)
26
+ content.should =~ %r{require 'shenandoah/rails/tasks'}
27
+ content.should =~ %r{Shenandoah::Rails::Tasks.new}
28
+ end
29
+ end
30
+
31
+ %w(spec examples test).each do |dir|
32
+ describe "when the project uses '#{dir}'" do
33
+ before do
34
+ FileUtils.mkdir_p "#{RAILS_ROOT}/#{dir}"
35
+ generate
36
+ end
37
+
38
+ it "generates spec_helper" do
39
+ File.exist?("#{RAILS_ROOT}/#{dir}/javascript/spec_helper.js").should be_true
40
+ end
41
+
42
+ describe "creation of application_spec.js" do
43
+ before do
44
+ @path = "#{RAILS_ROOT}/#{dir}/javascript/application_spec.js"
45
+ end
46
+
47
+ it "happens" do
48
+ File.exist?(@path).should be_true
49
+ end
50
+
51
+ it "requires spec_helper" do
52
+ File.read(@path).should =~ %r{require_spec\('spec_helper.js'\)}
53
+ end
54
+
55
+ it "requires application.js" do
56
+ File.read(@path).should =~ %r{require_main\('application.js'\)}
57
+ end
58
+ end
59
+
60
+ describe "creation of application.html" do
61
+ before do
62
+ @path = "#{RAILS_ROOT}/#{dir}/javascript/application.html"
63
+ end
64
+
65
+ it "happens" do
66
+ File.exist?(@path).should be_true
67
+ end
68
+
69
+ it "links to shenandoah's runner" do
70
+ File.read(@path).should =~ %r{src="/shenandoah/browser-runner.js"}
71
+ end
72
+
73
+ it "links to the served screw.css" do
74
+ File.read(@path).should =~ %r{href="/screw.css"}
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path("../spec_helper", File.dirname(__FILE__))
2
+
3
+ require 'rails_generator'
4
+ require 'rails_generator/lookup'
5
+
6
+ module Shenandoah::Spec
7
+ module UseGenerators
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ before do
11
+ Rails::Generator::Base.sources.unshift(
12
+ Rails::Generator::PathSource.new("local", File.dirname(__FILE__) + "/../../rails_generators"))
13
+ end
14
+
15
+ after do
16
+ Rails::Generator::Base.sources.shift
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,57 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ require 'shenandoah/rails/locator'
4
+
5
+ describe Shenandoah::Rails::Locator do
6
+ include Shenandoah::Spec::Tmpfile
7
+
8
+ before do
9
+ RAILS_ROOT = tmpdir('rails-root')
10
+ end
11
+
12
+ after do
13
+ Object.instance_eval { remove_const :RAILS_ROOT }
14
+ end
15
+
16
+ def loc(*args)
17
+ Shenandoah::Rails::Locator.new(*args)
18
+ end
19
+
20
+ describe "#main_path" do
21
+ it "uses public/javascripts by default" do
22
+ loc.main_path.should == "#{tmpdir}/rails-root/public/javascripts"
23
+ end
24
+
25
+ it "accepts an override relative to root" do
26
+ loc(:main_path => "app/javascript").main_path.
27
+ should == "#{tmpdir}/rails-root/app/javascript"
28
+ end
29
+ end
30
+
31
+ describe "#spec_path" do
32
+ it "uses test/javascript for spec by default" do
33
+ loc.spec_path.should == "#{tmpdir}/rails-root/test/javascript"
34
+ end
35
+
36
+ it "uses spec/javascript for spec if spec/ already exists" do
37
+ tmpdir('rails-root/spec')
38
+ loc.spec_path.should == "#{tmpdir}/rails-root/spec/javascript"
39
+ end
40
+
41
+ it "uses examples/javascript for spec if examples/ already exists" do
42
+ tmpdir('rails-root/examples')
43
+ loc.spec_path.should == "#{tmpdir}/rails-root/examples/javascript"
44
+ end
45
+
46
+ it "accepts an override relative to root" do
47
+ loc(:spec_path => "features/javascript").spec_path.
48
+ should == "#{tmpdir}/rails-root/features/javascript"
49
+ end
50
+ end
51
+
52
+ describe "#tmp_path" do
53
+ it "uses the rails tmp directory" do
54
+ loc.tmp_path.should == "#{tmpdir}/rails-root/tmp/shenandoah"
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ require 'shenandoah/locator'
4
+ require 'shenandoah/rails/locator'
5
+ require 'shenandoah/rails/tasks'
6
+
7
+ describe Shenandoah::Rails::Tasks do
8
+ include Shenandoah::Spec::Tmpfile
9
+
10
+ before do
11
+ RAILS_ROOT = tmpdir('rails')
12
+ end
13
+
14
+ after do
15
+ Object.instance_eval { remove_const :RAILS_ROOT }
16
+ end
17
+
18
+ it "uses a rails locator by default" do
19
+ Shenandoah::Rails::Tasks.new.locator.class.
20
+ should == Shenandoah::Rails::Locator
21
+ end
22
+
23
+ it "passes overrides to the rails locator" do
24
+ Shenandoah::Rails::Tasks.new(:main_path => "app/js").locator.
25
+ main_path.should == "#{tmpdir}/rails/app/js"
26
+ end
27
+
28
+ it "uses the explicitly provided locator over all others" do
29
+ loc = Shenandoah::DefaultLocator.new(:main_path => 'foo')
30
+ Shenandoah::Rails::Tasks.new(:locator => loc).locator.main_path.should == 'foo'
31
+ end
32
+ end
@@ -2,9 +2,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  require 'shenandoah/tasks'
4
4
  require 'shenandoah/locator'
5
+ require 'shenandoah/rails/locator'
5
6
 
6
7
  describe Shenandoah::Tasks do
7
8
  describe "init" do
9
+ include Shenandoah::Spec::Tmpfile
10
+
8
11
  it "uses a DefaultLocator by default" do
9
12
  Shenandoah::Tasks.new.locator.class.should == Shenandoah::DefaultLocator
10
13
  end
@@ -12,6 +15,12 @@ describe Shenandoah::Tasks do
12
15
  it "configures the default locator with the provided options" do
13
16
  Shenandoah::Tasks.new(:main_path => 'foo').locator.main_path.should == 'foo'
14
17
  end
18
+
19
+ it "uses an explictly provided locator, ignoring other options" do
20
+ loc = Shenandoah::DefaultLocator.new(:main_path => 'bar')
21
+ tasks = Shenandoah::Tasks.new(:locator => loc, :main_path => 'foo')
22
+ tasks.locator.main_path.should == 'bar'
23
+ end
15
24
  end
16
25
 
17
26
  after do
data/spec/spec_helper.rb CHANGED
@@ -11,14 +11,23 @@ end
11
11
  module Shenandoah
12
12
  module Spec
13
13
  module Tmpfile
14
- attr_accessor :tmpdir
15
-
14
+ attr_writer :tmpdir
15
+
16
16
  def tmpfile(name, contents="contents not important")
17
17
  n = "#{tmpdir}/#{name}"
18
18
  FileUtils.mkdir_p File.dirname(n)
19
19
  File.open(n, 'w') { |f| f.write contents }
20
20
  n
21
21
  end
22
+
23
+ def tmpdir(name=nil)
24
+ n = @tmpdir
25
+ if (name)
26
+ n = File.join(n, name)
27
+ FileUtils.mkdir_p(n)
28
+ end
29
+ n
30
+ end
22
31
 
23
32
  def self.included(klass)
24
33
  klass.class_eval do
@@ -32,5 +41,21 @@ module Shenandoah
32
41
  end
33
42
  end
34
43
  end
44
+
45
+ module RailsRoot
46
+ def self.included(klass)
47
+ klass.class_eval do
48
+ include Shenandoah::Spec::Tmpfile
49
+
50
+ before do
51
+ Object.const_set(:RAILS_ROOT, tmpdir('rails-root'))
52
+ end
53
+
54
+ after do
55
+ Object.instance_eval { remove_const :RAILS_ROOT }
56
+ end
57
+ end
58
+ end
59
+ end
35
60
  end
36
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shenandoah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhett Sutphin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-14 00:00:00 -05:00
12
+ date: 2009-06-16 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,16 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: "0"
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: rails
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.1.0
54
+ version:
45
55
  - !ruby/object:Gem::Dependency
46
56
  name: rspec
47
57
  type: :development
@@ -180,22 +190,39 @@ files:
180
190
  - lib/shenandoah/javascript/console/runner.js
181
191
  - lib/shenandoah/javascript/console/shell.js.erb
182
192
  - lib/shenandoah/locator.rb
193
+ - lib/shenandoah/rails/locator.rb
194
+ - lib/shenandoah/rails/tasks.rb
183
195
  - lib/shenandoah/runner.rb
184
196
  - lib/shenandoah/server.rb
185
197
  - lib/shenandoah/server/views/index.haml
186
198
  - lib/shenandoah/tasks.rb
199
+ - rails_generators/shen_spec/shen_spec_generator.rb
200
+ - rails_generators/shen_spec/templates/fixture.html.erb
201
+ - rails_generators/shen_spec/templates/javascript_spec.js.erb
202
+ - rails_generators/shenandoah/shenandoah_generator.rb
203
+ - rails_generators/shenandoah/templates/application.html
204
+ - rails_generators/shenandoah/templates/application_spec.js
205
+ - rails_generators/shenandoah/templates/shenandoah.rake
206
+ - rails_generators/shenandoah/templates/spec_helper.js
187
207
  - shenandoah.gemspec
208
+ - spec/rails_generators/shen_spec_generator_spec.rb
209
+ - spec/rails_generators/shenandoah_generator_spec.rb
210
+ - spec/rails_generators/spec_helper.rb
188
211
  - spec/shenandoah/buildr/locator_spec.rb
189
212
  - spec/shenandoah/buildr/shenandoah_tasks_spec.rb
190
213
  - spec/shenandoah/buildr/spec_helper.rb
191
214
  - spec/shenandoah/buildr/test_framework_spec.rb
192
215
  - spec/shenandoah/locator_spec.rb
216
+ - spec/shenandoah/rails/locator_spec.rb
217
+ - spec/shenandoah/rails/tasks_spec.rb
193
218
  - spec/shenandoah/runner_spec.rb
194
219
  - spec/shenandoah/server_spec.rb
195
220
  - spec/shenandoah/tasks_spec.rb
196
221
  - spec/spec_helper.rb
197
222
  has_rdoc: true
198
223
  homepage: http://github.com/rsutphin/shenandoah
224
+ licenses: []
225
+
199
226
  post_install_message:
200
227
  rdoc_options:
201
228
  - --charset=UTF-8
@@ -216,16 +243,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
243
  requirements: []
217
244
 
218
245
  rubyforge_project: detailedbalance
219
- rubygems_version: 1.3.1
246
+ rubygems_version: 1.3.4
220
247
  signing_key:
221
- specification_version: 2
248
+ specification_version: 3
222
249
  summary: A javascript test framework for buildr, rails, and other ruby-built projects
223
250
  test_files:
251
+ - spec/rails_generators/shen_spec_generator_spec.rb
252
+ - spec/rails_generators/shenandoah_generator_spec.rb
253
+ - spec/rails_generators/spec_helper.rb
224
254
  - spec/shenandoah/buildr/locator_spec.rb
225
255
  - spec/shenandoah/buildr/shenandoah_tasks_spec.rb
226
256
  - spec/shenandoah/buildr/spec_helper.rb
227
257
  - spec/shenandoah/buildr/test_framework_spec.rb
228
258
  - spec/shenandoah/locator_spec.rb
259
+ - spec/shenandoah/rails/locator_spec.rb
260
+ - spec/shenandoah/rails/tasks_spec.rb
229
261
  - spec/shenandoah/runner_spec.rb
230
262
  - spec/shenandoah/server_spec.rb
231
263
  - spec/shenandoah/tasks_spec.rb