drogus-blue-ridge 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/LICENSE +20 -0
  2. data/LICENSE-Screw.Unit +22 -0
  3. data/LICENSE-Smoke +22 -0
  4. data/README.markdown +256 -0
  5. data/Rakefile +65 -0
  6. data/VERSION +1 -0
  7. data/blue_ridge_generators/blue_ridge/USAGE +5 -0
  8. data/blue_ridge_generators/blue_ridge/blue_ridge_generator.rb +19 -0
  9. data/blue_ridge_generators/blue_ridge/templates/application.html +16 -0
  10. data/blue_ridge_generators/blue_ridge/templates/application_spec.js +15 -0
  11. data/blue_ridge_generators/blue_ridge/templates/javascript_spec_helper.rb +44 -0
  12. data/blue_ridge_generators/blue_ridge/templates/screw.css +90 -0
  13. data/blue_ridge_generators/blue_ridge/templates/spec_helper.js +1 -0
  14. data/blue_ridge_generators/javascript_spec/USAGE +5 -0
  15. data/blue_ridge_generators/javascript_spec/javascript_spec_generator.rb +52 -0
  16. data/blue_ridge_generators/javascript_spec/templates/fixture.html.erb +13 -0
  17. data/blue_ridge_generators/javascript_spec/templates/fixture_render_spec.rb.erb +10 -0
  18. data/blue_ridge_generators/javascript_spec/templates/javascript_spec.js.erb +10 -0
  19. data/lib/blue-ridge.js +73 -0
  20. data/lib/consoleReportForRake.js +32 -0
  21. data/lib/env.rhino.js +8841 -0
  22. data/lib/jquery-1.2.6.js +3549 -0
  23. data/lib/jquery-1.3.2.js +4376 -0
  24. data/lib/jquery.fn.js +29 -0
  25. data/lib/jquery.print.js +109 -0
  26. data/lib/js.jar +0 -0
  27. data/lib/screw.behaviors.js +92 -0
  28. data/lib/screw.builder.js +82 -0
  29. data/lib/screw.events.js +45 -0
  30. data/lib/screw.matchers.js +187 -0
  31. data/lib/screw.mocking.js +26 -0
  32. data/lib/shell.js +27 -0
  33. data/lib/smoke.core.js +49 -0
  34. data/lib/smoke.mock.js +171 -0
  35. data/lib/smoke.stub.js +29 -0
  36. data/lib/test_runner.js +58 -0
  37. data/spec/fixtures/rails_project/app/controllers/accounts_controller.rb +85 -0
  38. data/spec/fixtures/rails_project/app/controllers/application_controller.rb +10 -0
  39. data/spec/fixtures/rails_project/app/controllers/home_controller.rb +5 -0
  40. data/spec/fixtures/rails_project/app/helpers/accounts_helper.rb +2 -0
  41. data/spec/fixtures/rails_project/app/helpers/application_helper.rb +13 -0
  42. data/spec/fixtures/rails_project/app/helpers/home_helper.rb +2 -0
  43. data/spec/fixtures/rails_project/app/models/account.rb +3 -0
  44. data/spec/fixtures/rails_project/config/boot.rb +110 -0
  45. data/spec/fixtures/rails_project/config/environment.rb +41 -0
  46. data/spec/fixtures/rails_project/config/environments/cucumber.rb +25 -0
  47. data/spec/fixtures/rails_project/config/environments/development.rb +17 -0
  48. data/spec/fixtures/rails_project/config/environments/production.rb +28 -0
  49. data/spec/fixtures/rails_project/config/environments/test.rb +35 -0
  50. data/spec/fixtures/rails_project/config/initializers/backtrace_silencers.rb +7 -0
  51. data/spec/fixtures/rails_project/config/initializers/inflections.rb +10 -0
  52. data/spec/fixtures/rails_project/config/initializers/mime_types.rb +5 -0
  53. data/spec/fixtures/rails_project/config/initializers/new_rails_defaults.rb +19 -0
  54. data/spec/fixtures/rails_project/config/initializers/session_store.rb +2 -0
  55. data/spec/fixtures/rails_project/config/routes.rb +47 -0
  56. data/spec/fixtures/rails_project/db/migrate/20090719005327_create_sessions.rb +16 -0
  57. data/spec/fixtures/rails_project/db/migrate/20090719031606_create_accounts.rb +13 -0
  58. data/spec/fixtures/rails_project/db/schema.rb +30 -0
  59. data/spec/fixtures/rails_project/spec/spec_helper.rb +52 -0
  60. data/tasks/javascript_testing_tasks.rake +84 -0
  61. data/test/test_blue_ridge_generator.rb +48 -0
  62. data/test/test_generator_helper.rb +29 -0
  63. data/test/test_javascript_spec_generator.rb +57 -0
  64. metadata +148 -0
@@ -0,0 +1,52 @@
1
+ # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
+ # from the project root directory.
3
+ ENV["RAILS_ENV"] ||= 'test'
4
+ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
5
+ require 'spec/autorun'
6
+ require 'spec/rails'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
12
+ Spec::Runner.configure do |config|
13
+ # If you're not using ActiveRecord you should remove these
14
+ # lines, delete config/database.yml and disable :active_record
15
+ # in your config/boot.rb
16
+ config.use_transactional_fixtures = true
17
+ config.use_instantiated_fixtures = false
18
+ config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
19
+
20
+ # == Fixtures
21
+ #
22
+ # You can declare fixtures for each example_group like this:
23
+ # describe "...." do
24
+ # fixtures :table_a, :table_b
25
+ #
26
+ # Alternatively, if you prefer to declare them only once, you can
27
+ # do so right here. Just uncomment the next line and replace the fixture
28
+ # names with your fixtures.
29
+ #
30
+ # config.global_fixtures = :table_a, :table_b
31
+ #
32
+ # If you declare global fixtures, be aware that they will be declared
33
+ # for all of your examples, even those that don't use them.
34
+ #
35
+ # You can also declare which fixtures to use (for example fixtures for test/fixtures):
36
+ #
37
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
38
+ #
39
+ # == Mock Framework
40
+ #
41
+ # RSpec uses it's own mocking framework by default. If you prefer to
42
+ # use mocha, flexmock or RR, uncomment the appropriate line:
43
+ #
44
+ # config.mock_with :mocha
45
+ # config.mock_with :flexmock
46
+ # config.mock_with :rr
47
+ #
48
+ # == Notes
49
+ #
50
+ # For more information take a look at Spec::Runner::Configuration and Spec::Runner
51
+ end
52
+ require File.dirname(__FILE__) + '/blueprints'
@@ -0,0 +1,84 @@
1
+ app_root = ENV['APP_ROOT'] || RAILS_ROOT
2
+ plugin_prefix = ENV["BLUE_RIDGE_PREFIX"] || "#{app_root}/vendor/plugins/blue-ridge"
3
+ rhino_command = "java -Dblue.ridge.prefix=\"#{plugin_prefix}\" -jar #{plugin_prefix}/lib/js.jar -w -debug"
4
+ test_runner_command = "#{rhino_command} #{plugin_prefix}/lib/test_runner.js"
5
+
6
+ def find_base_dir
7
+ target_dirs = %w[test/javascript spec/javascripts examples/javascripts test spec examples]
8
+ base_dir = target_dirs.find {|d| Dir["#{d}/spec_helper.js"].first }
9
+ raise "Could not find JavaScript test/spec directory.\nNone of the following directories existed and contained spec_helper.js: #{target_dirs.join(", ")}.\nMaybe you need to call './script/generate blue_ridge'?" unless base_dir
10
+ base_dir
11
+ end
12
+
13
+ def fixture_file_for_spec(spec)
14
+ fixture_name = File.basename(spec).gsub(/_spec.js/, ".html")
15
+ File.join(File.dirname(spec), "fixtures", fixture_name)
16
+ end
17
+
18
+ # Support Test::Unit & Test/Spec style
19
+ namespace :test do
20
+ desc "Runs all the JavaScript tests and outputs the results"
21
+ task :javascripts do
22
+ require "fileutils"
23
+ require "erb"
24
+ Dir.chdir(find_base_dir) do
25
+ all_fine = true
26
+ if ENV["TEST"]
27
+ all_fine = false unless system("#{test_runner_command} #{ENV["TEST"]}_spec.js")
28
+ else
29
+ Dir.glob("**/*_spec.js").each do |file|
30
+ fixture_file = fixture_file_for_spec(file)
31
+ unless File.exists?(fixture_file)
32
+ FileUtils.mkdir_p(File.dirname(fixture_file))
33
+ File.open(fixture_file, "w") do |f|
34
+ template = "#{plugin_prefix}/generators/javascript_spec/templates/fixture.html.erb"
35
+ class_name_without_spec = file.gsub(/_spec.js/,'').classify
36
+ f << ERB.new(File.read(template), nil, '-').result(binding)
37
+ end
38
+ end
39
+ all_fine = false unless system("#{test_runner_command} #{file}")
40
+ end
41
+ end
42
+ raise "JavaScript test failures" unless all_fine
43
+ end
44
+ end
45
+
46
+ task :javascript => :javascripts
47
+ task :js => :javascripts
48
+ end
49
+
50
+ # Support RSpec style
51
+ namespace :spec do
52
+ task :javascripts => ["test:javascripts"]
53
+ task :javascript => ["test:javascripts"]
54
+ task :js => ["test:javascripts"]
55
+ end
56
+
57
+ # Support Micronaut style
58
+ namespace :examples do
59
+ task :javascripts => ["test:javascripts"]
60
+ task :javascript => ["test:javascripts"]
61
+ task :js => ["test:javascripts"]
62
+ end
63
+
64
+
65
+ namespace :js do
66
+ desc "Open fixtures directory"
67
+ task :fixtures do
68
+ fixture_dir = "#{find_base_dir}/fixtures"
69
+
70
+ if PLATFORM[/darwin/]
71
+ system("open #{fixture_dir}")
72
+ elsif PLATFORM[/linux/]
73
+ system("firefox #{fixture_dir}")
74
+ else
75
+ puts "You can run your in-browser fixtures from #{fixture_dir}."
76
+ end
77
+ end
78
+
79
+ desc "Run Rhino JS shell"
80
+ task :shell do
81
+ rlwrap = `which rlwrap`.chomp
82
+ system("#{rlwrap} #{rhino_command} -f #{plugin_prefix}/lib/shell.js -f -")
83
+ end
84
+ end
@@ -0,0 +1,48 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+
4
+ class TestBlueRidgeGenerator < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ bare_setup
9
+ end
10
+
11
+ def teardown
12
+ bare_teardown
13
+ end
14
+
15
+ # Some generator-related assertions:
16
+ # assert_generated_file(name, &block) # block passed the file contents
17
+ # assert_directory_exists(name)
18
+ # assert_generated_class(name, &block)
19
+ # assert_generated_module(name, &block)
20
+ # assert_generated_test_for(name, &block)
21
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
22
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
23
+ #
24
+ # Other helper methods are:
25
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
26
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
27
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
28
+
29
+ def test_generator_without_options
30
+ run_generator('blue_ridge', [], sources)
31
+ assert_directory_exists "spec/javascripts/"
32
+ assert_directory_exists "spec/javascripts/fixtures"
33
+ assert_generated_file "spec/javascripts/application_spec.js"
34
+ assert_generated_file "spec/javascripts/fixtures/application.html"
35
+ assert_generated_file "spec/javascripts/fixtures/screw.css"
36
+ assert_generated_file "spec/javascripts/spec_helper.js"
37
+ end
38
+
39
+ private
40
+ def sources
41
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
42
+ ]
43
+ end
44
+
45
+ def generator_path
46
+ "blue_ridge_generators"
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+ rescue LoadError
4
+ require 'test/unit'
5
+ end
6
+ require 'fileutils'
7
+
8
+ # Must set before requiring generator libs.
9
+ TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
10
+ PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
11
+ app_root = File.join(TMP_ROOT, PROJECT_NAME)
12
+ if defined?(APP_ROOT)
13
+ APP_ROOT.replace(app_root)
14
+ else
15
+ APP_ROOT = app_root
16
+ end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
22
+
23
+ begin
24
+ require 'rubigen'
25
+ rescue LoadError
26
+ require 'rubygems'
27
+ require 'rubigen'
28
+ end
29
+ require 'rubigen/helpers/generator_test_helper'
@@ -0,0 +1,57 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+
4
+ class TestJavascriptSpecGenerator < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ bare_setup
9
+ end
10
+
11
+ def teardown
12
+ bare_teardown
13
+ end
14
+
15
+ # Some generator-related assertions:
16
+ # assert_generated_file(name, &block) # block passed the file contents
17
+ # assert_directory_exists(name)
18
+ # assert_generated_class(name, &block)
19
+ # assert_generated_module(name, &block)
20
+ # assert_generated_test_for(name, &block)
21
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
22
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
23
+ #
24
+ # Other helper methods are:
25
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
26
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
27
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
28
+
29
+ def test_generator_without_options
30
+ name = "gallery"
31
+ run_generator('javascript_spec', [name], sources)
32
+ assert_directory_exists "spec/javascripts/"
33
+ assert_generated_file "spec/javascripts/gallery_spec.js"
34
+ assert_directory_exists "spec/javascripts/fixtures/"
35
+ assert_generated_file "spec/javascripts/fixtures/gallery.html"
36
+ end
37
+
38
+ def test_generator_with_actions
39
+ name = "gallery"
40
+ run_generator('javascript_spec', [name, "action1", "action2"], sources)
41
+ assert_directory_exists "spec/javascripts/"
42
+ assert_generated_file "spec/javascripts/gallery_spec.js"
43
+ assert_generated_file "spec/javascripts/gallery_spec.rb"
44
+ assert_directory_exists "spec/javascripts/fixtures/"
45
+ end
46
+
47
+
48
+ private
49
+ def sources
50
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
51
+ ]
52
+ end
53
+
54
+ def generator_path
55
+ "blue_ridge_generators"
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drogus-blue-ridge
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Sarnacki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-03 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubigen
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.9
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: JavaScript BDD Gem (using Screw.Unit and env.js)
46
+ email: drogus@gmail.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - LICENSE-Screw.Unit
54
+ - LICENSE-Smoke
55
+ - README.markdown
56
+ files:
57
+ - README.markdown
58
+ - Rakefile
59
+ - VERSION
60
+ - blue_ridge_generators/blue_ridge/USAGE
61
+ - blue_ridge_generators/blue_ridge/blue_ridge_generator.rb
62
+ - blue_ridge_generators/blue_ridge/templates/application.html
63
+ - blue_ridge_generators/blue_ridge/templates/application_spec.js
64
+ - blue_ridge_generators/blue_ridge/templates/javascript_spec_helper.rb
65
+ - blue_ridge_generators/blue_ridge/templates/screw.css
66
+ - blue_ridge_generators/blue_ridge/templates/spec_helper.js
67
+ - blue_ridge_generators/javascript_spec/USAGE
68
+ - blue_ridge_generators/javascript_spec/javascript_spec_generator.rb
69
+ - blue_ridge_generators/javascript_spec/templates/fixture.html.erb
70
+ - blue_ridge_generators/javascript_spec/templates/fixture_render_spec.rb.erb
71
+ - blue_ridge_generators/javascript_spec/templates/javascript_spec.js.erb
72
+ - lib/blue-ridge.js
73
+ - lib/consoleReportForRake.js
74
+ - lib/env.rhino.js
75
+ - lib/jquery-1.2.6.js
76
+ - lib/jquery-1.3.2.js
77
+ - lib/jquery.fn.js
78
+ - lib/jquery.print.js
79
+ - lib/js.jar
80
+ - lib/screw.behaviors.js
81
+ - lib/screw.builder.js
82
+ - lib/screw.events.js
83
+ - lib/screw.matchers.js
84
+ - lib/screw.mocking.js
85
+ - lib/shell.js
86
+ - lib/smoke.core.js
87
+ - lib/smoke.mock.js
88
+ - lib/smoke.stub.js
89
+ - lib/test_runner.js
90
+ - tasks/javascript_testing_tasks.rake
91
+ - LICENSE
92
+ - LICENSE-Screw.Unit
93
+ - LICENSE-Smoke
94
+ has_rdoc: true
95
+ homepage: http://github.com/drogus/blue-ridge
96
+ licenses: []
97
+
98
+ post_install_message:
99
+ rdoc_options:
100
+ - --charset=UTF-8
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: "0"
108
+ version:
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ requirements: []
116
+
117
+ rubyforge_project:
118
+ rubygems_version: 1.3.5
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: JavaScript BDD Gem (using Screw.Unit and env.js)
122
+ test_files:
123
+ - spec/fixtures/rails_project/spec/spec_helper.rb
124
+ - spec/fixtures/rails_project/app/controllers/application_controller.rb
125
+ - spec/fixtures/rails_project/app/controllers/accounts_controller.rb
126
+ - spec/fixtures/rails_project/app/controllers/home_controller.rb
127
+ - spec/fixtures/rails_project/app/models/account.rb
128
+ - spec/fixtures/rails_project/app/helpers/accounts_helper.rb
129
+ - spec/fixtures/rails_project/app/helpers/application_helper.rb
130
+ - spec/fixtures/rails_project/app/helpers/home_helper.rb
131
+ - spec/fixtures/rails_project/config/routes.rb
132
+ - spec/fixtures/rails_project/config/boot.rb
133
+ - spec/fixtures/rails_project/config/environments/development.rb
134
+ - spec/fixtures/rails_project/config/environments/production.rb
135
+ - spec/fixtures/rails_project/config/environments/cucumber.rb
136
+ - spec/fixtures/rails_project/config/environments/test.rb
137
+ - spec/fixtures/rails_project/config/environment.rb
138
+ - spec/fixtures/rails_project/config/initializers/new_rails_defaults.rb
139
+ - spec/fixtures/rails_project/config/initializers/session_store.rb
140
+ - spec/fixtures/rails_project/config/initializers/backtrace_silencers.rb
141
+ - spec/fixtures/rails_project/config/initializers/inflections.rb
142
+ - spec/fixtures/rails_project/config/initializers/mime_types.rb
143
+ - spec/fixtures/rails_project/db/schema.rb
144
+ - spec/fixtures/rails_project/db/migrate/20090719005327_create_sessions.rb
145
+ - spec/fixtures/rails_project/db/migrate/20090719031606_create_accounts.rb
146
+ - test/test_generator_helper.rb
147
+ - test/test_blue_ridge_generator.rb
148
+ - test/test_javascript_spec_generator.rb