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
@@ -1,3 +1,9 @@
1
+ 0.1.2
2
+ =====
3
+
4
+ * Fix javascript spec template (generated code was not correct)
5
+ * Only generate the spec helper require when spec_helper.js exists
6
+
1
7
  0.1.1
2
8
  =====
3
9
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 1
4
+ :patch: 2
@@ -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
- describe('<%= javascript_class_name %>', function () {
5
- it("needs tests", function () {
6
- expect("you").to(include, "some tests");
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{shenandoah}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
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"]
@@ -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
- @js = File.read("#{RAILS_ROOT}/test/javascript/#{expected_filename}_spec.js")
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 "requires the spec_helper" do
67
- @js.should =~ %r{require_spec\('spec_helper.js'\);}
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
- @js.should =~ %r{require_main\('#{expected_filename}.js'\);}
87
+ js.should =~ %r{require_main\('#{expected_filename}.js'\);}
72
88
  end
73
89
 
74
90
  it "describes the main file" do
75
- @js.should =~ %r{describe\('#{expected_classname}', function \(\) \{}
91
+ js.should =~ %r{describe\('#{expected_classname}', function \(\) \{}
76
92
  end
77
93
  end
78
94
  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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhett Sutphin