bushido 0.0.34 → 0.0.35

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,8 @@ module Bushido
15
15
  end
16
16
 
17
17
  def call(env)
18
+ @bushido_claimed = (ENV['BUSHIDO_CLAIMED'].nil? or ENV['BUSHIDO_CLAIMED'].blank?) ? false : true
19
+
18
20
  status, headers, response = @app.call(env)
19
21
 
20
22
  unless @bushido_app_name.empty?
@@ -1,4 +1,4 @@
1
1
  module Bushido
2
2
  # Current version of the Bushido gem
3
- VERSION = "0.0.34"
3
+ VERSION = "0.0.35"
4
4
  end
data/lib/engine.rb CHANGED
@@ -11,8 +11,6 @@ module Bushido
11
11
  unless ENV['BUSHIDO_APP'].nil?
12
12
  app.middleware.use Bushido::Middleware
13
13
  end
14
-
15
14
  end
16
-
17
15
  end
18
16
  end
data/test_app/Gemfile CHANGED
@@ -4,3 +4,4 @@ gem 'rails', '3.0.9'
4
4
  gem 'rspec'
5
5
  gem 'rspec-rails'
6
6
  gem 'bushido', :path => '../'
7
+ gem 'capybara'
@@ -0,0 +1,4 @@
1
+ class StaticController < ApplicationController
2
+ def home
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module StaticHelper
2
+ end
@@ -0,0 +1 @@
1
+ Homepage
@@ -1,5 +1,8 @@
1
1
  TestApp::Application.routes.draw do
2
2
  bushido_routes
3
+
4
+ match '/home' => 'static#home'
5
+
3
6
  # The priority is based upon order of creation:
4
7
  # first created -> highest priority.
5
8
 
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ # Specs in this file have access to a helper object that includes
4
+ # the StaticHelper. For example:
5
+ #
6
+ # describe StaticHelper do
7
+ # describe "string concat" do
8
+ # it "concats two strings with spaces" do
9
+ # helper.concat_strings("this","that").should == "this that"
10
+ # end
11
+ # end
12
+ # end
13
+ describe StaticHelper do
14
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'claiming an app' do
4
+ it "marks claimed = false in the markup" do
5
+ visit "/home"
6
+
7
+ page.body.include?("var _bushido_claimed = false;").should be_true
8
+ end
9
+
10
+ it "marks claimed = false in the markup" do
11
+ preserve_envs("BUSHIDO_CLAIMED") do
12
+ ENV["BUSHIDO_CLAIMED"] = "true"
13
+ visit "/home"
14
+
15
+ page.body.include?("var _bushido_claimed = true;").should be_true
16
+ end
17
+ end
18
+ end
@@ -1,9 +1,19 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ #require File.expand_path('../boot', __FILE__)
2
+ require File.expand_path("../../config/environment", __FILE__)
3
+ require 'rspec/rails'
4
+
5
+ # Requires supporting ruby files with custom matchers and macros, etc,
6
+ # in spec/support/ and its subdirectories.
7
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
2
8
 
3
9
  require "action_controller/railtie"
4
10
  require "action_mailer/railtie"
5
11
  require "active_resource/railtie"
6
12
 
13
+ # Add this to load Capybara integration:
14
+ require 'capybara/rspec'
15
+ require 'capybara/rails'
16
+
7
17
  # If you have a Gemfile, require the gems listed there, including any gems
8
18
  # you've limited to :test, :development, or :production.
9
19
  Bundler.require(:default, Rails.env) if defined?(Bundler)
@@ -42,3 +52,15 @@ module TestApp
42
52
  config.filter_parameters += [:password]
43
53
  end
44
54
  end
55
+
56
+
57
+ def preserve_envs(*keys, &block)
58
+ cache = {}
59
+ keys.each { |key| cache[key] = ENV[key] }
60
+
61
+ begin
62
+ yield
63
+ ensure
64
+ keys.each { |key| ENV[key] = cache[key] }
65
+ end
66
+ end
@@ -0,0 +1,35 @@
1
+ require 'action_dispatch'
2
+ require 'capybara/rails'
3
+ require 'capybara/dsl'
4
+
5
+ module RSpec::Rails
6
+ module IntegrationExampleGroup
7
+ extend ActiveSupport::Concern
8
+
9
+ include ActionDispatch::Integration::Runner
10
+ include RSpec::Rails::TestUnitAssertionAdapter
11
+ include ActionDispatch::Assertions
12
+ include Capybara::DSL
13
+ include RSpec::Matchers
14
+
15
+ module InstanceMethods
16
+ def app
17
+ ::Rails.application
18
+ end
19
+
20
+ def last_response
21
+ page
22
+ end
23
+ end
24
+
25
+ included do
26
+ before do
27
+ @router = ::Rails.application.routes
28
+ end
29
+ end
30
+
31
+ RSpec.configure do |c|
32
+ c.include self, :example_group => { :file_path => /\bspec\/integration\// }
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bushido
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.34
5
+ version: 0.0.35
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sean Grove
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-07-26 00:00:00 -07:00
14
+ date: 2011-07-27 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -112,8 +112,11 @@ files:
112
112
  - test_app/README
113
113
  - test_app/Rakefile
114
114
  - test_app/app/controllers/application_controller.rb
115
+ - test_app/app/controllers/static_controller.rb
115
116
  - test_app/app/helpers/application_helper.rb
117
+ - test_app/app/helpers/static_helper.rb
116
118
  - test_app/app/views/layouts/application.html.erb
119
+ - test_app/app/views/static/home.html.erb
117
120
  - test_app/config.ru
118
121
  - test_app/config/application.rb
119
122
  - test_app/config/boot.rb
@@ -149,7 +152,10 @@ files:
149
152
  - test_app/public/stylesheets/.gitkeep
150
153
  - test_app/script/rails
151
154
  - test_app/spec/controllers/envs_controller_spec.rb
155
+ - test_app/spec/helpers/static_helper_spec.rb
156
+ - test_app/spec/integration/app_claim_spec.rb
152
157
  - test_app/spec/spec_helper.rb
158
+ - test_app/spec/support/integration_example_group.rb
153
159
  - test_app/test/performance/browsing_test.rb
154
160
  - test_app/test/test_helper.rb
155
161
  - test_app/vendor/plugins/.gitkeep
@@ -189,8 +195,11 @@ test_files:
189
195
  - test_app/README
190
196
  - test_app/Rakefile
191
197
  - test_app/app/controllers/application_controller.rb
198
+ - test_app/app/controllers/static_controller.rb
192
199
  - test_app/app/helpers/application_helper.rb
200
+ - test_app/app/helpers/static_helper.rb
193
201
  - test_app/app/views/layouts/application.html.erb
202
+ - test_app/app/views/static/home.html.erb
194
203
  - test_app/config.ru
195
204
  - test_app/config/application.rb
196
205
  - test_app/config/boot.rb
@@ -226,7 +235,10 @@ test_files:
226
235
  - test_app/public/stylesheets/.gitkeep
227
236
  - test_app/script/rails
228
237
  - test_app/spec/controllers/envs_controller_spec.rb
238
+ - test_app/spec/helpers/static_helper_spec.rb
239
+ - test_app/spec/integration/app_claim_spec.rb
229
240
  - test_app/spec/spec_helper.rb
241
+ - test_app/spec/support/integration_example_group.rb
230
242
  - test_app/test/performance/browsing_test.rb
231
243
  - test_app/test/test_helper.rb
232
244
  - test_app/vendor/plugins/.gitkeep