Skip to content

Commit

Permalink
Skip Rails generator tests for legacy rails
Browse files Browse the repository at this point in the history
- Rails versions < 2.3.11 are incompatible with the latest rubygems,
  travis-ci doesn't permit testing different rubygem versions, so just
  skip it (generator tests should be replaced with a wrapper testing the
  functionality, and then a simple mock anyways).
  • Loading branch information
ragaskar authored and Ian Smith-Heisters committed Apr 18, 2012
1 parent dbef0f8 commit 2528c02
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/jasmine/dependencies.rb
Expand Up @@ -10,6 +10,10 @@ def rails2?
safe_gem_check("rails", "~> 2.3")
end

def legacy_rails?
safe_gem_check("rails", "< 2.3.11")
end

def rails3?
safe_gem_check("rails", ">= 3.0")
end
Expand Down
31 changes: 31 additions & 0 deletions spec/dependencies_spec.rb
Expand Up @@ -43,6 +43,22 @@ module Rails
end
end

describe ".legacy_rails?" do
subject { Jasmine::Dependencies.legacy_rails? }
context "when rails < 2.3.11 is present" do
before do
Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_return(true)
end
it { should be_true }
end
context "when rails < 2.3.11 is not present" do
before do
Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_raise(Gem::LoadError)
end
it { should be_false }
end
end

describe ".rails3?" do
subject { Jasmine::Dependencies.rails3? }
context "when rails 3 is present" do
Expand Down Expand Up @@ -151,6 +167,21 @@ module Rails
end
end

describe ".legacy_rails?" do
subject { Jasmine::Dependencies.legacy_rails? }
before do
Gem.should_receive(:available?).with("rails", "< 2.3.11").and_return(legacy_rails_present)
end
context "when rails < 2.3.11 is present" do
let(:legacy_rails_present) { true }
it { should be_true }
end
context "when rails < 2.3.11 is not present" do
let(:legacy_rails_present) { false }
it { should be_false }
end
end

describe ".rails3?" do
subject { Jasmine::Dependencies.rails3? }
before do
Expand Down
2 changes: 1 addition & 1 deletion spec/jasmine_rails2_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))

if Jasmine::Dependencies.rails2?
if Jasmine::Dependencies.rails2? && !Jasmine::Dependencies.legacy_rails?

describe "A Rails 2 app" do

Expand Down

0 comments on commit 2528c02

Please sign in to comment.