shenandoah 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.markdown
CHANGED
data/VERSION.yml
CHANGED
@@ -5,7 +5,6 @@ module Shenandoah
|
|
5
5
|
module Generators
|
6
6
|
class ShenSpecGenerator < ::Rails::Generator::NamedBase
|
7
7
|
def manifest
|
8
|
-
spec_path = ENV['SHEN_SPEC_PATH'] || Shenandoah::Rails::Locator.new.spec_path.sub(%r{^#{RAILS_ROOT}/}, '')
|
9
8
|
record do |m|
|
10
9
|
m.directory "#{spec_path}/#{File.dirname(file_path)}"
|
11
10
|
m.template 'javascript_spec.js.erb', "#{spec_path}/#{file_path}_spec.js"
|
@@ -13,6 +12,10 @@ module Shenandoah
|
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
15
|
+
def spec_path
|
16
|
+
ENV['SHEN_SPEC_PATH'] || Shenandoah::Rails::Locator.new.spec_path.sub(%r{^#{RAILS_ROOT}/}, '')
|
17
|
+
end
|
18
|
+
|
16
19
|
def file_path
|
17
20
|
super.sub /_spec$/, ''
|
18
21
|
end
|
@@ -22,6 +25,10 @@ module Shenandoah
|
|
22
25
|
mod_spec = mods_rev.reverse.collect { |m| m.downcase }.join('.')
|
23
26
|
[mod_spec, klass].reject { |p| p == "" }.join '.'
|
24
27
|
end
|
28
|
+
|
29
|
+
def spec_helper?
|
30
|
+
File.exist?("#{destination_root}/#{spec_path}/spec_helper.js")
|
31
|
+
end
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
@@ -1,8 +1,12 @@
|
|
1
|
+
<% if spec_helper? -%>
|
1
2
|
require_spec('spec_helper.js');
|
3
|
+
<% end -%>
|
2
4
|
require_main('<%= file_path %>.js');
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
Screw.Unit(function () {
|
7
|
+
describe('<%= javascript_class_name %>', function () {
|
8
|
+
it("needs tests", function () {
|
9
|
+
expect("you").to(include, "some tests");
|
10
|
+
});
|
7
11
|
});
|
8
12
|
});
|
data/shenandoah.gemspec
CHANGED
@@ -36,12 +36,9 @@ describe "shen_spec generator" do
|
|
36
36
|
'themes/light/alison' => ['themes/light/alison', 'themes.light.Alison']
|
37
37
|
}.each do |input, (expected_filename, expected_classname)|
|
38
38
|
describe "for '#{input}'" do
|
39
|
-
before do
|
40
|
-
generate(input)
|
41
|
-
end
|
42
|
-
|
43
39
|
describe "the HTML" do
|
44
40
|
before do
|
41
|
+
generate(input)
|
45
42
|
@html = File.read("#{RAILS_ROOT}/test/javascript/#{expected_filename}.html")
|
46
43
|
end
|
47
44
|
|
@@ -60,19 +57,38 @@ describe "shen_spec generator" do
|
|
60
57
|
|
61
58
|
describe "the JS" do
|
62
59
|
before do
|
63
|
-
@
|
60
|
+
@input = input
|
61
|
+
@filename = expected_filename
|
62
|
+
end
|
63
|
+
|
64
|
+
def js
|
65
|
+
@js ||= begin
|
66
|
+
generate(@input)
|
67
|
+
File.read("#{RAILS_ROOT}/test/javascript/#{@filename}_spec.js")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "builds a Screw.Unit spec" do
|
72
|
+
js.should =~ %r{Screw.Unit}
|
73
|
+
end
|
74
|
+
|
75
|
+
it "requires the spec_helper if it exists" do
|
76
|
+
FileUtils.mkdir_p "#{RAILS_ROOT}/test/javascript"
|
77
|
+
File.open("#{RAILS_ROOT}/test/javascript/spec_helper.js", 'w') { }
|
78
|
+
js.should =~ %r{require_spec\('spec_helper.js'\);\n}
|
64
79
|
end
|
65
80
|
|
66
|
-
it "
|
67
|
-
|
81
|
+
it "does not require the spec_helper if it does not" do
|
82
|
+
js.should_not =~ %r{require_spec\('spec_helper.js'\);}
|
83
|
+
js.should =~ %r{^require_main} # ensure no blank line
|
68
84
|
end
|
69
85
|
|
70
86
|
it "requires the presumed main file" do
|
71
|
-
|
87
|
+
js.should =~ %r{require_main\('#{expected_filename}.js'\);}
|
72
88
|
end
|
73
89
|
|
74
90
|
it "describes the main file" do
|
75
|
-
|
91
|
+
js.should =~ %r{describe\('#{expected_classname}', function \(\) \{}
|
76
92
|
end
|
77
93
|
end
|
78
94
|
end
|