remarkable_rails 3.1.8 → 3.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGELOG +91 -88
  2. data/LICENSE +20 -20
  3. data/README +80 -80
  4. data/lib/remarkable_rails/action_controller/base.rb +29 -29
  5. data/lib/remarkable_rails/action_controller/macro_stubs.rb +459 -457
  6. data/lib/remarkable_rails/action_controller/matchers/assign_to_matcher.rb +92 -92
  7. data/lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb +41 -41
  8. data/lib/remarkable_rails/action_controller/matchers/redirect_to_matcher.rb +119 -119
  9. data/lib/remarkable_rails/action_controller/matchers/render_template_matcher.rb +146 -146
  10. data/lib/remarkable_rails/action_controller/matchers/respond_with_matcher.rb +126 -126
  11. data/lib/remarkable_rails/action_controller/matchers/route_matcher.rb +135 -109
  12. data/lib/remarkable_rails/action_controller/matchers/set_cookies_matcher.rb +49 -49
  13. data/lib/remarkable_rails/action_controller/matchers/set_session_matcher.rb +106 -106
  14. data/lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb +54 -54
  15. data/lib/remarkable_rails/action_controller.rb +22 -22
  16. data/lib/remarkable_rails/action_view/base.rb +7 -7
  17. data/lib/remarkable_rails/action_view.rb +18 -18
  18. data/lib/remarkable_rails/active_orm.rb +19 -19
  19. data/lib/remarkable_rails.rb +30 -30
  20. data/locale/en.yml +110 -110
  21. data/spec/action_controller/assign_to_matcher_spec.rb +142 -142
  22. data/spec/action_controller/filter_params_matcher_spec.rb +64 -64
  23. data/spec/action_controller/macro_stubs_spec.rb +234 -208
  24. data/spec/action_controller/redirect_to_matcher_spec.rb +102 -102
  25. data/spec/action_controller/render_template_matcher_spec.rb +251 -251
  26. data/spec/action_controller/respond_with_matcher_spec.rb +223 -223
  27. data/spec/action_controller/route_matcher_spec.rb +96 -79
  28. data/spec/action_controller/set_cookies_matcher_spec.rb +149 -149
  29. data/spec/action_controller/set_session_matcher_spec.rb +141 -141
  30. data/spec/action_controller/set_the_flash_matcher_spec.rb +93 -93
  31. data/spec/application/application.rb +15 -15
  32. data/spec/application/tasks_controller.rb +34 -34
  33. data/spec/functional_builder.rb +88 -88
  34. data/spec/rcov.opts +2 -2
  35. data/spec/remarkable_rails_spec.rb +5 -5
  36. data/spec/spec.opts +4 -4
  37. data/spec/spec_helper.rb +42 -42
  38. metadata +7 -7
@@ -1,56 +1,56 @@
1
- require File.join(File.dirname(__FILE__), 'set_session_matcher')
2
-
3
- module Remarkable
4
- module ActionController
5
- module Matchers
6
- class SetTheFlashMatcher < SetSessionMatcher #:nodoc:
7
-
8
- protected
9
- def session
10
- @subject ? (@subject.response.session['flash'] || {}) : {}
11
- end
12
-
13
- def interpolation_options
14
- { :flash_inspect => session.symbolize_keys!.inspect }
15
- end
16
-
17
- end
18
-
1
+ require File.join(File.dirname(__FILE__), 'set_session_matcher')
2
+
3
+ module Remarkable
4
+ module ActionController
5
+ module Matchers
6
+ class SetTheFlashMatcher < SetSessionMatcher #:nodoc:
7
+
8
+ protected
9
+ def session
10
+ @subject ? (@subject.response.session['flash'] || {}) : {}
11
+ end
12
+
13
+ def interpolation_options
14
+ { :flash_inspect => session.symbolize_keys!.inspect }
15
+ end
16
+
17
+ end
18
+
19
19
  # Ensures that a flash message is being set. If you want to check that a
20
- # flash is not being set, just do:
21
- #
22
- # should_not_set_the_flash :user
23
- #
24
- # If you want to assure that a flash is being set to nil, do instead:
25
- #
26
- # should_set_the_flash :user, :to => nil
27
- #
28
- # == Options
29
- #
20
+ # flash is not being set, just do:
21
+ #
22
+ # should_not_set_the_flash :user
23
+ #
24
+ # If you want to assure that a flash is being set to nil, do instead:
25
+ #
26
+ # should_set_the_flash :user, :to => nil
27
+ #
28
+ # == Options
29
+ #
30
30
  # * <tt>:to</tt> - The value to compare the flash key.
31
- # It accepts procs and can also be given as a block (see examples below)
32
- #
33
- # == Examples
34
- #
35
- # should_set_the_flash
36
- # should_not_set_the_flash
37
- #
38
- # should_set_the_flash :to => 'message'
39
- # should_set_the_flash :notice, :warn
40
- # should_set_the_flash :notice, :to => 'message'
41
- # should_set_the_flash :notice, :to => proc{ 'hi ' + users(:first).name }
42
- # should_set_the_flash(:notice){ 'hi ' + users(:first).name }
43
- #
44
- # it { should set_the_flash }
45
- # it { should set_the_flash.to('message') }
46
- # it { should set_the_flash(:notice, :warn) }
47
- # it { should set_the_flash(:notice, :to => 'message') }
48
- # it { should set_the_flash(:notice, :to => ('hi ' + users(:first).name)) }
49
- #
50
- def set_the_flash(*args, &block)
51
- SetTheFlashMatcher.new(*args, &block).spec(self)
52
- end
53
-
54
- end
55
- end
56
- end
31
+ # It accepts procs and can also be given as a block (see examples below)
32
+ #
33
+ # == Examples
34
+ #
35
+ # should_set_the_flash
36
+ # should_not_set_the_flash
37
+ #
38
+ # should_set_the_flash :to => 'message'
39
+ # should_set_the_flash :notice, :warn
40
+ # should_set_the_flash :notice, :to => 'message'
41
+ # should_set_the_flash :notice, :to => proc{ 'hi ' + users(:first).name }
42
+ # should_set_the_flash(:notice){ 'hi ' + users(:first).name }
43
+ #
44
+ # it { should set_the_flash }
45
+ # it { should set_the_flash.to('message') }
46
+ # it { should set_the_flash(:notice, :warn) }
47
+ # it { should set_the_flash(:notice, :to => 'message') }
48
+ # it { should set_the_flash(:notice, :to => ('hi ' + users(:first).name)) }
49
+ #
50
+ def set_the_flash(*args, &block)
51
+ SetTheFlashMatcher.new(*args, &block).spec(self)
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -1,22 +1,22 @@
1
- module Remarkable
2
- module ActionController
3
- end
4
- end
5
-
6
- dir = File.dirname(__FILE__)
7
- require File.join(dir, 'action_controller', 'base')
8
- require File.join(dir, 'action_controller', 'macro_stubs')
9
-
10
- # Load matchers
11
- Dir[File.join(dir, 'action_controller', 'matchers', '*.rb')].each do |file|
12
- require file
13
- end
14
-
15
- # Include macro_stubs and matchers in Spec::Rails
16
- if defined?(Spec::Rails)
17
- Spec::Rails::Example::ControllerExampleGroup.send :include, Remarkable::ActionController::MacroStubs
18
-
19
- Remarkable.include_matchers!(Remarkable::ActionController, Spec::Rails::Example::ControllerExampleGroup)
20
- Remarkable.include_matchers!(Remarkable::ActionController, Spec::Rails::Example::RoutingExampleGroup)
21
- end
22
-
1
+ module Remarkable
2
+ module ActionController
3
+ end
4
+ end
5
+
6
+ dir = File.dirname(__FILE__)
7
+ require File.join(dir, 'action_controller', 'base')
8
+ require File.join(dir, 'action_controller', 'macro_stubs')
9
+
10
+ # Load matchers
11
+ Dir[File.join(dir, 'action_controller', 'matchers', '*.rb')].each do |file|
12
+ require file
13
+ end
14
+
15
+ # Include macro_stubs and matchers in Spec::Rails
16
+ if defined?(Spec::Rails)
17
+ Spec::Rails::Example::ControllerExampleGroup.send :include, Remarkable::ActionController::MacroStubs
18
+
19
+ Remarkable.include_matchers!(Remarkable::ActionController, Spec::Rails::Example::ControllerExampleGroup)
20
+ Remarkable.include_matchers!(Remarkable::ActionController, Spec::Rails::Example::RoutingExampleGroup)
21
+ end
22
+
@@ -1,7 +1,7 @@
1
- module Remarkable
2
- module ActionView
3
- class Base < Remarkable::Base
4
-
5
- end
6
- end
7
- end
1
+ module Remarkable
2
+ module ActionView
3
+ class Base < Remarkable::Base
4
+
5
+ end
6
+ end
7
+ end
@@ -1,18 +1,18 @@
1
- module Remarkable
2
- module ActionView
3
- end
4
- end
5
-
6
- dir = File.dirname(__FILE__)
7
- require File.join(dir, 'action_view', 'base')
8
-
9
- # Load matchers
10
- Dir[File.join(dir, 'action_view', 'matchers', '*.rb')].each do |file|
11
- require file
12
- end
13
-
14
- # Iinclude matchers in Spec::Rails
15
- if defined?(Spec::Rails)
16
- Remarkable.include_matchers!(Remarkable::ActionView, Spec::Rails::Example::FunctionalExampleGroup)
17
- end
18
-
1
+ module Remarkable
2
+ module ActionView
3
+ end
4
+ end
5
+
6
+ dir = File.dirname(__FILE__)
7
+ require File.join(dir, 'action_view', 'base')
8
+
9
+ # Load matchers
10
+ Dir[File.join(dir, 'action_view', 'matchers', '*.rb')].each do |file|
11
+ require file
12
+ end
13
+
14
+ # Iinclude matchers in Spec::Rails
15
+ if defined?(Spec::Rails)
16
+ Remarkable.include_matchers!(Remarkable::ActionView, Spec::Rails::Example::FunctionalExampleGroup)
17
+ end
18
+
@@ -1,19 +1,19 @@
1
- # This will responsable to check which ORM is loaded and include respective
2
- # matchers.
3
- #
4
- if defined?(ActiveRecord::Base)
5
- unless Remarkable.const_defined?('ActiveRecord')
6
- begin
7
- require 'remarkable_activerecord'
8
- rescue LoadError
9
- require 'rubygems'
10
- gem 'remarkable_activerecord'
11
- require 'remarkable_activerecord'
12
- end
13
- end
14
-
15
- # Include Remarkable ActiveRecord matcher in appropriate ExampleGroup
16
- if defined?(Spec::Rails)
17
- Remarkable.include_matchers!(Remarkable::ActiveRecord, Spec::Rails::Example::ModelExampleGroup)
18
- end
19
- end
1
+ # This will responsable to check which ORM is loaded and include respective
2
+ # matchers.
3
+ #
4
+ if defined?(ActiveRecord::Base)
5
+ unless Remarkable.const_defined?('ActiveRecord')
6
+ begin
7
+ require 'remarkable_activerecord'
8
+ rescue LoadError
9
+ require 'rubygems'
10
+ gem 'remarkable_activerecord'
11
+ require 'remarkable_activerecord'
12
+ end
13
+ end
14
+
15
+ # Include Remarkable ActiveRecord matcher in appropriate ExampleGroup
16
+ if defined?(Spec::Rails)
17
+ Remarkable.include_matchers!(Remarkable::ActiveRecord, Spec::Rails::Example::ModelExampleGroup)
18
+ end
19
+ end
@@ -1,33 +1,33 @@
1
- # Load Remarkable
2
- unless Object.const_defined?('Remarkable')
3
- begin
4
- require 'remarkable'
5
- rescue LoadError
6
- require 'rubygems'
7
- gem 'remarkable'
8
- require 'remarkable'
9
- end
10
- end
11
-
12
- # Load spec/rails
13
- if defined?(Spec)
14
- begin
15
- require 'spec/rails'
16
- rescue LoadError
17
- require 'rubygems'
18
- gem 'rspec-rails'
19
- require 'spec/rails'
20
- end
21
- end
22
-
23
- # Load Remarkable Rails base files
24
- dir = File.dirname(__FILE__)
25
- require File.join(dir, 'remarkable_rails', 'active_orm')
26
- require File.join(dir, 'remarkable_rails', 'action_controller')
27
- require File.join(dir, 'remarkable_rails', 'action_view')
28
-
29
- # Load locale file
30
- Remarkable.add_locale File.join(dir, '..', 'locale', 'en.yml')
1
+ # Load Remarkable
2
+ unless Object.const_defined?('Remarkable')
3
+ begin
4
+ require 'remarkable'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ gem 'remarkable'
8
+ require 'remarkable'
9
+ end
10
+ end
11
+
12
+ # Load spec/rails
13
+ if defined?(Spec)
14
+ begin
15
+ require 'spec/rails'
16
+ rescue LoadError
17
+ require 'rubygems'
18
+ gem 'rspec-rails'
19
+ require 'spec/rails'
20
+ end
21
+ end
22
+
23
+ # Load Remarkable Rails base files
24
+ dir = File.dirname(__FILE__)
25
+ require File.join(dir, 'remarkable_rails', 'active_orm')
26
+ require File.join(dir, 'remarkable_rails', 'action_controller')
27
+ require File.join(dir, 'remarkable_rails', 'action_view')
28
+
29
+ # Load locale file
30
+ Remarkable.add_locale File.join(dir, '..', 'locale', 'en.yml')
31
31
  # Load plugin files if RAILS_ROOT is defined. It loads files at:
32
32
  #
33
33
  # RAILS_ROOT/spec/remarkable
data/locale/en.yml CHANGED
@@ -1,110 +1,110 @@
1
- en:
2
- remarkable:
3
- action_controller:
4
- responding: "responding to #{{verb}} {{action}}"
5
- mime_type: "with {{format}}"
6
-
7
- assign_to:
8
- description: "assign {{names}}"
9
- expectations:
10
- assigned_value: "action to assign {{name}}, got no assignment"
11
- is_kind_of: "assign {{name}} to be kind of {{with_kind_of}}, got a {{assign_class}}"
12
- is_equal_value: "assign {{name}} to be equal to {{with}}, got {{assign_inspect}}"
13
- optionals:
14
- with_kind_of:
15
- positive: "with kind of {{value}}"
16
-
17
- filter_params:
18
- description: "filter {{params}} parameters from log"
19
- expectations:
20
- respond_to_filter_params: "controller to respond to filter_parameters (controller is not filtering any parameter)"
21
- is_filtered: "{{param}} to be filtered, got no filtering"
22
-
23
- redirect_to:
24
- description: "redirect to {{expected}}"
25
- expectations:
26
- redirected: "redirect to {{expected}}, got no redirect"
27
- status_matches: "redirect to {{expected}} with status {{with}}, got status {{status}}"
28
- url_matches: "redirect to {{expected}}, got redirect to {{actual}}"
29
- optionals:
30
- with:
31
- positive: "with status {{inspect}}"
32
-
33
- render_template:
34
- description: "render"
35
- expectations:
36
- rendered: "template {{template}} to be rendered, got no render"
37
- template_matches: "template {{template}} to be rendered, got {{actual_template}}"
38
- layout_matches: "to render with layout {{layout}}, got {{actual_layout}}"
39
- status_matches: "to render with status {{with}}, got {{actual_status}}"
40
- body_matches: "to render with body {{body}}, got {{actual_body}}"
41
- content_type_matches: "to render with content type {{content_type}}, got {{actual_content_type}}"
42
- optionals:
43
- template:
44
- positive: "template {{inspect}}"
45
- layout:
46
- positive: "with layout {{inspect}}"
47
- negative: "with no layout"
48
- with:
49
- positive: "with {{value}}"
50
- body:
51
- positive: "with body {{inspect}}"
52
- content_type:
53
- positive: "with content type {{inspect}}"
54
-
55
- respond_with:
56
- description: "respond"
57
- expectations:
58
- status_matches: "to respond with status {{with}}, got {{actual_status}}"
59
- body_matches: "to respond with body {{body}}, got {{actual_body}}"
60
- content_type_matches: "to respond with content type {{content_type}}, got {{actual_content_type}}"
61
- optionals:
62
- with:
63
- positive: "with {{value}}"
64
- body:
65
- positive: "with body {{inspect}}"
66
- content_type:
67
- positive: "with content type {{inspect}}"
68
-
69
- route:
70
- description: "route {{method}} {{path}} to/from {{options}}"
71
- expectations:
72
- map_to_path: "to map {{options}} to {{method}} {{path}}, got {{actual}}"
73
- generate_params: "to generate params {{options}} from {{method}} {{path}}, got {{actual}}"
74
-
75
- set_cookies:
76
- description: "set cookies {{keys}}"
77
- expectations:
78
- is_not_empty: "any cookie to be set, got {{cookies_inspect}}"
79
- contains_value: "any cookie to be set to {{to}}, got {{cookies_inspect}}"
80
- assigned_value: "cookie {{key}} to be set, got {{cookies_inspect}}"
81
- is_equal_value: "cookie {{key}} to be set to {{to}}, got {{cookies_inspect}}"
82
- optionals:
83
- to:
84
- positive: "to {{inspect}}"
85
- negative: "to {{inspect}}"
86
-
87
- set_session:
88
- description: "set session variable {{keys}}"
89
- expectations:
90
- is_not_empty: "any session variable to be set, got {{session_inspect}}"
91
- contains_value: "any session variable to be set to {{to}}, got {{session_inspect}}"
92
- assigned_value: "session variable {{key}} to be set, got {{session_inspect}}"
93
- is_equal_value: "session variable {{key}} to be set to {{to}}, got {{session_inspect}}"
94
- optionals:
95
- to:
96
- positive: "to {{inspect}}"
97
- negative: "to {{inspect}}"
98
-
99
- set_the_flash:
100
- description: "set the flash message {{keys}}"
101
- expectations:
102
- is_not_empty: "any flash message to be set, got {{flash_inspect}}"
103
- contains_value: "any flash message to be set to {{to}}, got {{flash_inspect}}"
104
- assigned_value: "flash message {{key}} to be set, got {{flash_inspect}}"
105
- is_equal_value: "flash message {{key}} to be set to {{to}}, got {{flash_inspect}}"
106
- optionals:
107
- to:
108
- positive: "to {{inspect}}"
109
- negative: "to {{inspect}}"
110
-
1
+ en:
2
+ remarkable:
3
+ action_controller:
4
+ responding: "responding to #{{verb}} {{action}}"
5
+ mime_type: "with {{format}}"
6
+
7
+ assign_to:
8
+ description: "assign {{names}}"
9
+ expectations:
10
+ assigned_value: "action to assign {{name}}, got no assignment"
11
+ is_kind_of: "assign {{name}} to be kind of {{with_kind_of}}, got a {{assign_class}}"
12
+ is_equal_value: "assign {{name}} to be equal to {{with}}, got {{assign_inspect}}"
13
+ optionals:
14
+ with_kind_of:
15
+ positive: "with kind of {{value}}"
16
+
17
+ filter_params:
18
+ description: "filter {{params}} parameters from log"
19
+ expectations:
20
+ respond_to_filter_params: "controller to respond to filter_parameters (controller is not filtering any parameter)"
21
+ is_filtered: "{{param}} to be filtered, got no filtering"
22
+
23
+ redirect_to:
24
+ description: "redirect to {{expected}}"
25
+ expectations:
26
+ redirected: "redirect to {{expected}}, got no redirect"
27
+ status_matches: "redirect to {{expected}} with status {{with}}, got status {{status}}"
28
+ url_matches: "redirect to {{expected}}, got redirect to {{actual}}"
29
+ optionals:
30
+ with:
31
+ positive: "with status {{inspect}}"
32
+
33
+ render_template:
34
+ description: "render"
35
+ expectations:
36
+ rendered: "template {{template}} to be rendered, got no render"
37
+ template_matches: "template {{template}} to be rendered, got {{actual_template}}"
38
+ layout_matches: "to render with layout {{layout}}, got {{actual_layout}}"
39
+ status_matches: "to render with status {{with}}, got {{actual_status}}"
40
+ body_matches: "to render with body {{body}}, got {{actual_body}}"
41
+ content_type_matches: "to render with content type {{content_type}}, got {{actual_content_type}}"
42
+ optionals:
43
+ template:
44
+ positive: "template {{inspect}}"
45
+ layout:
46
+ positive: "with layout {{inspect}}"
47
+ negative: "with no layout"
48
+ with:
49
+ positive: "with {{value}}"
50
+ body:
51
+ positive: "with body {{inspect}}"
52
+ content_type:
53
+ positive: "with content type {{inspect}}"
54
+
55
+ respond_with:
56
+ description: "respond"
57
+ expectations:
58
+ status_matches: "to respond with status {{with}}, got {{actual_status}}"
59
+ body_matches: "to respond with body {{body}}, got {{actual_body}}"
60
+ content_type_matches: "to respond with content type {{content_type}}, got {{actual_content_type}}"
61
+ optionals:
62
+ with:
63
+ positive: "with {{value}}"
64
+ body:
65
+ positive: "with body {{inspect}}"
66
+ content_type:
67
+ positive: "with content type {{inspect}}"
68
+
69
+ route:
70
+ description: "route {{method}} {{path}} to/from {{options}}"
71
+ expectations:
72
+ map_to_path: "to map {{options}} to {{method}} {{path}}, got {{actual}}"
73
+ generate_params: "to generate params {{options}} from {{method}} {{path}}, got {{actual}}"
74
+
75
+ set_cookies:
76
+ description: "set cookies {{keys}}"
77
+ expectations:
78
+ is_not_empty: "any cookie to be set, got {{cookies_inspect}}"
79
+ contains_value: "any cookie to be set to {{to}}, got {{cookies_inspect}}"
80
+ assigned_value: "cookie {{key}} to be set, got {{cookies_inspect}}"
81
+ is_equal_value: "cookie {{key}} to be set to {{to}}, got {{cookies_inspect}}"
82
+ optionals:
83
+ to:
84
+ positive: "to {{inspect}}"
85
+ negative: "to {{inspect}}"
86
+
87
+ set_session:
88
+ description: "set session variable {{keys}}"
89
+ expectations:
90
+ is_not_empty: "any session variable to be set, got {{session_inspect}}"
91
+ contains_value: "any session variable to be set to {{to}}, got {{session_inspect}}"
92
+ assigned_value: "session variable {{key}} to be set, got {{session_inspect}}"
93
+ is_equal_value: "session variable {{key}} to be set to {{to}}, got {{session_inspect}}"
94
+ optionals:
95
+ to:
96
+ positive: "to {{inspect}}"
97
+ negative: "to {{inspect}}"
98
+
99
+ set_the_flash:
100
+ description: "set the flash message {{keys}}"
101
+ expectations:
102
+ is_not_empty: "any flash message to be set, got {{flash_inspect}}"
103
+ contains_value: "any flash message to be set to {{to}}, got {{flash_inspect}}"
104
+ assigned_value: "flash message {{key}} to be set, got {{flash_inspect}}"
105
+ is_equal_value: "flash message {{key}} to be set to {{to}}, got {{flash_inspect}}"
106
+ optionals:
107
+ to:
108
+ positive: "to {{inspect}}"
109
+ negative: "to {{inspect}}"
110
+