smartgen 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +0 -8
  3. data/Gemfile.lock +25 -31
  4. data/lib/smartgen/object_hash.rb +2 -2
  5. data/lib/smartgen/version.rb +1 -1
  6. metadata +138 -194
  7. data/spec/fixtures/expectations/common/another_index.html +0 -13
  8. data/spec/fixtures/expectations/common/index.html +0 -8
  9. data/spec/fixtures/expectations/common/other_index.html +0 -13
  10. data/spec/fixtures/expectations/erb/index.html +0 -15
  11. data/spec/fixtures/expectations/erb/with_layout/index.html +0 -19
  12. data/spec/fixtures/expectations/indexer/index_with_indexer.html +0 -16
  13. data/spec/fixtures/expectations/indexer/index_with_indexer_and_numbered_index.html +0 -16
  14. data/spec/fixtures/expectations/with_layout/index.html +0 -12
  15. data/spec/fixtures/expectations/with_layout/index_with_metadata.html +0 -43
  16. data/spec/fixtures/expectations/with_layout/index_with_specific_metadata.html +0 -44
  17. data/spec/fixtures/src/assets/images/image.gif +0 -0
  18. data/spec/fixtures/src/assets/javascripts/somelib.js +0 -2
  19. data/spec/fixtures/src/assets/stylesheets/style.css +0 -2
  20. data/spec/fixtures/src/common/another_index.md +0 -12
  21. data/spec/fixtures/src/common/index.textile +0 -10
  22. data/spec/fixtures/src/common/other_index.markdown +0 -12
  23. data/spec/fixtures/src/common/somefile +0 -10
  24. data/spec/fixtures/src/erb/index.html.erb +0 -7
  25. data/spec/fixtures/src/erb/with_layout/index.html.erb +0 -7
  26. data/spec/fixtures/src/erb/with_layout/layout.html.erb +0 -5
  27. data/spec/fixtures/src/indexer/index_with_indexer.textile +0 -26
  28. data/spec/fixtures/src/indexer/index_with_indexer_and_numbered_index.textile +0 -26
  29. data/spec/fixtures/src/layout.html.erb +0 -5
  30. data/spec/fixtures/src/layout_with_metadata.html.erb +0 -22
  31. data/spec/fixtures/src/layout_with_specific_metadata.html.erb +0 -23
  32. data/spec/fixtures/src/metadata.yml +0 -43
  33. data/spec/fixtures/src/with_layout/index.textile +0 -10
  34. data/spec/fixtures/src/with_layout/index_with_specific_metadata.textile +0 -10
  35. data/spec/lib/smartgen/configuration_spec.rb +0 -5
  36. data/spec/lib/smartgen/engines/base_spec.rb +0 -92
  37. data/spec/lib/smartgen/engines/erb_spec.rb +0 -37
  38. data/spec/lib/smartgen/engines/markdown_spec.rb +0 -23
  39. data/spec/lib/smartgen/engines/textile_spec.rb +0 -19
  40. data/spec/lib/smartgen/generator_spec.rb +0 -272
  41. data/spec/lib/smartgen/indexer_spec.rb +0 -122
  42. data/spec/lib/smartgen/markup_file_spec.rb +0 -168
  43. data/spec/lib/smartgen/object_hash_spec.rb +0 -91
  44. data/spec/lib/smartgen/renderers/erb_spec.rb +0 -38
  45. data/spec/lib/smartgen/resource_spec.rb +0 -73
  46. data/spec/lib/smartgen/watcher_spec.rb +0 -71
  47. data/spec/lib/smartgen_spec.rb +0 -18
  48. data/spec/sandbox/.gitkeep +0 -0
  49. data/spec/spec_helper.rb +0 -37
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Smartgen::Watcher do
4
- it "should create a resource and yield its configuration" do
5
- expected_config = nil
6
- Smartgen::Watcher.new(:my_resource) { |config| expected_config = config }
7
- expected_config.should == Smartgen[:my_resource].config
8
- end
9
-
10
- context "when it will start watching" do
11
- def src_files
12
- ['doc/**/*']
13
- end
14
-
15
- def directory_watcher
16
- return @directory_watcher if @directory_watcher
17
-
18
- @directory_watcher = mock(DirectoryWatcher, :add_observer => 'observer', :interval= => '2')
19
- @directory_watcher.stub!(:start).and_return(@directory_watcher)
20
- @directory_watcher.stub!(:join).and_return(@directory_watcher)
21
- @directory_watcher
22
- end
23
-
24
- before do
25
- DirectoryWatcher.stub!(:new).and_return(directory_watcher)
26
- end
27
-
28
- subject do
29
- Smartgen::Watcher.new(:my_resource) do |config|
30
- config.src_files = src_files
31
- config.output_folder = 'public/docs'
32
- end
33
- end
34
-
35
- it "should create a directory watcher, pre loading src_files" do
36
- DirectoryWatcher.should_receive(:new).with('.', :glob => src_files).and_return(directory_watcher)
37
- capture(:stdout) { subject.start }
38
- end
39
-
40
- it "should add itself as an observer, with :generate method as the callback" do
41
- directory_watcher.should_receive(:add_observer).with(subject, :generate)
42
- capture(:stdout) { subject.start }
43
- end
44
-
45
- it "should start watching" do
46
- directory_watcher.should_receive(:start)
47
- directory_watcher.should_receive(:join)
48
- capture(:stdout) { subject.start }
49
- end
50
-
51
- it "should set interval to 2 seconds" do
52
- directory_watcher.should_receive(:interval=).with(2)
53
- capture(:stdout) { subject.start }
54
- end
55
-
56
- context "when generating" do
57
- it "should generate files" do
58
- Smartgen[:my_resource].should_receive(:generate!)
59
- capture(:stdout) { subject.generate }
60
- end
61
- end
62
-
63
- context "when user hits ctrl+c" do
64
- it "should exit gracefully" do
65
- Kernel.should_receive(:exit).with(0)
66
- Kernel.should_receive(:trap).with('INT').and_yield
67
- capture(:stdout) { subject.start }
68
- end
69
- end
70
- end
71
- end
@@ -1,18 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe Smartgen do
5
- describe "resources" do
6
- it "should create a resource the first time it is accessed" do
7
- Smartgen[:foo].should be_an_instance_of(Smartgen::Resource)
8
- end
9
-
10
- it "should use the same resource when it is accessed in the future" do
11
- Smartgen[:foo].should be_equal(Smartgen[:foo])
12
- end
13
-
14
- it "should create different resource for each given name" do
15
- Smartgen[:foo].should_not be_equal(Smartgen[:bar])
16
- end
17
- end
18
- end
File without changes
@@ -1,37 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
- require 'rspec'
4
- require 'smartgen'
5
-
6
- RSpec.configure do |config|
7
- def fixture(path)
8
- File.join(fixtures_dir, path)
9
- end
10
-
11
- def fixtures_dir
12
- File.expand_path('fixtures', File.dirname(__FILE__))
13
- end
14
-
15
- def sandbox(path)
16
- File.join(sandbox_dir, path)
17
- end
18
-
19
- def sandbox_dir
20
- File.expand_path('sandbox', File.dirname(__FILE__))
21
- end
22
-
23
- def capture(stream)
24
- begin
25
- stream = stream.to_s
26
- eval "$#{stream} = StringIO.new"
27
- yield
28
- result = eval("$#{stream}").string
29
- ensure
30
- eval("$#{stream} = #{stream.upcase}")
31
- end
32
-
33
- result
34
- end
35
-
36
- alias silence capture
37
- end