1
0
Fork 0
mirror of https://github.com/kbparagua/paloma synced 2023-03-27 23:21:17 -04:00

request spec helper

This commit is contained in:
kbparagua 2014-02-15 18:51:02 +08:00
parent abf85476fe
commit 0a5ccaf8db
6 changed files with 47 additions and 12 deletions

View file

@ -44,3 +44,8 @@ Foos.prototype.otherAction = function(){};
var NotFoos = Paloma.controller('NotAdmin/Foos');
NotFoos.prototype.show = function(){};
NotFoos.prototype.otherAction = function(){};
var Baz = Paloma.controller('Baz');
Baz.prototype.index = function(){};

View file

@ -0,0 +1,7 @@
class BarsController < ApplicationController
def index
render :inline => 'Bars#index', :layout => 'application'
end
end

View file

@ -19,4 +19,7 @@ TestApp::Application.routes.draw do
namespace :admin do
resources :foos
end
resources :bars
end

View file

@ -12,7 +12,6 @@ feature 'executing Paloma controller', :js => true do
context 'default behavior' do
it 'executes the same namespace/controller/action' do
visit admin_foos_path
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'Admin/Foos',
@ -25,7 +24,6 @@ feature 'executing Paloma controller', :js => true do
context 'override default controller' do
it 'executes the specified controller' do
visit admin_foo_path(1)
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'NotAdmin/Foos',
@ -38,7 +36,6 @@ feature 'executing Paloma controller', :js => true do
context 'override default action' do
it 'executes the specified action' do
visit new_admin_foo_path
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'Admin/Foos',
@ -51,7 +48,6 @@ feature 'executing Paloma controller', :js => true do
context 'override default controller/action' do
it 'executes the specified controller/action' do
visit edit_admin_foo_path(1)
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'NotAdmin/Foos',
@ -60,4 +56,29 @@ feature 'executing Paloma controller', :js => true do
end
end
#
#
# Controller-wide settings
#
#
context 'global controller' do
before do
BarsController.send :js, 'Baz'
end
it 'executes the specified controller' do
visit bars_path
expect(request).to eq({
'controller' => 'Baz',
'action' => 'index',
'params' => {}})
end
end
end

View file

@ -18,7 +18,6 @@ feature 'executing Paloma controller', :js => true do
context 'default behavior' do
it 'executes the same controller/action' do
visit main_index_path
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'Main',
@ -31,7 +30,6 @@ feature 'executing Paloma controller', :js => true do
context 'override default controller' do
it 'executes the specified controller' do
visit main_path(1)
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'OtherMain',
@ -44,7 +42,6 @@ feature 'executing Paloma controller', :js => true do
context 'override default action' do
it 'executes the specified action' do
visit new_main_path
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'Main',
@ -57,7 +54,6 @@ feature 'executing Paloma controller', :js => true do
context 'override default controller/action' do
it 'executes the specified controller/action' do
visit edit_main_path(1)
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to eq({
'controller' => 'OtherMain',
@ -70,9 +66,8 @@ feature 'executing Paloma controller', :js => true do
context 'parameter passed' do
it 'passes the parameter' do
visit basic_params_main_index_path
params = page.evaluate_script 'Paloma.engine.lastRequest.params'
expect(params).to eq({'x' => 1, 'y' => 2})
expect(request['params']).to eq({'x' => 1, 'y' => 2})
end
end
@ -99,7 +94,6 @@ feature 'executing Paloma controller', :js => true do
include_examples 'no paloma'
it 'prevents execution of Paloma controller' do
request = page.evaluate_script 'Paloma.engine.lastRequest'
expect(request).to be_nil
end
end

View file

@ -30,3 +30,8 @@ RSpec.configure do |config|
# --seed 1234
config.order = "random"
end
def request
page.evaluate_script 'Paloma.engine.lastRequest'
end