remarkable_rails 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. data/CHANGELOG +44 -44
  2. data/LICENSE +1 -1
  3. data/README +83 -83
  4. data/lib/remarkable_rails/action_controller/base.rb +24 -24
  5. data/lib/remarkable_rails/action_controller/macro_stubs.rb +493 -493
  6. data/lib/remarkable_rails/action_controller/matchers/assign_to_matcher.rb +72 -72
  7. data/lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb +21 -21
  8. data/lib/remarkable_rails/action_controller/matchers/redirect_to_matcher.rb +112 -112
  9. data/lib/remarkable_rails/action_controller/matchers/render_template_matcher.rb +140 -140
  10. data/lib/remarkable_rails/action_controller/matchers/respond_with_matcher.rb +118 -118
  11. data/lib/remarkable_rails/action_controller/matchers/route_matcher.rb +51 -51
  12. data/lib/remarkable_rails/action_controller/matchers/set_session_matcher.rb +103 -103
  13. data/lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb +50 -50
  14. data/lib/remarkable_rails/action_view/base.rb +1 -1
  15. data/lib/remarkable_rails/action_view.rb +16 -16
  16. data/lib/remarkable_rails/active_orm.rb +2 -2
  17. data/locale/en.yml +74 -74
  18. data/spec/action_controller/assign_to_matcher_spec.rb +68 -68
  19. data/spec/action_controller/filter_params_matcher_spec.rb +42 -42
  20. data/spec/action_controller/macro_stubs_spec.rb +17 -17
  21. data/spec/action_controller/redirect_to_matcher_spec.rb +60 -60
  22. data/spec/action_controller/render_template_matcher_spec.rb +227 -227
  23. data/spec/action_controller/respond_with_matcher_spec.rb +189 -189
  24. data/spec/action_controller/route_matcher_spec.rb +75 -75
  25. data/spec/action_controller/set_session_matcher_spec.rb +43 -43
  26. data/spec/action_controller/set_the_flash_matcher_spec.rb +1 -1
  27. data/spec/application/application.rb +14 -14
  28. data/spec/application/tasks_controller.rb +34 -34
  29. data/spec/functional_builder.rb +93 -93
  30. data/spec/spec_helper.rb +44 -44
  31. metadata +4 -4
@@ -45,14 +45,14 @@ describe 'set_session' do
45
45
  end
46
46
 
47
47
  describe 'matcher' do
48
- before(:each) do
49
- build_response {
50
- session[:user] = 'jose'
51
- session[:address] = 'Avenue'
52
- session[:true] = true
53
- session[:false] = false
54
- session[:nil] = nil
55
- }
48
+ before(:each) do
49
+ build_response {
50
+ session[:user] = 'jose'
51
+ session[:address] = 'Avenue'
52
+ session[:true] = true
53
+ session[:false] = false
54
+ session[:nil] = nil
55
+ }
56
56
  end
57
57
 
58
58
  it { should set_session }
@@ -66,33 +66,33 @@ describe 'set_session' do
66
66
 
67
67
  it { should set_session(:user){ 'jose' } }
68
68
  it { should set_session(:user, :to => proc{ 'jose' }) }
69
-
69
+
70
70
  it { should_not set_session(:user).to(nil) }
71
71
  it { should_not set_session(:user){ 'joseph' } }
72
- it { should_not set_session(:user, :to => proc{ 'joseph' }) }
73
-
74
- it { should set_session(:true) }
75
- it { should set_session(:true).to(true) }
76
- it { should_not set_session(:true).to(false) }
77
-
78
- it { should set_session(:false) }
79
- it { should set_session(:false).to(false) }
80
- it { should_not set_session(:false).to(true) }
81
-
82
- it { should set_session(:nil) }
83
- it { should set_session(:nil).to(nil) }
72
+ it { should_not set_session(:user, :to => proc{ 'joseph' }) }
73
+
74
+ it { should set_session(:true) }
75
+ it { should set_session(:true).to(true) }
76
+ it { should_not set_session(:true).to(false) }
77
+
78
+ it { should set_session(:false) }
79
+ it { should set_session(:false).to(false) }
80
+ it { should_not set_session(:false).to(true) }
81
+
82
+ it { should set_session(:nil) }
83
+ it { should set_session(:nil).to(nil) }
84
84
  it { should_not set_session(:nil).to(true) }
85
85
  end
86
86
 
87
87
  describe 'macro' do
88
- before(:each) do
89
- build_response {
90
- session[:user] = 'jose'
91
- session[:address] = 'Avenue'
92
- session[:true] = true
93
- session[:false] = false
94
- session[:nil] = nil
95
- }
88
+ before(:each) do
89
+ build_response {
90
+ session[:user] = 'jose'
91
+ session[:address] = 'Avenue'
92
+ session[:true] = true
93
+ session[:false] = false
94
+ session[:nil] = nil
95
+ }
96
96
  end
97
97
 
98
98
  should_set_session
@@ -106,21 +106,21 @@ describe 'set_session' do
106
106
 
107
107
  should_set_session(:user){ 'jose' }
108
108
  should_set_session :user, :to => proc{ 'jose' }
109
-
109
+
110
110
  should_not_set_session :user, :to => nil
111
111
  should_not_set_session(:user){ 'joseph' }
112
- should_not_set_session :user, :to => proc{ 'joseph' }
113
-
114
- should_set_session :true
115
- should_set_session :true, :to => true
116
- should_not_set_session :true, :to => false
117
-
118
- should_set_session :false
119
- should_set_session :false, :to => false
120
- should_not_set_session :false, :to => true
121
-
122
- should_set_session :nil
123
- should_set_session :nil, :to => nil
112
+ should_not_set_session :user, :to => proc{ 'joseph' }
113
+
114
+ should_set_session :true
115
+ should_set_session :true, :to => true
116
+ should_not_set_session :true, :to => false
117
+
118
+ should_set_session :false
119
+ should_set_session :false, :to => false
120
+ should_not_set_session :false, :to => true
121
+
122
+ should_set_session :nil
123
+ should_set_session :nil, :to => nil
124
124
  should_not_set_session :nil, :to => true
125
125
  end
126
126
 
@@ -130,6 +130,6 @@ describe 'set_session' do
130
130
  should_not_set_session
131
131
  it { should_not set_session }
132
132
  end
133
-
133
+
134
134
  generate_macro_stubs_specs_for(:set_session)
135
135
  end
@@ -90,6 +90,6 @@ describe 'set_the_flash' do
90
90
  should_not_set_the_flash
91
91
  it { should_not set_the_flash }
92
92
  end
93
-
93
+
94
94
  generate_macro_stubs_specs_for(:set_the_flash)
95
95
  end
@@ -1,15 +1,15 @@
1
- # Create an application controller to satisfy rspec-rails, a dummy controller
2
- # and define routes.
3
- #
4
- class ApplicationController < ActionController::Base
5
- end
6
-
7
- class Task; end
8
-
9
- # Define routes
10
- ActionController::Routing::Routes.draw do |map|
11
- map.resources :projects, :has_many => :tasks
1
+ # Create an application controller to satisfy rspec-rails, a dummy controller
2
+ # and define routes.
3
+ #
4
+ class ApplicationController < ActionController::Base
5
+ end
6
+
7
+ class Task; end
8
+
9
+ # Define routes
10
+ ActionController::Routing::Routes.draw do |map|
11
+ map.resources :projects, :has_many => :tasks
12
12
  map.connect ':controller/:action/:id'
13
- map.connect ':controller/:action/:id.:format'
14
- end
15
-
13
+ map.connect ':controller/:action/:id.:format'
14
+ end
15
+
@@ -1,34 +1,34 @@
1
- class TasksController < ApplicationController
2
- filter_parameter_logging :password
3
-
4
- def index
5
- @tasks = Task.find(:all)
6
- render :text => 'index'
7
- end
8
-
9
- def new
10
- render :nothing => true
11
- end
12
-
13
- def show
14
- @task = Task.find(params[:id])
15
-
16
- respond_to do |format|
17
- format.html { render :text => 'show' }
18
- format.xml { render :xml => @task.to_xml }
19
- end
20
- end
21
-
22
- def destroy
23
- @task = Task.find(params[:id])
24
- @task.destroy
25
-
26
- flash[:notice] = 'Task deleted.'
27
- session[:last_task_id] = 37
28
-
29
- respond_to do |format|
30
- format.html { redirect_to project_tasks_url(10) }
31
- format.xml { head :ok }
32
- end
33
- end
34
- end
1
+ class TasksController < ApplicationController
2
+ filter_parameter_logging :password
3
+
4
+ def index
5
+ @tasks = Task.find(:all)
6
+ render :text => 'index'
7
+ end
8
+
9
+ def new
10
+ render :nothing => true
11
+ end
12
+
13
+ def show
14
+ @task = Task.find(params[:id])
15
+
16
+ respond_to do |format|
17
+ format.html { render :text => 'show' }
18
+ format.xml { render :xml => @task.to_xml }
19
+ end
20
+ end
21
+
22
+ def destroy
23
+ @task = Task.find(params[:id])
24
+ @task.destroy
25
+
26
+ flash[:notice] = 'Task deleted.'
27
+ session[:last_task_id] = 37
28
+
29
+ respond_to do |format|
30
+ format.html { redirect_to project_tasks_url(10) }
31
+ format.xml { head :ok }
32
+ end
33
+ end
34
+ end
@@ -1,93 +1,93 @@
1
- # This is based on Shoulda model builder for Test::Unit.
2
- #
3
- module FunctionalBuilder
4
- def self.included(base)
5
- base.class_eval do
6
- return unless base.name =~ /^Spec/
7
-
8
- base.controller_name 'application'
9
- base.integrate_views false
10
-
11
- after(:each) do
12
- if @defined_constants
13
- @defined_constants.each do |class_name|
14
- Object.send(:remove_const, class_name)
15
- end
16
- end
17
- end
18
- end
19
-
20
- base.extend ClassMethods
21
- end
22
-
23
- def build_response(&block)
24
- klass = defined?(ExamplesController) ? ExamplesController : define_controller('Examples')
25
- block ||= lambda { render :nothing => true }
26
- klass.class_eval { define_method(:example, &block) }
27
-
28
- @controller = klass.new
29
- @request = ActionController::TestRequest.new
30
- @response = ActionController::TestResponse.new
31
- get :example
32
-
33
- self.class.subject { @controller }
34
- end
35
-
36
- def define_controller(class_name, &block)
37
- class_name = class_name.to_s
38
- class_name << 'Controller' unless class_name =~ /Controller$/
39
- define_constant(class_name, ApplicationController, &block)
40
- end
41
-
42
- def define_constant(class_name, base, &block)
43
- class_name = class_name.to_s.camelize
44
-
45
- klass = Class.new(base)
46
- Object.const_set(class_name, klass)
47
-
48
- klass.class_eval(&block) if block_given?
49
-
50
- @defined_constants ||= []
51
- @defined_constants << class_name
52
-
53
- klass
54
- end
55
-
56
- module ClassMethods
57
- def generate_macro_stubs_specs_for(matcher, *args)
58
- stubs_args = args.dup
59
-
60
- options = args.extract_options!
61
- expectations_args = (args << options.merge(:with_expectations => true))
62
-
63
- describe 'macro stubs' do
64
- before(:each) do
65
- @controller = TasksController.new
66
- @request = ActionController::TestRequest.new
67
- @response = ActionController::TestResponse.new
68
- end
69
-
70
- expects :new, :on => String, :with => 'ola', :returns => 'ola'
71
- get :new
72
-
73
- it 'should run stubs by default' do
74
- String.should_receive(:stub!).with(:new).and_return(@mock=mock('chain'))
75
- @mock.should_receive(:and_return).with('ola').and_return('ola')
76
-
77
- send(matcher, *stubs_args).matches?(@controller)
78
- end
79
-
80
- it 'should run expectations' do
81
- String.should_receive(:should_receive).with(:new).and_return(@mock=mock('chain'))
82
- @mock.should_receive(:with).with('ola').and_return(@mock)
83
- @mock.should_receive(:exactly).with(1).and_return(@mock)
84
- @mock.should_receive(:times).and_return(@mock)
85
- @mock.should_receive(:and_return).with('ola').and_return('ola')
86
-
87
- send(matcher, *expectations_args).matches?(@controller)
88
- end
89
- end
90
-
91
- end
92
- end
93
- end
1
+ # This is based on Shoulda model builder for Test::Unit.
2
+ #
3
+ module FunctionalBuilder
4
+ def self.included(base)
5
+ base.class_eval do
6
+ return unless base.name =~ /^Spec/
7
+
8
+ base.controller_name 'application'
9
+ base.integrate_views false
10
+
11
+ after(:each) do
12
+ if @defined_constants
13
+ @defined_constants.each do |class_name|
14
+ Object.send(:remove_const, class_name)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ base.extend ClassMethods
21
+ end
22
+
23
+ def build_response(&block)
24
+ klass = defined?(ExamplesController) ? ExamplesController : define_controller('Examples')
25
+ block ||= lambda { render :nothing => true }
26
+ klass.class_eval { define_method(:example, &block) }
27
+
28
+ @controller = klass.new
29
+ @request = ActionController::TestRequest.new
30
+ @response = ActionController::TestResponse.new
31
+ get :example
32
+
33
+ self.class.subject { @controller }
34
+ end
35
+
36
+ def define_controller(class_name, &block)
37
+ class_name = class_name.to_s
38
+ class_name << 'Controller' unless class_name =~ /Controller$/
39
+ define_constant(class_name, ApplicationController, &block)
40
+ end
41
+
42
+ def define_constant(class_name, base, &block)
43
+ class_name = class_name.to_s.camelize
44
+
45
+ klass = Class.new(base)
46
+ Object.const_set(class_name, klass)
47
+
48
+ klass.class_eval(&block) if block_given?
49
+
50
+ @defined_constants ||= []
51
+ @defined_constants << class_name
52
+
53
+ klass
54
+ end
55
+
56
+ module ClassMethods
57
+ def generate_macro_stubs_specs_for(matcher, *args)
58
+ stubs_args = args.dup
59
+
60
+ options = args.extract_options!
61
+ expectations_args = (args << options.merge(:with_expectations => true))
62
+
63
+ describe 'macro stubs' do
64
+ before(:each) do
65
+ @controller = TasksController.new
66
+ @request = ActionController::TestRequest.new
67
+ @response = ActionController::TestResponse.new
68
+ end
69
+
70
+ expects :new, :on => String, :with => 'ola', :returns => 'ola'
71
+ get :new
72
+
73
+ it 'should run stubs by default' do
74
+ String.should_receive(:stub!).with(:new).and_return(@mock=mock('chain'))
75
+ @mock.should_receive(:and_return).with('ola').and_return('ola')
76
+
77
+ send(matcher, *stubs_args).matches?(@controller)
78
+ end
79
+
80
+ it 'should run expectations' do
81
+ String.should_receive(:should_receive).with(:new).and_return(@mock=mock('chain'))
82
+ @mock.should_receive(:with).with('ola').and_return(@mock)
83
+ @mock.should_receive(:exactly).with(1).and_return(@mock)
84
+ @mock.should_receive(:times).and_return(@mock)
85
+ @mock.should_receive(:and_return).with('ola').and_return('ola')
86
+
87
+ send(matcher, *expectations_args).matches?(@controller)
88
+ end
89
+ end
90
+
91
+ end
92
+ end
93
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,44 +1,44 @@
1
- require 'rubygems'
2
- require 'ruby-debug'
3
-
4
- RAILS_ENV = 'test'
5
- RAILS_VERSION = ENV['RAILS_VERSION'] || '=2.2.2'
6
- RSPEC_VERSION = ENV['RSPEC_VERSION'] || Spec::VERSION::STRING
7
-
8
- # Load Rails
9
- gem 'activesupport', RAILS_VERSION
10
- require 'active_support'
11
-
12
- gem 'actionpack', RAILS_VERSION
13
- require 'action_controller'
14
-
15
- gem 'actionmailer', RAILS_VERSION
16
- require 'action_mailer'
17
-
18
- gem 'rails', RAILS_VERSION
19
- require 'rails/version'
20
-
21
- # Load Remarkable core on place to avoid gem to be loaded
22
- dir = File.dirname(__FILE__)
23
- require File.join(dir, '..', '..', 'remarkable', 'lib', 'remarkable')
24
-
25
- # Add spec/application to load path and set view_paths
26
- RAILS_ROOT = File.join(dir, 'application')
27
- $:.unshift(RAILS_ROOT)
28
-
29
- ActionController::Base.view_paths = RAILS_ROOT
30
- require File.join(RAILS_ROOT, 'application')
31
- require File.join(RAILS_ROOT, 'tasks_controller')
32
-
33
- # Load Remarkable Rails
34
- require File.join(dir, 'functional_builder')
35
-
36
- # Load spec-rails
37
- gem 'rspec-rails', RSPEC_VERSION
38
- require 'spec/rails'
39
-
40
- require File.join(dir, '..', 'lib', 'remarkable_rails')
41
-
42
- # Register folders to example groups
43
- Spec::Example::ExampleGroupFactory.register(:action_controller, Spec::Rails::Example::ControllerExampleGroup)
44
-
1
+ require 'rubygems'
2
+ require 'ruby-debug'
3
+
4
+ RAILS_ENV = 'test'
5
+ RAILS_VERSION = ENV['RAILS_VERSION'] || '=2.2.2'
6
+ RSPEC_VERSION = ENV['RSPEC_VERSION'] || Spec::VERSION::STRING
7
+
8
+ # Load Rails
9
+ gem 'activesupport', RAILS_VERSION
10
+ require 'active_support'
11
+
12
+ gem 'actionpack', RAILS_VERSION
13
+ require 'action_controller'
14
+
15
+ gem 'actionmailer', RAILS_VERSION
16
+ require 'action_mailer'
17
+
18
+ gem 'rails', RAILS_VERSION
19
+ require 'rails/version'
20
+
21
+ # Load Remarkable core on place to avoid gem to be loaded
22
+ dir = File.dirname(__FILE__)
23
+ require File.join(dir, '..', '..', 'remarkable', 'lib', 'remarkable')
24
+
25
+ # Add spec/application to load path and set view_paths
26
+ RAILS_ROOT = File.join(dir, 'application')
27
+ $:.unshift(RAILS_ROOT)
28
+
29
+ ActionController::Base.view_paths = RAILS_ROOT
30
+ require File.join(RAILS_ROOT, 'application')
31
+ require File.join(RAILS_ROOT, 'tasks_controller')
32
+
33
+ # Load Remarkable Rails
34
+ require File.join(dir, 'functional_builder')
35
+
36
+ # Load spec-rails
37
+ gem 'rspec-rails', RSPEC_VERSION
38
+ require 'spec/rails'
39
+
40
+ require File.join(dir, '..', 'lib', 'remarkable_rails')
41
+
42
+ # Register folders to example groups
43
+ Spec::Example::ExampleGroupFactory.register(:action_controller, Spec::Rails::Example::ControllerExampleGroup)
44
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remarkable_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Brando
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-04-10 00:00:00 +02:00
13
+ date: 2009-04-13 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 3.0.1
34
+ version: 3.0.2
35
35
  version:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: remarkable_activerecord
@@ -41,7 +41,7 @@ dependencies:
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 3.0.1
44
+ version: 3.0.2
45
45
  version:
46
46
  description: "Remarkable Rails: collection of matchers and macros with I18n for Rails"
47
47
  email: