Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Work in Progress] Rails 5 #241

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
sudo: false
language: ruby
rvm:
- 2.2.0
- 2.4.0
- 2.3.3
- 2.2.6
install:
- wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
- mkdir geckodriver
- tar -xzf geckodriver-v0.24.0-linux64.tar.gz -C geckodriver
- export PATH=$(pwd)/geckodriver:$PATH
gemfile:
- Gemfile
- Gemfile-sprockets2-sprocketsrails2
- Gemfile-sprockets3-sprocketsrails2
- Gemfile-rails41
- Gemfile-rails42
before_script:
- sh -e /etc/init.d/xvfb start
- export DISPLAY=:99.0
- firefox -v
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source 'https://rubygems.org'
gemspec

gem "railties", "~> 4.2.0"
gem "rails", "~> 5.0", ">= 5.0.1"
gem "sprockets-rails"
gem "jquery-rails"
gem "rspec-rails", "3.8.2"
5 changes: 5 additions & 0 deletions Gemfile-rails42
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'
gemspec

gem "railties", "~> 4.2.0"
gem "sprockets-rails"
6 changes: 5 additions & 1 deletion app/controllers/konacha/specs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
module Konacha
class SpecsController < ActionController::Base
rescue_from Konacha::Spec::NotFound do
render :text => "Not found", :status => 404
if Konacha.rails_5_x?
render plain: "Not found", status: 404
else
render :text => "Not found", :status => 404
end
end

def parent
Expand Down
9 changes: 5 additions & 4 deletions konacha.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ the asset pipeline and engines.}
gem.version = "4.0.0"
gem.license = "MIT"

gem.add_dependency "railties", ">= 4.1", "< 5"
gem.add_dependency "actionpack", ">= 4.1", "< 5"
gem.add_dependency "railties", ">= 4.1", "< 6"
gem.add_dependency "actionpack", ">= 4.1", "< 6"
gem.add_dependency "sprockets", ">= 2", "< 4"
gem.add_dependency "sprockets-rails", ">= 2", "< 4"
gem.add_dependency "capybara"
gem.add_dependency "colorize"
gem.add_dependency "tilt"

gem.add_development_dependency "jquery-rails"
gem.add_development_dependency "rspec-rails", "~> 3.1"
gem.add_development_dependency "rspec-rails"
gem.add_development_dependency "capybara-firebug", "~> 1.1"
gem.add_development_dependency "coffee-script"
gem.add_development_dependency "ejs"
gem.add_development_dependency "tzinfo"
gem.add_development_dependency "selenium-webdriver", "~> 2"
gem.add_development_dependency "selenium-webdriver", "~> 3"
gem.add_development_dependency "poltergeist", "1.9.0"
gem.add_development_dependency "rails-controller-testing"
end
4 changes: 4 additions & 0 deletions lib/konacha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,9 @@ def asset_precompiled?(logical_path)
def sprockets_rails_3?
defined?(Sprockets::Rails::VERSION) && Sprockets::Rails::VERSION.start_with?('3')
end

def rails_5_x?
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING.starts_with?('5.')
end
end
end
18 changes: 15 additions & 3 deletions spec/controllers/specs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

describe '#parent' do
it 'accepts a mode parameter and assigns it to @run_mode' do
get :parent, :mode => 'runner'
if Konacha.rails_5_x?
get :parent, params: { mode: 'runner' }
else
get :parent, mode: 'runner'
end
assigns[:run_mode].runner?.should be_truthy
end

Expand All @@ -21,15 +25,23 @@
describe "#iframe" do
it "assigns the result of Spec.find_by_name to @spec" do
Konacha::Spec.should_receive(:find_by_name).with("spec_name") { :spec }
get :iframe, :name => "spec_name"
if Konacha.rails_5_x?
get :iframe, params: { name: "spec_name" }
else
get :iframe, name: "spec_name"
end
assigns[:spec].should == :spec
assigns[:stylesheets].should == Konacha::Engine.config.konacha.stylesheets
assigns[:javascripts].should == Konacha::Engine.config.konacha.javascripts
end

it "404s if there is no match for the given path" do
Konacha::Spec.should_receive(:find_by_name).with("array_spec") { raise Konacha::Spec::NotFound }
get :iframe, :name => "array_spec"
if Konacha.rails_5_x?
get :iframe, params: { name: "array_spec" }
else
get :iframe, :name => "array_spec"
end
response.status.should == 404
response.should_not render_template("konacha/specs/iframe")
end
Expand Down