fume 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :build:
3
- :minor: 2
4
- :patch: 6
3
+ :minor: 3
4
+ :patch: 0
5
5
  :major: 0
data/fume.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fume}
8
- s.version = "0.2.6"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sunteya"]
12
- s.date = %q{2009-12-24}
12
+ s.date = %q{2009-12-28}
13
13
  s.email = %q{Sunteya@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README"
@@ -24,6 +24,8 @@ Gem::Specification.new do |s|
24
24
  "generators/fume/capify/templates/Capfile",
25
25
  "generators/fume/capify/templates/config/deploy.rb",
26
26
  "generators/fume/fume_generator.rb",
27
+ "generators/fume/rspec/rspec_gen.rb",
28
+ "generators/fume/rspec/templates/spec/support/fume_controller_macros.rb",
27
29
  "generators/fume/simple_theme/simple_theme_gen.rb",
28
30
  "generators/fume/simple_theme/templates/public/demo.html",
29
31
  "generators/fume/simple_theme/templates/public/images/jquery-ui-1.7.2.ui-darkness/ui-bg_flat_30_cccccc_40x100.png",
@@ -43,6 +45,7 @@ Gem::Specification.new do |s|
43
45
  "generators/fume/simple_theme/templates/public/javascripts/jquery-1.3.2.js",
44
46
  "generators/fume/simple_theme/templates/public/javascripts/jquery-ui-1.7.2.js",
45
47
  "generators/fume/simple_theme/templates/public/javascripts/jquery-ui-i18n-1.7.2.js",
48
+ "generators/fume/simple_theme/templates/public/javascripts/jquery.ba-url-1.11.js",
46
49
  "generators/fume/simple_theme/templates/public/javascripts/jquery.corner-2.03.js",
47
50
  "generators/fume/simple_theme/templates/public/javascripts/jquery.timepicker-0.2.1.js",
48
51
  "generators/fume/simple_theme/templates/public/javascripts/simple-theme-ie-patch.js",
@@ -0,0 +1,8 @@
1
+ class RspecGen < Fume::Gen::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ cp_files m, File.join("**", "*")
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,105 @@
1
+ module FumeControllerMacros
2
+ def self.included(base)
3
+ base.send :extend, ClassMethods
4
+ base.send :include, InstanceMethods
5
+ end
6
+
7
+ module ClassMethods
8
+
9
+ class ActionMethod < Struct.new(:method, :action)
10
+ def to_proc
11
+ eval <<-EOV
12
+ Proc.new do |params|
13
+ #{method} "#{action}", params
14
+ end
15
+ EOV
16
+ end
17
+ end
18
+
19
+ %w{ get post put delete }.each do |name|
20
+ define_method(name) do |*actions|
21
+ [ actions ].flatten.map do |action|
22
+ ActionMethod.new(name, action)
23
+ end
24
+ end
25
+ end
26
+
27
+ %w{ be_success be_redirect be_invalid }.each do |be_method|
28
+ define_method "it_should_#{be_method}_for" do |action_methods, &block|
29
+ action_methods.each do |action_method|
30
+ it "should #{be_method} for #{action_method.method} :#{action_method.action} action" do
31
+ if block_given?
32
+ result = self.instance_exec(&block)
33
+ params = result if result.is_a? Hash
34
+
35
+ self.instance_exec(params, &action_method)
36
+ response.should send(be_method)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def it_should_be_like_restful_resources(options = {}, &block)
44
+ actions = [ :index, :new, :create, :show, :edit, :update, :destroy ]
45
+ actions &= [ options[:only] ].flatten if options[:only]
46
+ actions -= [ options[:except] ].flatten if options[:except]
47
+
48
+ if actions.include?(:index)
49
+ it_should_be_success_for get(:index) do
50
+ params = instance_exec(&block)
51
+ end
52
+ end
53
+
54
+ if actions.include?(:new)
55
+ it_should_be_success_for get(:new) do
56
+ params = instance_exec(&block)
57
+ end
58
+ end
59
+
60
+ if actions.include?(:create)
61
+ it_should_be_redirect_for post(:create) do
62
+ params = instance_exec(&block)
63
+ params.merge(params.delete(:valid_attributes))
64
+ end
65
+
66
+ it_should_be_invalid_for post(:create) do
67
+ params = instance_exec(&block)
68
+ params.merge(params.delete(:invalid_attributes))
69
+ end
70
+ end
71
+
72
+ if actions.include?(:edit)
73
+ it_should_be_success_for get(:edit) do
74
+ params = instance_exec(&block)
75
+ end
76
+ end
77
+
78
+ if actions.include?(:update)
79
+ it_should_be_redirect_for put(:update) do
80
+ params = instance_exec(&block)
81
+ params.merge(params.delete(:valid_attributes))
82
+ end
83
+
84
+ it_should_be_invalid_for put(:update) do
85
+ params = instance_exec(&block)
86
+ params.merge(params.delete(:invalid_attributes))
87
+ end
88
+ end
89
+
90
+ if actions.include?(:destroy)
91
+ it_should_be_redirect_for delete(:destroy) do
92
+ params = instance_exec(&block)
93
+ end
94
+ end
95
+ end
96
+
97
+ end # ClassMethods
98
+
99
+ module InstanceMethods
100
+ def be_invalid(*args)
101
+ be_success(*args)
102
+ end
103
+ end
104
+
105
+ end