Skip to content

Commit

Permalink
Setting test categories in spec action instead of config yaml, prepar…
Browse files Browse the repository at this point in the history
…ing for fake data spec
  • Loading branch information
winton committed Aug 23, 2010
1 parent 99a917b commit fc78c54
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 17 deletions.
16 changes: 1 addition & 15 deletions config/a_b.yml
@@ -1,16 +1,2 @@
token: UAkc328OcjMVFbPAE5bo
url: http://localhost:9394
# For specs
site: test
categories:
- name: Category
tests:
- id: 1
name: Test
variants:
- id: 2
name: v1
- id: 3
name: v2
- id: 4
name: v3
url: http://localhost:9394
24 changes: 24 additions & 0 deletions lib/a_b_front_end/controller/spec.rb
Expand Up @@ -3,8 +3,32 @@
if environment == :development

get '/spec/js' do
site = ABPlugin::Config.site
categories = ABPlugin::Config.categories

ABPlugin::Config.categories [
{
:name => 'Category',
:tests => [
{
:id => 1,
:name => 'Test',
:variants => [
{ :id => 2, :name => 'v1' },
{ :id => 3, :name => 'v2' },
{ :id => 4, :name => 'v3' }
]
}
]
}
]

ABPlugin::API.spec_js_setup

haml :'spec/js', :layout => false

ABPlugin::Config.site site
ABPlugin::Config.categories categories
end
end
end
19 changes: 19 additions & 0 deletions lib/a_b_front_end/view/spec/fake_data.haml
@@ -0,0 +1,19 @@
!!! 1.1
%html
%head
= css 'qunit'
= js 'jquery'
= js 'a_b'
= js 'qunit'
= js 'spec/fake_data'
%script{ :type => 'text/javascript' }
:erb
reset_a_b();
function reset_a_b() {
<%= a_b %>
}
%body
%h1{ :id => "qunit-header" } a_b fake data
%h2{ :id => "qunit-banner" }
%h2{ :id => "qunit-userAgent" }
%ol{ :id => "qunit-tests" }
4 changes: 2 additions & 2 deletions lib/a_b_front_end/view/spec/js.haml
Expand Up @@ -5,15 +5,15 @@
= js 'jquery'
= js 'a_b'
= js 'qunit'
= js 'spec'
= js 'spec/js'
%script{ :type => 'text/javascript' }
:erb
reset_a_b();
function reset_a_b() {
<%= a_b %>
}
%body
%h1{ :id => "qunit-header" } a_b
%h1{ :id => "qunit-header" } a_b.js
%h2{ :id => "qunit-banner" }
%h2{ :id => "qunit-userAgent" }
%ol{ :id => "qunit-tests" }
Empty file added public/js/spec/fake_data.js
Empty file.
File renamed without changes.

0 comments on commit fc78c54

Please sign in to comment.