qlive 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,32 +1,16 @@
1
1
  # Qlive
2
2
 
3
- Qlive is rack middleware for running qunit javascript tests against a live server.
4
- It is mainly intended to be used for testing javascript-heavy, single-page web applications
5
- (like those built using backbone, angularjs, emberjs, etc.)
3
+ This core Qlive gem is rack middleware that:
6
4
 
7
- Qlive inserts the qunit framework and your test sources into the page's response.
8
- Qlive provides hooks for setting server state before the request is processed by your app, so you can
9
- do things like popuplate content with your favorite fixtures library (like factory_girl) and log in a user for the qunit test page.
5
+ * provides hooks for setting server state before the request is processed by your app
6
+ * inserts the qunit framework and your test sources and helpers into the page's response.
10
7
 
11
8
 
12
- ## Benefits:
9
+ If you are using Ruby on Rails, you should not use this gem directly. Instead, use
10
+ [qlive-rails](https://github.com/proxv/qlive-rails) or [qlive-rspec](https://github.com/proxv/qlive-rspec).
13
11
 
14
- * Precisely set fixture content and user login state for your qunit tests
15
- * Insert qunit tests and any custom html into live pages generated by your server
16
- * Run the same qunit tests in a browser or headlessly, alongside your normal integration test suite. (When used with Ruby on Rails and the [qlive-rspec](https://github.com/proxv/qlive-rspec) gem.)
17
12
 
18
-
19
- ## Installation
20
-
21
- ### Ruby on Rails
22
-
23
- If you are using Ruby on Rails, you should use one of these gems:
24
-
25
- * [qlive-rails](https://github.com/proxv/qlive-rails). Configures most of qlive for you and provides an index page linking to your test suites.
26
- * [qlive-rspec](https://github.com/proxv/qlive-rspec). Run your qunit tests headlessly as an rspec example. (Builds on qlive-rails.)
27
-
28
-
29
- ### Non-rails:
13
+ ## Configuration
30
14
 
31
15
  * Configure base path, the top of the directory tree that contains your qlive suites. (See suites section below)
32
16
  <pre>Qlive.setup[:base_path] = /absolute/path/to/qunit/tests/tree</pre>
@@ -4,17 +4,7 @@ require 'qlive/suite'
4
4
  module Qlive
5
5
  module Registry
6
6
 
7
- unless String.public_method_defined?(:underscore)
8
- String.class_eval do
9
- def underscore
10
- self.gsub(/(.)([A-Z])/,'\1_\2').downcase
11
- end
12
- end
13
- end
14
-
15
-
16
7
  $qlive_all_suites ||= {}
17
- #@all_suites ||= {} # use module instance variable
18
8
 
19
9
  def self.suites
20
10
  $qlive_all_suites
@@ -56,16 +46,17 @@ module Qlive
56
46
  meta
57
47
  end
58
48
 
49
+ private
59
50
 
60
51
  def self.extract_suite_name_from_path(path)
61
- res = path.split('/')[-1]
62
- res = res.split('.')[0]
63
- res = res.downcase.sub(/_qlive$/, '')
64
- res
52
+ res = path.sub(Qlive.setup[:base_path], '').sub(/^\//, '')
53
+ res.split('/')[0..-2].join('/')
65
54
  end
66
55
 
67
56
  def self.extract_suite_name_from_class(klass)
68
- klass.name.underscore.sub(/_qlive$/, '')
57
+ parts = klass.name.split('::')
58
+ parts = parts.map { |part| part.gsub(/(.)([A-Z])/,'\1_\2').downcase }
59
+ parts.join('/').sub(/_qlive$/, '')
69
60
  end
70
61
 
71
62
  end
@@ -1,3 +1,3 @@
1
1
  module Qlive
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,5 +1,3 @@
1
- $(document).ready(function() {
2
- nextTick(function() {
3
- QUnit.start();
4
- });
5
- });
1
+ $(window).load(function() {
2
+ setTimeout(QUnit.start, 1); // start after qunit is ready
3
+ });
@@ -0,0 +1,10 @@
1
+ module Regressions
2
+ class StayUnbrokenQlive
3
+ include Qlive::Suite
4
+
5
+ def before_each_request(rack_request)
6
+ # fixtures that reproduce the original bug
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ $(document).ready(function() {
2
+ module("test-never-again.js");
3
+
4
+ test("regression tests", 26, window.ns.moreQunitTests);
5
+ });
@@ -39,7 +39,7 @@ describe Qlive::Rack do
39
39
  def html_page
40
40
  <<-END.gsub(/^\s+/, '')
41
41
  <html><head>
42
- <title>Why Jasmine Is Annoying</title>
42
+ <title>Why Fixturing Is Annoying</title>
43
43
  <script src='/app-ui.js'></script>
44
44
  </head>
45
45
  <body class="webapp">
@@ -6,13 +6,25 @@ describe Qlive::Registry, "find_suites" do
6
6
  suites.length.should > 0
7
7
  suites['fancy_workflow'].should_not be_nil
8
8
  end
9
+
10
+ it "should support subdirectories namespaced by modules" do
11
+ suites = Qlive::Registry.find_suites
12
+ suites.length.should == 2
13
+ suites['regressions/stay_unbroken'].should_not be_nil
14
+ end
9
15
  end
10
16
 
17
+
11
18
  describe Qlive::Registry, "build_suite" do
12
19
 
13
20
  it "should instantiate suite and add class to meta data registry" do
14
21
  suite = Qlive::Registry.build_suite('fancy_workflow')
15
22
  suite.class.name.should == 'FancyWorkflowQlive'
23
+ end
16
24
 
25
+ it "should work with namespaced subdirs " do
26
+ suite = Qlive::Registry.build_suite('regressions/stay_unbroken')
27
+ suite.class.name.should == 'Regressions::StayUnbrokenQlive'
17
28
  end
29
+
18
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qlive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-29 00:00:00.000000000 Z
12
+ date: 2012-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &2152014860 !ruby/object:Gem::Requirement
16
+ requirement: &2152316140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152014860
24
+ version_requirements: *2152316140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2152118760 !ruby/object:Gem::Requirement
27
+ requirement: &2152315360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152118760
35
+ version_requirements: *2152315360
36
36
  description: run qunit tests against actual back-end server with prepared test fixtures
37
37
  email:
38
38
  - support@proxv.com
@@ -40,12 +40,10 @@ executables: []
40
40
  extensions: []
41
41
  extra_rdoc_files: []
42
42
  files:
43
- - .gitignore
44
43
  - Gemfile
45
44
  - README.md
46
45
  - Rakefile
47
46
  - lib/qlive.rb
48
- - lib/qlive/.DS_Store
49
47
  - lib/qlive/dev_reload.rb
50
48
  - lib/qlive/qunit_assets.rb
51
49
  - lib/qlive/rack.rb
@@ -54,11 +52,12 @@ files:
54
52
  - lib/qlive/suite.rb
55
53
  - lib/qlive/version.rb
56
54
  - qlive.gemspec
57
- - spec/.DS_Store
55
+ - spec/fixtures/fancy_workflow/fancy_workflow_qlive.rb
56
+ - spec/fixtures/fancy_workflow/post-new-recipe.js
57
+ - spec/fixtures/fancy_workflow/verify-creds.js
58
58
  - spec/fixtures/qunit_support/start-qunit.js
59
- - spec/fixtures/suites/fancy_workflow/fancy_workflow_qlive.rb
60
- - spec/fixtures/suites/fancy_workflow/post-new-recipe.js
61
- - spec/fixtures/suites/fancy_workflow/verify-creds.js
59
+ - spec/fixtures/regressions/stay_unbroken/stay_unbroken_qlive.rb
60
+ - spec/fixtures/regressions/stay_unbroken/test-never-again.js
62
61
  - spec/qlive/rack_spec.rb
63
62
  - spec/qlive/registry_spec.rb
64
63
  - spec/qlive/suite_spec.rb
@@ -89,10 +88,12 @@ signing_key:
89
88
  specification_version: 3
90
89
  summary: run qunit tests against actual back-end server with prepared test fixtures
91
90
  test_files:
91
+ - spec/fixtures/fancy_workflow/fancy_workflow_qlive.rb
92
+ - spec/fixtures/fancy_workflow/post-new-recipe.js
93
+ - spec/fixtures/fancy_workflow/verify-creds.js
92
94
  - spec/fixtures/qunit_support/start-qunit.js
93
- - spec/fixtures/suites/fancy_workflow/fancy_workflow_qlive.rb
94
- - spec/fixtures/suites/fancy_workflow/post-new-recipe.js
95
- - spec/fixtures/suites/fancy_workflow/verify-creds.js
95
+ - spec/fixtures/regressions/stay_unbroken/stay_unbroken_qlive.rb
96
+ - spec/fixtures/regressions/stay_unbroken/test-never-again.js
96
97
  - spec/qlive/rack_spec.rb
97
98
  - spec/qlive/registry_spec.rb
98
99
  - spec/qlive/suite_spec.rb
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
Binary file
Binary file