[DRE-commits] [ruby-dataobjects] 02/05: Make tests run

Balasankar C balasankarc-guest at moszumanska.debian.org
Tue Jul 21 16:49:35 UTC 2015


This is an automated email from the git hooks/post-receive script.

balasankarc-guest pushed a commit to branch master
in repository ruby-dataobjects.

commit d21bcbcfff4bb1b42c8361ab530ad1623a503de0
Author: Balasankar C <balasankarc at autistici.org>
Date:   Tue Jul 21 22:18:15 2015 +0530

    Make tests run
---
 debian/patches/0040-require-its.patch          |  16 +
 debian/patches/0050-tests-support-rspec3.patch | 424 +++++++++++++++++++++++++
 2 files changed, 440 insertions(+)

diff --git a/debian/patches/0040-require-its.patch b/debian/patches/0040-require-its.patch
new file mode 100644
index 0000000..12e2df1
--- /dev/null
+++ b/debian/patches/0040-require-its.patch
@@ -0,0 +1,16 @@
+Description: Require 'rspec/its'
+ Tests use 'its'. So, made spec_helper require 'rspec/its'
+Author: Balasankar C <balasankarc at autistici.org>
+Last-Update: 2015-07-21
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/spec/spec_helper.rb
++++ b/spec/spec_helper.rb
+@@ -1,6 +1,7 @@
+ require 'rubygems'
+ require 'data_objects'
+ require 'rspec'
++require 'rspec/its'
+ 
+ module DataObjects::Pooling
+   class << self
diff --git a/debian/patches/0050-tests-support-rspec3.patch b/debian/patches/0050-tests-support-rspec3.patch
new file mode 100644
index 0000000..a0e14a1
--- /dev/null
+++ b/debian/patches/0050-tests-support-rspec3.patch
@@ -0,0 +1,424 @@
+Description: Make test files support RSpec3
+ The test files are tweaked to support RSpec 3 syntax
+Author: Balasankar C <balasankarc at autistici.org>
+Last-Update: 2015-07-21
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/spec/command_spec.rb
++++ b/spec/command_spec.rb
+@@ -12,13 +12,13 @@
+ 
+   %w{connection execute_non_query execute_reader set_types}.each do |meth|
+     it "should respond to ##{meth}" do
+-      @command.should respond_to(meth.intern)
++      expect(@command).to respond_to(meth.intern)
+     end
+   end
+ 
+   %w{execute_non_query execute_reader set_types}.each do |meth|
+     it "should raise NotImplementedError on ##{meth}" do
+-      lambda { @command.send(meth.intern, nil) }.should raise_error(NotImplementedError)
++      expect { @command.send(meth.intern, nil) }.to raise_error(NotImplementedError)
+     end
+   end
+ 
+--- a/spec/connection_spec.rb
++++ b/spec/connection_spec.rb
+@@ -11,10 +11,13 @@
+   context 'should define a standard API' do
+     let(:uri)   { 'mock://localhost'      }
+ 
+-    it { should respond_to(:dispose)        }
+-    it { should respond_to(:create_command) }
++    it { is_expected.to respond_to(:dispose)        }
++    it { is_expected.to respond_to(:create_command) }
+ 
+-    its(:to_s)  { should == 'mock://localhost' }
++    describe '#to_s' do
++      subject { super().to_s }
++      it { is_expected.to eq('mock://localhost') }
++    end
+   end
+ 
+   describe 'initialization' do
+@@ -22,10 +25,13 @@
+     context 'with a connection uri as a Addressable::URI' do
+       let(:uri)  { Addressable::URI::parse('mock://localhost/database') }
+ 
+-      it { should be_kind_of(DataObjects::Mock::Connection) }
+-      it { should be_kind_of(DataObjects::Pooling)          }
++      it { is_expected.to be_kind_of(DataObjects::Mock::Connection) }
++      it { is_expected.to be_kind_of(DataObjects::Pooling)          }
+ 
+-      its(:to_s) { should == 'mock://localhost/database' }
++      describe '#to_s' do
++        subject { super().to_s }
++        it { is_expected.to eq('mock://localhost/database') }
++      end
+     end
+ 
+     [
+@@ -35,8 +41,8 @@
+     context 'should return the Connection specified by the scheme without pooling' do
+       let(:uri)  { jndi_url }
+ 
+-      it { should be_kind_of(DataObjects::Mock2::Connection) }
+-      it { should_not be_kind_of(DataObjects::Pooling)       }
++      it { is_expected.to be_kind_of(DataObjects::Mock2::Connection) }
++      it { is_expected.not_to be_kind_of(DataObjects::Pooling)       }
+     end
+   end
+ 
+@@ -52,7 +58,7 @@
+       context "with JDBC URL '#{jdbc_url}'" do
+         let(:uri)  { jdbc_url }
+ 
+-        it { should be_kind_of(DataObjects::Mock::Connection) }
++        it { is_expected.to be_kind_of(DataObjects::Mock::Connection) }
+       end
+     end
+ 
+--- a/spec/pooling_spec.rb
++++ b/spec/pooling_spec.rb
+@@ -80,7 +80,7 @@
+     ted = Person.new('Ted')
+ 
+     Person.__pools.each do |args, pool|
+-      pool.size.should == 1
++      expect(pool.size).to eq(1)
+     end
+ 
+     bob.release
+@@ -88,31 +88,31 @@
+     ted.release
+ 
+     Person.__pools.each do |args, pool|
+-      pool.size.should == 1
++      expect(pool.size).to eq(1)
+     end
+   end
+ 
+   it "should track the initialized pools" do
+     bob = Person.new('Bob') # Ensure the pool is "primed"
+-    bob.name.should == 'Bob'
+-    bob.instance_variable_get(:@__pool).should_not be_nil
+-    Person.__pools.size.should == 1
++    expect(bob.name).to eq('Bob')
++    expect(bob.instance_variable_get(:@__pool)).not_to be_nil
++    expect(Person.__pools.size).to eq(1)
+     bob.release
+-    Person.__pools.size.should == 1
++    expect(Person.__pools.size).to eq(1)
+ 
+-    DataObjects::Pooling::pools.should_not be_empty
++    expect(DataObjects::Pooling::pools).not_to be_empty
+ 
+     sleep(1.2)
+ 
+     # NOTE: This assertion is commented out, as our MockConnection objects are
+     #       currently in the pool.
+     # DataObjects::Pooling::pools.should be_empty
+-    bob.name.should be_nil
++    expect(bob.name).to be_nil
+   end
+ 
+   it "should allow you to overwrite Class#new" do
+     bob = Overwriter.new('Bob')
+-    bob.should be_overwritten
++    expect(bob).to be_overwritten
+     bob.release
+   end
+ 
+@@ -123,11 +123,11 @@
+       bob.release
+     end
+ 
+-    lambda do
++    expect do
+       bob = Person.new('Bob')
+       t1.join
+       bob.release
+-    end.should_not raise_error(DataObjects::Pooling::InvalidResourceError)
++    end.not_to raise_error
+   end
+ 
+   it "should allow you to flush a pool" do
+@@ -135,13 +135,13 @@
+     Overwriter.new('Bob').release
+     bob.release
+ 
+-    bob.name.should == 'Bob'
++    expect(bob.name).to eq('Bob')
+ 
+-    Overwriter.__pools[['Bob']].size.should == 2
++    expect(Overwriter.__pools[['Bob']].size).to eq(2)
+     Overwriter.__pools[['Bob']].flush!
+-    Overwriter.__pools[['Bob']].size.should == 0
++    expect(Overwriter.__pools[['Bob']].size).to eq(0)
+ 
+-    bob.name.should be_nil
++    expect(bob.name).to be_nil
+   end
+ 
+   it "should wake up the scavenger thread when exiting" do
+@@ -149,14 +149,14 @@
+     bob.release
+     DataObjects.exiting = true
+     sleep(1)
+-    DataObjects::Pooling.scavenger?.should be_false
++    expect(DataObjects::Pooling.scavenger?).to be_falsey
+   end
+ 
+   it "should be able to detach an instance from the pool" do
+     bob = Person.new('Bob')
+-    Person.__pools[['Bob']].size.should == 1
++    expect(Person.__pools[['Bob']].size).to eq(1)
+     bob.detach
+-    Person.__pools[['Bob']].size.should == 0
++    expect(Person.__pools[['Bob']].size).to eq(0)
+   end
+ 
+ end
+--- a/spec/reader_spec.rb
++++ b/spec/reader_spec.rb
+@@ -10,13 +10,13 @@
+ 
+   context 'should define a standard API' do
+ 
+-    it { should be_a(Enumerable)    }
++    it { is_expected.to be_a(Enumerable)    }
+ 
+-    it { should respond_to(:close)  }
+-    it { should respond_to(:next!)  }
+-    it { should respond_to(:values) }
+-    it { should respond_to(:fields) }
+-    it { should respond_to(:each)   }
++    it { is_expected.to respond_to(:close)  }
++    it { is_expected.to respond_to(:next!)  }
++    it { is_expected.to respond_to(:values) }
++    it { is_expected.to respond_to(:fields) }
++    it { is_expected.to respond_to(:each)   }
+   end
+ 
+ end
+--- a/spec/result_spec.rb
++++ b/spec/result_spec.rb
+@@ -11,12 +11,12 @@
+   context 'should define a standard API' do
+ 
+     it 'should provide the number of affected rows' do
+-      should respond_to(:to_i)
+-      subject.to_i.should == 0
++      is_expected.to respond_to(:to_i)
++      expect(subject.to_i).to eq(0)
+     end
+ 
+     it 'should provide the id of the inserted row' do
+-      should respond_to(:insert_id)
++      is_expected.to respond_to(:insert_id)
+     end
+ 
+   end
+--- a/spec/spec_helper.rb
++++ b/spec/spec_helper.rb
+@@ -1,7 +1,6 @@
+ require 'rubygems'
+ require 'data_objects'
+ require 'rspec'
+-require 'rspec/its'
+ 
+ module DataObjects::Pooling
+   class << self
+--- a/spec/transaction_spec.rb
++++ b/spec/transaction_spec.rb
+@@ -3,36 +3,36 @@
+ describe DataObjects::Transaction do
+ 
+   before :each do
+-    @connection = mock("connection")
+-    DataObjects::Connection.should_receive(:new).with("mock://mock/mock").once.and_return(@connection)
++    @connection = double("connection")
++    expect(DataObjects::Connection).to receive(:new).with("mock://mock/mock").once.and_return(@connection)
+     @transaction = DataObjects::Transaction.new("mock://mock/mock")
+   end
+ 
+   it "should have a HOST constant" do
+-    DataObjects::Transaction::HOST.should_not == nil?
++    expect(DataObjects::Transaction::HOST).not_to eq(nil?)
+   end
+ 
+   describe "#initialize" do
+     it "should provide a connection" do
+-      @transaction.connection.should == @connection
++      expect(@transaction.connection).to eq(@connection)
+     end
+     it "should provide an id" do
+-      @transaction.id.should_not == nil
++      expect(@transaction.id).not_to eq(nil)
+     end
+     it "should provide a unique id" do
+-      DataObjects::Connection.should_receive(:new).with("mock://mock/mock2").once.and_return(@connection)
+-      @transaction.id.should_not == DataObjects::Transaction.new("mock://mock/mock2").id
++      expect(DataObjects::Connection).to receive(:new).with("mock://mock/mock2").once.and_return(@connection)
++      expect(@transaction.id).not_to eq(DataObjects::Transaction.new("mock://mock/mock2").id)
+     end
+   end
+   describe "#close" do
+     it "should close its connection" do
+-      @connection.should_receive(:close).once
+-      lambda { @transaction.close }.should_not raise_error(DataObjects::TransactionError)
++      expect(@connection).to receive(:close).once
++      expect { @transaction.close }.not_to raise_error
+     end
+   end
+   [:prepare, :commit_prepared, :rollback_prepared].each do |meth|
+     it "should raise NotImplementedError on #{meth}" do
+-      lambda { @transaction.send(meth) }.should raise_error(NotImplementedError)
++      expect { @transaction.send(meth) }.to raise_error(NotImplementedError)
+     end
+   end
+ 
+--- a/spec/uri_spec.rb
++++ b/spec/uri_spec.rb
+@@ -6,46 +6,119 @@
+   context 'parsing parts' do
+     let(:uri) { 'mock://username:password@localhost:12345/path?encoding=utf8#fragment'  }
+ 
+-    its(:scheme)    { should == 'mock'      }
+-    its(:user)      { should == 'username'  }
+-    its(:password)  { should == 'password'  }
+-    its(:host)      { should == 'localhost' }
+-    its(:port)      { should == 12345       }
+-    its(:path)      { should == '/path'     }
+-    its(:query)     { should == { 'encoding' => 'utf8' } }
+-    its(:fragment)  { should == 'fragment'  }
++    describe '#scheme' do
++      subject { super().scheme }
++      it { is_expected.to eq('mock')      }
++    end
++
++    describe '#user' do
++      subject { super().user }
++      it { is_expected.to eq('username')  }
++    end
++
++    describe '#password' do
++      subject { super().password }
++      it { is_expected.to eq('password')  }
++    end
++
++    describe '#host' do
++      subject { super().host }
++      it { is_expected.to eq('localhost') }
++    end
++
++    describe '#port' do
++      subject { super().port }
++      it { is_expected.to eq(12345)       }
++    end
++
++    describe '#path' do
++      subject { super().path }
++      it { is_expected.to eq('/path')     }
++    end
++
++    describe '#query' do
++      subject { super().query }
++      it { is_expected.to eq({ 'encoding' => 'utf8' }) }
++    end
++
++    describe '#fragment' do
++      subject { super().fragment }
++      it { is_expected.to eq('fragment')  }
++    end
+ 
+     it 'should provide a correct string representation' do
+-      subject.to_s.should == 'mock://username@localhost:12345/path?encoding=utf8#fragment'
++      expect(subject.to_s).to eq('mock://username@localhost:12345/path?encoding=utf8#fragment')
+     end
+   end
+ 
+   context 'parsing JDBC URL parts' do
+     let(:uri) { 'jdbc:mock://username:password@localhost:12345/path?encoding=utf8#fragment'  }
+ 
+-    its(:scheme)    { should == 'jdbc'      }
+-    its(:subscheme) { should == 'mock'      }
+-    its(:user)      { should == 'username'  }
+-    its(:password)  { should == 'password'  }
+-    its(:host)      { should == 'localhost' }
+-    its(:port)      { should == 12345       }
+-    its(:path)      { should == '/path'     }
+-    its(:query)     { should == { 'encoding' => 'utf8' } }
+-    its(:fragment)  { should == 'fragment'  }
++    describe '#scheme' do
++      subject { super().scheme }
++      it { is_expected.to eq('jdbc')      }
++    end
++
++    describe '#subscheme' do
++      subject { super().subscheme }
++      it { is_expected.to eq('mock')      }
++    end
++
++    describe '#user' do
++      subject { super().user }
++      it { is_expected.to eq('username')  }
++    end
++
++    describe '#password' do
++      subject { super().password }
++      it { is_expected.to eq('password')  }
++    end
++
++    describe '#host' do
++      subject { super().host }
++      it { is_expected.to eq('localhost') }
++    end
++
++    describe '#port' do
++      subject { super().port }
++      it { is_expected.to eq(12345)       }
++    end
++
++    describe '#path' do
++      subject { super().path }
++      it { is_expected.to eq('/path')     }
++    end
++
++    describe '#query' do
++      subject { super().query }
++      it { is_expected.to eq({ 'encoding' => 'utf8' }) }
++    end
++
++    describe '#fragment' do
++      subject { super().fragment }
++      it { is_expected.to eq('fragment')  }
++    end
+ 
+     it 'should provide a correct string representation' do
+-      subject.to_s.should == 'jdbc:mock://username@localhost:12345/path?encoding=utf8#fragment'
++      expect(subject.to_s).to eq('jdbc:mock://username@localhost:12345/path?encoding=utf8#fragment')
+     end
+   end
+ 
+   context 'parsing parts' do
+     let(:uri) { 'java:comp/env/jdbc/TestDataSource'  }
+ 
+-    its(:scheme)    { should == 'java' }
+-    its(:path)      { should == 'comp/env/jdbc/TestDataSource'     }
++    describe '#scheme' do
++      subject { super().scheme }
++      it { is_expected.to eq('java') }
++    end
++
++    describe '#path' do
++      subject { super().path }
++      it { is_expected.to eq('comp/env/jdbc/TestDataSource')     }
++    end
+ 
+     it 'should provide a correct string representation' do
+-      subject.to_s.should == 'java:comp/env/jdbc/TestDataSource'
++      expect(subject.to_s).to eq('java:comp/env/jdbc/TestDataSource')
+     end
+   end
+ 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-dataobjects.git



More information about the Pkg-ruby-extras-commits mailing list