weinre-rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # Weinre::Rails
2
2
 
3
- TODO: Write a gem description
3
+ Some helpers for integrating the awesome Weinre app with a Rails 3.1+ set up. It wouldn't take took much to use it with Rails < 3.1 as long as you're ok with getting the asset pipeline bolted in. It's assumed that if you're using this for testing with Cucumber that you'll be using something like Capybara so that you have a Javascript engine.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'weinre-rails'
9
+ group :cucumber, :development, :test do
10
+ gem 'weinre-rails'
11
+ end
10
12
 
11
13
  And then execute:
12
14
 
@@ -18,7 +20,37 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ This is a very simple wrapper done as a Rails Engine which gives us Asset Pipeline goodness. To use it just put a
24
+
25
+ //= require weinre-rails
26
+
27
+ Into your `application.js` and you'll be off to the races. Whenever you want to connect to a Weinre server just execute:
28
+
29
+ $.connectWeinre()
30
+
31
+ from your javascript and you're good to go.
32
+
33
+ There's a handy cucumber step that lets you pause a scenario and inspect the current state of the test in Weinre. To do this include `weinre-rails/cucumber` in `env.rb` like so:
34
+
35
+ require 'weinre/rails/cucumber'
36
+
37
+ And in your scenario do something like:
38
+
39
+ Scenario: I'm testing something complicated
40
+ Given I am doing something complicated with javascript
41
+ When some weird condition occurs
42
+ Then I start remote debugging
43
+ Execution paused by weinre-rails, press enter when ready
44
+
45
+ The app will pause until you hit *enter* in the console at which point it will keep going.
46
+
47
+ By default the cucumber test will try to connect to:
48
+
49
+ http://localhost:8080/target/target-script-min.js#anonymous
50
+
51
+ If you want to change that you can:
52
+
53
+ Weinre::Rails.url = "http://localhost:9090/target/target-script-min.js#anonymous"
22
54
 
23
55
  ## Contributing
24
56
 
@@ -3,10 +3,17 @@
3
3
  if(options == undefined) {
4
4
  options = {};
5
5
  }
6
- var host = options.host || "127.0.0.1";
7
- var port = options.port || "8080";
8
- var id = options.id || "anonymous";
9
- var url = "http://" + host + ":" + port + "/target/target-script-min.js#" + id;
6
+
7
+ if(options.url === undefined) {
8
+ var host = options.host || "127.0.0.1";
9
+ var port = options.port || "8080";
10
+ var id = options.id || "anonymous";
11
+ var path = options.path || "/target/target-script-min.js#";
12
+
13
+ var url = "http://" + host + ":" + port + path + id;
14
+ } else {
15
+ var url = options.url;
16
+ }
10
17
 
11
18
  var script = document.createElement( 'script' );
12
19
  script.type = 'text/javascript';
@@ -1,9 +1,14 @@
1
- require "weinre-rails/version"
2
-
3
1
  module Weinre
4
- module Rails
2
+ module Rails
3
+ include ActiveSupport::Configurable
4
+
5
+ config_accessor :url
6
+ self.url = "http://localhost:8080/target/target-script-min.js#anonymous"
7
+
8
+ autoload :Engine, "weinre/rails/engine"
5
9
 
10
+ autoload :VERSION, "weinre/rails/version"
6
11
  end
7
12
  end
8
13
 
9
- require "weinre-rails/engine" if defined?(Rails)
14
+ require "weinre/rails/engine" if defined?(Rails)
@@ -0,0 +1,8 @@
1
+ Then /^I start remote debugging$/ do
2
+ script = %Q{jQuery("body").append("<script src='#{Weinre::Rails.url}'></script>")}
3
+ page.execute_script(script)
4
+
5
+ STDOUT.write(" Execution paused by weinre-rails, press enter when ready")
6
+ STDOUT.flush
7
+ STDIN.gets
8
+ end
@@ -0,0 +1,7 @@
1
+ module Weinre
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  module Weinre
2
2
  module Rails
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/weinre-rails/version', __FILE__)
2
+ require File.expand_path('../lib/weinre/rails/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Andrew Eberbach"]
metadata CHANGED
@@ -1,33 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: weinre-rails
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Andrew Eberbach
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-10 00:00:00 Z
12
+ date: 2012-07-08 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: A Rails 3 helper for Weinre
22
- email:
15
+ email:
23
16
  - andrew@ebertech.ca
24
17
  executables: []
25
-
26
18
  extensions: []
27
-
28
19
  extra_rdoc_files: []
29
-
30
- files:
20
+ files:
31
21
  - .gitignore
32
22
  - Gemfile
33
23
  - LICENSE
@@ -35,43 +25,32 @@ files:
35
25
  - Rakefile
36
26
  - lib/assets/javascripts/weinre-rails.js
37
27
  - lib/weinre-rails.rb
38
- - lib/weinre-rails/cucumber.rb
39
- - lib/weinre-rails/engine.rb
40
- - lib/weinre-rails/version.rb
28
+ - lib/weinre/rails/cucumber.rb
29
+ - lib/weinre/rails/engine.rb
30
+ - lib/weinre/rails/version.rb
41
31
  - weinre-rails.gemspec
42
32
  homepage:
43
33
  licenses: []
44
-
45
34
  post_install_message:
46
35
  rdoc_options: []
47
-
48
- require_paths:
36
+ require_paths:
49
37
  - lib
50
- required_ruby_version: !ruby/object:Gem::Requirement
38
+ required_ruby_version: !ruby/object:Gem::Requirement
51
39
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 3
56
- segments:
57
- - 0
58
- version: "0"
59
- required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
45
  none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
68
50
  requirements: []
69
-
70
51
  rubyforge_project:
71
- rubygems_version: 1.8.21
52
+ rubygems_version: 1.8.24
72
53
  signing_key:
73
54
  specification_version: 3
74
55
  summary: Provides asset-pipeline javascript for connecting to weinre
75
56
  test_files: []
76
-
77
- has_rdoc:
@@ -1,7 +0,0 @@
1
- Then /^I start remote debugging$/ do
2
- url = "http://localhost:8080/target/target-script-min.js#anonymous"
3
- script = %Q{jQuery("body").append("<script src='#{url}'></script>")}
4
- page.execute_script(script)
5
- puts "Executing paused, press enter when ready"
6
- $stdin.gets
7
- end
@@ -1,6 +0,0 @@
1
- module Weinre
2
- module Rails
3
- class Engine < Rails::Engine
4
- end
5
- end
6
- end