-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
173 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
gem 'rails', '~> 3.2' | ||
gemspec :path => '../' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
gem 'rails', '~> 4.0' | ||
gemspec :path => '../' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
gem 'rails', '~> 4.1' | ||
gemspec :path => '../' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'spec_helper' | ||
|
||
if defined?(::Rails) | ||
require 'tempfile' | ||
require 'generators/rack/dev-mark/install_generator' | ||
describe Rack::DevMark::InstallGenerator do | ||
include_context 'forked spec' | ||
|
||
context "config/application.rb" do | ||
let(:application_rb) { Tempfile.new('config_application.rb') } | ||
before do | ||
application_rb.write <<-EOS | ||
module MyApp | ||
class Application < Rails::Application | ||
# ... | ||
end | ||
end | ||
EOS | ||
application_rb.rewind | ||
allow_any_instance_of(Rack::DevMark::InstallGenerator).to receive(:target_path).and_return(application_rb.path) | ||
end | ||
after do | ||
application_rb.close | ||
application_rb.unlink | ||
end | ||
|
||
it 'inserts rack-dev-mark settings' do | ||
Rails::Generators.invoke("rack:dev-mark:install") | ||
application_rb.rewind | ||
expect(application_rb.read).to eq <<-EOS | ||
module MyApp | ||
class Application < Rails::Application | ||
# Enable rack-dev-mark | ||
config.rack_dev_mark.enable = !Rails.env.production? | ||
# Customize themes if you want to do so | ||
# config.rack_dev_mark.theme = [:title, :github_fork_ribbon] | ||
# ... | ||
end | ||
end | ||
EOS | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper' | ||
|
||
if defined?(::Rails) | ||
describe Rack::DevMark::Railtie do | ||
include_context 'forked spec' | ||
|
||
before do | ||
puts 'initialize rails' | ||
@app = Class.new(::Rails::Application) | ||
@app.config.active_support.deprecation = :stderr | ||
end | ||
context "rack_dev_mark enable" do | ||
before do | ||
@app.config.rack_dev_mark.enable = true | ||
@app.initialize! | ||
end | ||
it 'inserts the middleware' do | ||
expect(@app.middleware.middlewares).to include(Rack::DevMark::Middleware) | ||
end | ||
end | ||
context "rack_dev_mark disable" do | ||
before do | ||
@app.config.rack_dev_mark.enable = false | ||
@app.initialize! | ||
end | ||
it 'does not insert the middleware' do | ||
expect(@app.middleware.middlewares).not_to include(Rack::DevMark::Middleware) | ||
end | ||
end | ||
context "rack_dev_mark theme" do | ||
let(:setting_key) { 'theme' } | ||
let(:theme) { d = double setup: nil; allow(d).to receive(:insert_into){ |b| "#{b} dev-mark" }; d } | ||
before do | ||
@app.config.rack_dev_mark.enable = true | ||
@app.config.rack_dev_mark.send "#{setting_key}=", [theme] | ||
@app.initialize! | ||
end | ||
it 'inserts the middleware' do | ||
expect(theme).to receive(:setup) | ||
end | ||
context "rack_dev_mark custom_theme alias" do | ||
let(:setting_key) { 'custom_theme' } | ||
it 'inserts the middleware' do | ||
expect(theme).to receive(:setup) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
require 'rubygems' | ||
require 'simplecov' | ||
require 'coveralls' | ||
Coveralls.wear! | ||
|
||
resultset_path = SimpleCov::ResultMerger.resultset_path | ||
FileUtils.rm resultset_path if File.exists? resultset_path | ||
SimpleCov.use_merging true | ||
SimpleCov.at_exit do | ||
SimpleCov.command_name "fork-#{$$}" | ||
SimpleCov.result.format! | ||
end | ||
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ | ||
SimpleCov::Formatter::HTMLFormatter, | ||
Coveralls::SimpleCov::Formatter | ||
] | ||
if ENV['COVERAGE'] | ||
SimpleCov.start | ||
end | ||
|
||
ENV['RACK_ENV'] = 'test' | ||
|
||
require 'rack' | ||
begin | ||
require 'rails' | ||
$stdout.write "* Rails has been loaded.\n" | ||
rescue LoadError | ||
end | ||
require 'rack-dev-mark' | ||
|
||
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f } | ||
|
||
ENV['RACK_ENV'] = 'test' | ||
RSpec.configure do |config| | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
shared_context 'forked spec' do | ||
around do |example| | ||
read, write = IO.pipe | ||
pid = fork do | ||
$stdout.sync = true | ||
$stderr.sync = true | ||
res = example.run | ||
Marshal.dump(res, write) | ||
write.close | ||
end | ||
Process.waitpid2 pid | ||
res = Marshal.load(read) | ||
example.example.send :set_exception, res | ||
read.close | ||
#fail "Forked spec failed" if $? >> 8 != 0 | ||
end | ||
end |