Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing active_wrapper inclusion in rakefile, fake data spec working

  • Loading branch information...
commit bfffb09dd3248c00fa0d19ca83c586cae08c7051 1 parent 5e0ad99
@winton authored
View
1  Rakefile
@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/lib/a_b_front_end/gems'
ABFrontEnd::Gems.require(:rake)
require 'rake'
+require 'active_wrapper/tasks'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
View
7 lib/a_b_front_end/controller/spec.rb
@@ -3,13 +3,18 @@
if environment == :development
get '/spec/fake_data' do
- if request.cookies['site_name'] && request.cookies['test_name']
+ response.set_cookie('a_b', :value => nil, :path => '/')
+ response.set_cookie('a_b_i', :value => nil, :path => '/')
+
+ if request.cookies['category_name'] && request.cookies['site_name'] && request.cookies['test_name']
categories = ABPlugin::Config.categories
site = ABPlugin.site request.cookies['site_name']
if site != false
+ @category = request.cookies['category_name']
@test = request.cookies['test_name']
ABPlugin::Config.categories site['categories']
end
+ response.set_cookie('category_name', :value => nil, :path => '/')
response.set_cookie('site_name', :value => nil, :path => '/')
response.set_cookie('test_name', :value => nil, :path => '/')
end
View
2  lib/a_b_front_end/gems.rb
@@ -23,7 +23,7 @@ class Gems
:gemspec => [ :active_wrapper, :haml, :lilypad, :'rack-flash', :sinatra ],
:gemspec_dev => [ :cucumber, :rspec, :'rack-test' ],
:lib => [ :active_wrapper, :haml, :lilypad, :'rack-flash', :sinatra ],
- :rake => [ :rake, :rspec ],
+ :rake => [ :active_wrapper, :rake, :rspec ],
:spec => [ :'rack-test', :rspec ]
}
View
4 lib/a_b_front_end/view/dashboard.haml
@@ -69,10 +69,10 @@
}
});
if (!found) { %>
+ %td 0
%td -
%td -
%td -
- %td -
- %td -
+ %td ?
<% } %>
<% }); %>
View
1  lib/a_b_front_end/view/spec/fake_data.haml
@@ -8,6 +8,7 @@
= js 'spec/fake_data'
%script{ :type => 'text/javascript' }
:erb
+ window.category = <%= @category.to_json %>;
window.test = <%= @test.to_json %>;
<% if @test %>
reset_a_b();
View
2  public/js/a_b.js
@@ -371,6 +371,8 @@ window.A_B = new function() {
this.Datastore = Datastore;
this.Test = Test;
+ this.categories = function() { return categories; };
+
// Global methods
window.a_b = function(c, t, e) {
View
41 public/js/spec/fake_data.js
@@ -1,5 +1,3 @@
-window.testing = true;
-
function wait(msg, fn) {
var alert = $('<div id="alert"/>')
.html(msg + ":&nbsp;&nbsp;")
@@ -12,7 +10,14 @@ function wait(msg, fn) {
padding: '8px'
})
.prependTo('body')
- .append('<input type="text" />')
+ .append(
+ $('<input type="text" />')
+ .keyup(function(e) {
+ if (e.keyCode == 13)
+ submit();
+ })
+ .focus()
+ )
.append(
$('<a href="#"/>')
.html('Continue')
@@ -20,27 +25,33 @@ function wait(msg, fn) {
'color': 'yellow',
'margin-left': 10
})
- .click(function() {
- fn($('input', alert).val());
- alert.remove();
- return false;
- })
+ .click(submit)
);
+ function submit() {
+ fn($('input', alert).val());
+ alert.remove();
+ return false;
+ }
}
module('fake data');
test('should create some fake data', function() {
- stop();
- if (window.test) {
- // do tests
+ if (window.category && window.test) {
+ start();
+ expect(2);
+ equals(typeof a_b(window.category, window.test).visit(), 'string');
+ equals(typeof a_b(window.category, window.test).convert(), 'string');
} else {
stop();
wait("Enter site name", function(site_name) {
- wait("Enter test name", function(test_name) {
- A_B.Cookies.set('site_name', site_name);
- A_B.Cookies.set('test_name', test_name);
- window.location.reload();
+ wait("Enter category name", function(category_name) {
+ wait("Enter test name", function(test_name) {
+ A_B.Cookies.set('category_name', category_name);
+ A_B.Cookies.set('site_name', site_name);
+ A_B.Cookies.set('test_name', test_name);
+ window.location.reload();
+ });
});
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.