Class: Spec::Rails::Example::ControllerExampleGroup
- Inherits:
-
FunctionalExampleGroup
- Object
- FunctionalExampleGroup
- Spec::Rails::Example::ControllerExampleGroup
- Defined in:
- lib/controller_example_group.rb
Instance Method Summary collapse
-
#on_deleting_from(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP DELETE, performing any code in the block beforehand.
-
#on_getting(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP GET, performing any code in the block beforehand.
-
#on_posting_to(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP POST, performing any code in the block beforehand.
-
#on_putting_to(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP PUT, performing any code in the block beforehand.
Instance Method Details
#on_deleting_from(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP DELETE, performing any code in the block beforehand. This is to allow you to set up expectations on your mocks whilst keeping the code readable.
As with on_getting, use :as_xhr => true to make this an XMLHTTPRequest
53 54 55 56 57 58 59 60 61 |
# File 'lib/controller_example_group.rb', line 53 def on_deleting_from page, parameters = {} yield if block_given? is_xhr_request = parameters.delete(:as_xhr) if is_xhr_request xhr :delete, page, parameters else delete page, parameters end end |
#on_getting(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP GET, performing any code in the block beforehand. This is to allow you to set up expectations on your mocks whilst keeping the code readable.
For example:
on_getting :show, :id => '25' do
@person = mock_model Person
Person.should_receive(:find).with('25').and_return(@person)
end
If you want an XMLHTTPRequest pass in :as_xhr => true in the parameters (don’t worry - it won’t be passed to your controller) For example:
on_getting :show, :id => '25', :as_xhr => true do
whatever
end
17 18 19 20 21 22 23 24 25 |
# File 'lib/controller_example_group.rb', line 17 def on_getting page, parameters = {} yield if block_given? is_xhr_request = parameters.delete(:as_xhr) if is_xhr_request xhr :get, page, parameters else get page, parameters end end |
#on_posting_to(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP POST, performing any code in the block beforehand. This is to allow you to set up expectations on your mocks whilst keeping the code readable.
As with on_getting, use :as_xhr => true to make this an XMLHTTPRequest
29 30 31 32 33 34 35 36 37 |
# File 'lib/controller_example_group.rb', line 29 def on_posting_to page, parameters = {} yield if block_given? is_xhr_request = parameters.delete(:as_xhr) if is_xhr_request xhr :post, page, parameters else post page, parameters end end |
#on_putting_to(page, parameters = {}) ⇒ Object
Perform a pseudo HTTP PUT, performing any code in the block beforehand. This is to allow you to set up expectations on your mocks whilst keeping the code readable.
As with on_getting, use :as_xhr => true to make this an XMLHTTPRequest
41 42 43 44 45 46 47 48 49 |
# File 'lib/controller_example_group.rb', line 41 def on_putting_to page, parameters = {} yield if block_given? is_xhr_request = parameters.delete(:as_xhr) if is_xhr_request xhr :put, page, parameters else put page, parameters end end |