siesta 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Siesta
2
2
 
3
+ [![Build
4
+ Status](https://secure.travis-ci.org/towerhe/siesta.png)](http://travis-ci.org/towerhe/siesta)
5
+ [![Dependency
6
+ Status](https://gemnasium.com/towerhe/siesta.png)](https://gemnasium.com/towerhe/siesta)
7
+ [![Code
8
+ Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/towerhe/siesta)
9
+
3
10
  A rails mountable engine setting up
4
11
  [siesta](http://www.bryntum.com/products/siesta/) for testing ExtJS.
5
12
 
@@ -15,7 +22,7 @@ And then run `bundle install` to install siesta. That's all.
15
22
 
16
23
  ### Usage
17
24
 
18
- 1. Mount the engine in your rails application.
25
+ * Mount the engine in your rails application.
19
26
 
20
27
  ```ruby
21
28
  # config/routes
@@ -24,7 +31,39 @@ if Rails.env.development?
24
31
  end
25
32
  ```
26
33
 
27
- 2. Create tests under `spec/javascripts` or `test/javascripts`.
34
+ * (OPTIONAL) Configure siesta.
35
+ * spec_dir - Default directory of specs is `spec/javascripts`, so you should create you specs under `spec/javascripts` by default. But you could change the default value through an initializer.
36
+
37
+ ```ruby
38
+ # config/initializers/siesta.rb
39
+ Siesta.configure do |config|
40
+ config.spec_dir = 'test/javascripts'
41
+ end
42
+ ```
43
+
44
+ * auto_organizing - Organizing the tests by folders, default is true.
45
+
46
+ ```ruby
47
+ # config/initializers/siesta.rb
48
+ Siesta.configure do |config|
49
+ config.auto_organizing = false
50
+ end
51
+ ```
52
+ If you do not enable auto_organizing function, you need to create a
53
+ `test_harness.js` under `spec_dir` to organize your tests.
54
+
55
+ ```javascript
56
+ var Harness = Siesta.Harness.Browser.ExtJS;
57
+
58
+ Harness.start({
59
+ group : 'Sample',
60
+ items : [
61
+ '/assets/sample.t.js'
62
+ ]
63
+ });
64
+ ```
65
+
66
+ * Create your specs under the directory of specs.
28
67
 
29
68
  ```javascript
30
69
  // spec/javascripts/sample.t.js
@@ -33,7 +72,7 @@ StartTest(function(t) {
33
72
  })
34
73
  ```
35
74
 
36
- 3. Create `spec/javascripts/test_harness.js` to start.
75
+ * Create `spec/javascripts/test_harness.js` to start.
37
76
 
38
77
  ```javascript
39
78
  // spec/javascript/test_harness.js
@@ -45,13 +84,28 @@ Harness.start({
45
84
  });
46
85
  ```
47
86
 
48
- 4. Start up the application, and then run your tests through
87
+ * Start up the application, and then run your tests through
49
88
  [http://localhost:3000/siesta](http://localhost:3000/siesta).
50
89
 
51
90
  ```bash
52
91
  rails s
53
92
  ```
54
93
 
94
+ * (OPTIONAL) Customize the behavior of siesta. See the [Siesta.Harness.Browser.ExtJS](http://www.bryntum.com/products/siesta/docs/#!/api/Siesta.Harness.Browser.ExtJS) for a detailed description of all available options.
95
+
96
+ ```javascript
97
+ // spec/javascripts/siesta_config.js
98
+ Siesta.Harness.Browser.ExtJS.configure({
99
+ title: 'Dummy App',
100
+ loaderPath: { 'DummyApp' : '/assets/extjs/app' },
101
+
102
+ preload : [
103
+ "/assets/extjs/resources/css/ext-all.css",
104
+ "/assets/extjs/ext-all-debug.js"
105
+ ]
106
+ });
107
+ ```
108
+
55
109
  For more detail about how to test your ExtJS, please visit:
56
110
  [http://www.bryntum.com/products/siesta/docs/](http://www.bryntum.com/products/siesta/docs/)
57
111
 
@@ -0,0 +1,38 @@
1
+ module Siesta
2
+ module ApplicationHelper
3
+ def include_siesta_config
4
+ if asset_exists?('siesta_config.js')
5
+ javascript_include_tag 'siesta_config'
6
+ else
7
+ javascript_include_tag 'siesta/siesta_config'
8
+ end
9
+ end
10
+
11
+ def include_test_harness
12
+ if Siesta.config.auto_organizing
13
+ content_tag(:script, test_harness, { type: 'text/javascript' }, false)
14
+ else
15
+ javascript_include_tag 'test_harness'
16
+ end
17
+ end
18
+
19
+ private
20
+ def asset_exists?(asset)
21
+ Rails.application.assets.find_asset(asset)
22
+ end
23
+
24
+ def test_harness
25
+ @suite ||= TestSuite.new(File.join(Rails.root, Siesta.config.spec_dir))
26
+
27
+ groups = @suite.groups.inject([]) do |c, g|
28
+ c << { group: g.name, items: g.items.map(&:url) }
29
+ end
30
+
31
+ <<-SCRIPTS
32
+ var Harness = Siesta.Harness.Browser.ExtJS;
33
+
34
+ Harness.start(#{groups.to_json.gsub(/^\[|\]$/, '')});
35
+ SCRIPTS
36
+ end
37
+ end
38
+ end
@@ -9,8 +9,8 @@
9
9
 
10
10
  <%= javascript_include_tag 'siesta/siesta-all' %>
11
11
 
12
- <%= javascript_include_tag 'siesta/siesta' %>
13
- <%= javascript_include_tag 'test_harness' %>
12
+ <%= include_siesta_config %>
13
+ <%= include_test_harness %>
14
14
  </head>
15
15
 
16
16
  <body>
@@ -1,4 +1,22 @@
1
- require "siesta/engine"
1
+ require 'rails'
2
+ require 'virtus'
3
+
4
+ require 'siesta/engine'
5
+ require 'siesta/test_suite'
2
6
 
3
7
  module Siesta
8
+ class << self
9
+ def config
10
+ @config ||= ActiveSupport::OrderedOptions.new
11
+ end
12
+
13
+ def configure
14
+ yield config
15
+ end
16
+ end
17
+ end
18
+
19
+ Siesta.configure do |config|
20
+ config.spec_dir = 'spec/javascripts'
21
+ config.auto_organizing = true
4
22
  end
@@ -7,8 +7,7 @@ module Siesta
7
7
  raise RuntimeError, "siesta requires the asset pipeline to be enabled"
8
8
  end
9
9
 
10
- app.config.assets.paths << app.root.join('spec/javascripts').to_s
11
- app.config.assets.paths << app.root.join('test/javascripts').to_s
10
+ app.config.assets.paths << app.root.join(Siesta.config.spec_dir).to_s
12
11
  end
13
12
  end
14
13
  end
@@ -0,0 +1,52 @@
1
+ module Siesta
2
+ class TestSuite
3
+ class Group
4
+ include ::Virtus
5
+
6
+ attribute :path, String
7
+ attribute :suite, TestSuite
8
+
9
+ def name
10
+ @name ||= path.gsub(suite.path, '')
11
+
12
+ @name.blank? ? 'global' : @name
13
+ end
14
+
15
+ def items
16
+ @items ||= Dir.glob(File.join(path, '*.t.js')).inject([]) do |c, f|
17
+ c << Item.new(path: f, group: self, suite: suite) unless File.directory?(f)
18
+
19
+ c
20
+ end
21
+ end
22
+ end
23
+
24
+ class Item
25
+ include ::Virtus
26
+
27
+ attribute :path, String
28
+ attribute :group, Group
29
+ attribute :suite, TestSuite
30
+
31
+ def url
32
+ @url ||= File.join('/assets', path.gsub(suite.path, ''))
33
+ end
34
+ end
35
+
36
+ attr_reader :path
37
+
38
+ def initialize(path)
39
+ @path = path
40
+ end
41
+
42
+ def groups
43
+ @groups ||= Dir.glob(File.join(path, '**', '*')).inject([]) do |c, f|
44
+ c << Group.new(path: f, suite: self) if File.directory?(f)
45
+
46
+ c
47
+ end
48
+
49
+ @groups << Group.new(path: path, suite: self)
50
+ end
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Siesta
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siesta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-14 00:00:00.000000000 Z
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.6
30
+ - !ruby/object:Gem::Dependency
31
+ name: virtus
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.5.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.1
30
46
  description: A rails mountable engine setting up siesta for testing ExtJS
31
47
  email:
32
48
  - towerhe@gmail.com
@@ -36,10 +52,12 @@ extra_rdoc_files: []
36
52
  files:
37
53
  - app/controllers/siesta/siesta_controller.rb
38
54
  - app/controllers/siesta/application_controller.rb
39
- - app/assets/javascripts/siesta/siesta.js
55
+ - app/helpers/siesta/application_helper.rb
56
+ - app/assets/javascripts/siesta/siesta_config.js
40
57
  - app/views/siesta/siesta/index.html.erb
41
58
  - config/routes.rb
42
59
  - lib/siesta.rb
60
+ - lib/siesta/test_suite.rb
43
61
  - lib/siesta/engine.rb
44
62
  - lib/siesta/version.rb
45
63
  - vendor/assets/stylesheets/extjs/resources/css/ext-all-gray.css
@@ -1395,7 +1413,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1395
1413
  version: '0'
1396
1414
  segments:
1397
1415
  - 0
1398
- hash: -1860199928134172160
1416
+ hash: 1098804971030861051
1399
1417
  required_rubygems_version: !ruby/object:Gem::Requirement
1400
1418
  none: false
1401
1419
  requirements:
@@ -1404,7 +1422,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1404
1422
  version: '0'
1405
1423
  segments:
1406
1424
  - 0
1407
- hash: -1860199928134172160
1425
+ hash: 1098804971030861051
1408
1426
  requirements: []
1409
1427
  rubyforge_project:
1410
1428
  rubygems_version: 1.8.24