Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #14 from alindeman/matsubo-test-latest-ruby
Browse files Browse the repository at this point in the history
Updates for latest Ruby versions, removes support for EOLed Ruby versions
  • Loading branch information
alindeman committed Mar 13, 2016
2 parents 4d1054c + 5e6157b commit ce29eb3
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 73 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
@@ -1,8 +1,8 @@
language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.8
- 2.2.4
- 2.3.0
- jruby-19mode
- rbx-2
4 changes: 0 additions & 4 deletions Gemfile
Expand Up @@ -3,10 +3,6 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in zonebie.gemspec
gemspec

if RUBY_VERSION <= '1.9.2'
gem 'activesupport', '>=2.3', '<4.1'
end

platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'rubinius-developer_tools'
Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -11,16 +11,16 @@ debug (more information below).

## Requirements

* MRI (1.8.7, 1.9.2, 1.9.3, 2.0.0)
* JRuby (1.6, 1.7)
* Rubinius (1.2, 2.0)
* MRI (2.0.x, 2.1.x, 2.2.x, 2.3.x)
* JRuby (1.7)
* Rubinius (2.0)

***

And **either** of these gems which adds timezone support to Ruby:

* `activesupport` >= 2.3 (Rails 2.3, 3.0, 3.1, 3.2, 4.0, 4.1)
* `tzinfo` >= 0.3
* `activesupport` >= 3.0 (Rails 3.0, 3.1, 3.2, 4.0, 4.1, 4.2)
* `tzinfo` >= 1.2

## Installation

Expand Down
37 changes: 17 additions & 20 deletions lib/zonebie.rb
@@ -1,31 +1,33 @@
require File.expand_path("zonebie/version", File.dirname(__FILE__))
require File.expand_path('zonebie/version', File.dirname(__FILE__))

module Zonebie
class << self
attr_accessor :quiet

def backend
unless @backend
@backend = if @backends[:activesupport].usable?
@backends[:activesupport]
else
@backends.values.detect(&:usable?)
end
@backend = \
if @backends[:activesupport].usable?
@backends[:activesupport]
else
@backends.values.detect(&:usable?)
end
end

@backend
end

def backend=(backend)
case backend
when Symbol
@backend = @backends[backend]
else
@backend = backend
end
@backend = \
case backend
when Symbol
@backends[backend]
else
backend
end

if !backend.nil? && @backend.nil?
raise ArgumentError, "Unsupported backend: #{backend}"
fail ArgumentError, "Unsupported backend: #{backend}"
end

@backend
Expand All @@ -37,17 +39,12 @@ def add_backend(backend)
end

def set_random_timezone
zone = ENV['ZONEBIE_TZ'] || random_timezone
zone = ENV['ZONEBIE_TZ'] || backend.zones.sample

$stdout.puts("[Zonebie] Setting timezone: ZONEBIE_TZ=\"#{zone}\"") unless quiet
backend.zone = zone
end

def random_timezone
zones = backend.zones
zones[rand(zones.length)]
end
end
end

require File.expand_path("zonebie/backends", File.dirname(__FILE__))
require File.expand_path('zonebie/backends', File.dirname(__FILE__))
4 changes: 2 additions & 2 deletions lib/zonebie/backends.rb
@@ -1,2 +1,2 @@
require File.expand_path("backends/active_support", File.dirname(__FILE__))
require File.expand_path("backends/tzinfo", File.dirname(__FILE__))
require File.expand_path('backends/active_support', File.dirname(__FILE__))
require File.expand_path('backends/tzinfo', File.dirname(__FILE__))
2 changes: 1 addition & 1 deletion lib/zonebie/rspec.rb
@@ -1,4 +1,4 @@
require File.expand_path("../zonebie", File.dirname(__FILE__))
require File.expand_path('../zonebie', File.dirname(__FILE__))

RSpec.configure do |c|
c.before(:suite) do
Expand Down
3 changes: 2 additions & 1 deletion lib/zonebie/version.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Zonebie
VERSION = "0.5.1"
VERSION = '0.5.1'.freeze
end
1 change: 0 additions & 1 deletion spec/integrations/activesupport_spec.rb
@@ -1,5 +1,4 @@
require "spec_helper"
require "active_support/time"

describe Zonebie do
before do
Expand Down
17 changes: 8 additions & 9 deletions spec/lib/zonebie/backends/active_support_spec.rb
Expand Up @@ -3,19 +3,18 @@
describe Zonebie::Backends::ActiveSupport do
describe "#name" do
it "is :activesupport" do
described_class.name.should == :activesupport
expect(described_class.name).to eq :activesupport
end
end

describe "#zones" do
it "returns a list of zones provided by ActiveSupport" do
::ActiveSupport::TimeZone.stubs(:all).
returns([
stub(:name => "Eastern Time (US & Canada)"),
stub(:name => "Central Time (US & Canada)")
])
::ActiveSupport::TimeZone.stubs(:all).returns([
stub(:name => "Eastern Time (US & Canada)"),
stub(:name => "Central Time (US & Canada)")
])

described_class.zones.should =~ ["Eastern Time (US & Canada)", "Central Time (US & Canada)"]
expect(described_class.zones).to eq ["Eastern Time (US & Canada)", "Central Time (US & Canada)"]
end
end

Expand All @@ -29,14 +28,14 @@

describe "usable?" do
it "returns true if ActiveSupport is available" do
described_class.should be_usable
expect(described_class).to be_usable
end

it "returns false if ActiveSupport is unavailable" do
old_active_support = ActiveSupport
Object.send(:remove_const, :ActiveSupport)
begin
described_class.should_not be_usable
expect(described_class).not_to be_usable
ensure
ActiveSupport = old_active_support
end
Expand Down
17 changes: 8 additions & 9 deletions spec/lib/zonebie/backends/tzinfo_spec.rb
Expand Up @@ -3,19 +3,18 @@
describe Zonebie::Backends::TZInfo do
describe "#name" do
it "is :tzinfo" do
described_class.name.should == :tzinfo
expect(described_class.name).to eq :tzinfo
end
end

describe "#zones" do
it "returns a list of zones provided by TZInfo" do
::TZInfo::Timezone.stubs(:all).
returns([
stub(:identifier => "America/Chicago"),
stub(:identifier => "America/New York")
])
::TZInfo::Timezone.stubs(:all).returns([
stub(:identifier => "America/Chicago"),
stub(:identifier => "America/New York")
])

described_class.zones.should =~ ["America/Chicago", "America/New York"]
expect(described_class.zones).to eq ["America/Chicago", "America/New York"]
end
end

Expand All @@ -28,14 +27,14 @@

describe "usable?" do
it "returns true if TZInfo is available" do
described_class.should be_usable
expect(described_class).to be_usable
end

it "returns false if TZInfo is unavailable" do
old_tz_info = TZInfo
Object.send(:remove_const, :TZInfo)
begin
described_class.should_not be_usable
expect(described_class).not_to be_usable
ensure
TZInfo = old_tz_info
end
Expand Down
9 changes: 3 additions & 6 deletions spec/lib/zonebie_spec.rb
Expand Up @@ -3,18 +3,18 @@
describe Zonebie do
describe "#backend" do
it "defaults to the activesupport backend in the presence of activesupport" do
Zonebie.backend.name.should == :activesupport
expect(Zonebie.backend.name).to eq :activesupport
end

it "allows setting the backend to tzinfo" do
Zonebie.backend = :tzinfo
Zonebie.backend.name.should == :tzinfo
expect(Zonebie.backend.name).to eq :tzinfo
end

it "defaults to tzinfo in the absense of activesupport" do
Zonebie::Backends::ActiveSupport.stubs(:usable?).returns(false)

Zonebie.backend.name.should == :tzinfo
expect(Zonebie.backend.name).to eq :tzinfo
end

it "does not allow setting the backend to an unsupported value" do
Expand Down Expand Up @@ -90,8 +90,5 @@
Zonebie.backend = :my_awesome_backend
end

it "returns a random timezone" do
Zonebie.random_timezone.should == "Eastern Time (US & Canada)"
end
end
end
28 changes: 16 additions & 12 deletions zonebie.gemspec
@@ -1,26 +1,30 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/zonebie/version', __FILE__)
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'zonebie/version'

Gem::Specification.new do |gem|
gem.name = "zonebie"
gem.version = Zonebie::VERSION
gem.authors = ['Andy Lindeman', 'Steven Harman', 'Patrick Van Stee']
gem.email = ['andy@andylindeman.com', 'steveharman@gmail.com', 'patrickvanstee@gmail.com']
gem.description = %q{Runs your tests in a random timezone}
gem.summary = %q{Zonebie prevents bugs in code that deals with timezones by randomly assigning a zone on every run}
gem.homepage = "https://github.com/alindeman/zonebie"
gem.license = 'MIT'

gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "zonebie"
gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|gem|features)/}) }
gem.bindir = "exe"
gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
gem.require_paths = ["lib"]
gem.version = Zonebie::VERSION

gem.required_ruby_version = '>= 2.0.0'

gem.add_development_dependency "rake"
gem.add_development_dependency "rspec", "~>2.14"
gem.add_development_dependency "mocha", "~>0.14.0"
gem.add_development_dependency "rspec", "~> 3.4"
gem.add_development_dependency "mocha", "~> 0.14.0"

gem.add_development_dependency "activesupport", ">=2.3"
gem.add_development_dependency "tzinfo", "~>1.0", ">= 1.0.1"
gem.add_development_dependency "tzinfo-data", ">= 1.2013.4"
gem.add_development_dependency "activesupport", "~> 3.0"
gem.add_development_dependency "tzinfo", "~> 1.2", ">= 1.2.2"
gem.add_development_dependency "tzinfo-data", ">= 1.2016.1"
end

0 comments on commit ce29eb3

Please sign in to comment.