diff --git a/Gemfile.lock b/Gemfile.lock index f26f9f0..73bd52d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,19 +38,14 @@ GEM i18n (0.6.0) json (1.6.5) metaclass (0.0.1) + minitest (2.11.0) mocha (0.10.3) metaclass (~> 0.0.1) multi_json (1.0.4) rainbow (1.1.3) rake (0.8.7) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) rspec-expectations (2.8.0) diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) sqlite3 (1.3.5) term-ansicolor (1.0.7) tzinfo (0.3.31) @@ -62,6 +57,7 @@ PLATFORMS DEPENDENCIES cucumber (>= 1.1.4) github-api-client! + minitest (>= 2.11.0) mocha (>= 0.10.0) - rspec (>= 2.7.0) + rspec-expectations (>= 2.7.0) yard (>= 0.6.0) diff --git a/Rakefile b/Rakefile index a01c580..9be1904 100644 --- a/Rakefile +++ b/Rakefile @@ -18,15 +18,11 @@ task :irb do system 'irb -I./lib -r github-api-client' end -require 'rspec/core' -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) do |spec| - spec.pattern = FileList['spec/**/*_spec.rb'] -end - -RSpec::Core::RakeTask.new(:rcov) do |spec| - spec.pattern = 'spec/**/*_spec.rb' - spec.rcov = true +desc 'run test suite' +task :tests do + Dir[File.dirname(__FILE__) + '/spec/*_spec.rb'].each do |file| + require file + end end require 'cucumber/rake/task' diff --git a/github-api-client.gemspec b/github-api-client.gemspec index 832100f..3c57a36 100644 --- a/github-api-client.gemspec +++ b/github-api-client.gemspec @@ -34,7 +34,8 @@ Gem::Specification.new do |s| s.add_runtime_dependency("sqlite3", [">= 1.3.5"]) s.add_runtime_dependency("OptionParser", [">= 0.5.1"]) - s.add_development_dependency("rspec", [">= 2.7.0"]) + s.add_development_dependency("minitest", [">= 2.11.0"]) + s.add_development_dependency("rspec-expectations", [">= 2.7.0"]) s.add_development_dependency("mocha", [">= 0.10.0"]) s.add_development_dependency("yard", [">= 0.6.0"]) s.add_development_dependency("cucumber", [">= 1.1.4"]) diff --git a/spec/github-api-client_spec.rb b/spec/github-api-client_spec.rb deleted file mode 100644 index 1347d74..0000000 --- a/spec/github-api-client_spec.rb +++ /dev/null @@ -1,122 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/spec_helper') - -describe "GitHub Api Client" do - - before(:all) do - - @real_github_user = `git config --global github.user`.strip - @real_github_token = `git config --global github.token`.strip - - `git config --global --unset github.user` - `git config --global --unset github.token` - - GitHub::Config.setup - - end - - after(:all) do - - if !@real_github_user.empty? - `git config --global github.user "#{@real_github_user}"` - else - `git config --global --unset github.user` - end - - if !@real_github_token.empty? - `git config --global github.token "#{@real_github_token}"` - else - `git config --global --unset github.token` - end - - end - - context "configuration" do - - it "should create database on first run" do - File.stubs(:exists?).returns(false) - ActiveRecord::Migrator.expects(:migrate).with(GitHub::Config::Path[:migrations], nil).once - GitHub::Config.setup - end - - it "should not migrate database every time" do - File.stubs(:exists?).returns(true) - ActiveRecord::Migrator.expects(:migrate).never - GitHub::Config.setup - end - - it "should find git config setting for github user if defined" do - `git config --global github.user "test"` - `git config --global github.user`.strip.should == 'test' - `git config --global --unset github.user` - - - end - - it "should find git config setting for github token if defined" do - `git config --global github.token "token"` - `git config --global github.token`.strip.should == 'token' - `git config --global --unset github.token` - end - - it "should fall through if no user is defined" do - `git config --global --unset github.user` - GitHub::Config.expects(:setup).once - File.expects(:delete).with(GitHub::Config::Path[:dbfile]).once - GitHub::Config.reset - end - - - context "options" do - - context "with enabled verbose" do - - it "should print messages" do - GitHub::Config::Options.expects(:"[]").with(:verbose).returns(true) - GitHub::Browser.expects(:base_uri).once.returns("") - uri = mock("URI") - URI.expects(:parse).returns uri - Net::HTTP.expects(:get).with uri - $stdout.expects(:puts).once - GitHub::Browser.get("/users/show/farnoy") - end - - end - - context "with disabled verbose" do - - it "should not print messages" do - GitHub::Config::Options.expects(:"[]").with(:verbose).returns(false) - GitHub::Browser.expects(:base_uri).once.returns("") - uri = mock("URI") - URI.expects(:parse).returns uri - Net::HTTP.expects(:get).with uri - $stdout.expects(:puts).never - GitHub::Browser.get("/users/show/farnoy") - end - - end - - end - end - - context "basics" do - - it "should save objects to database" do - u = GitHub::User.get("farnoy") - u.should == GitHub::User.find(u.id) - end - - end - - context "version" do - - it "should assign properly" do - GitHub::Config::Version.should == File.read('VERSION') - end - - it "should alias CAPITALIZED name for maniacs" do - GitHub::Config::Version.should == GitHub::Config::VERSION - end - - end -end diff --git a/spec/other_spec.rb b/spec/other_spec.rb new file mode 100644 index 0000000..5c76279 --- /dev/null +++ b/spec/other_spec.rb @@ -0,0 +1,14 @@ +require 'minitest/spec' +MiniTest::Unit.autorun +require 'rspec/expectations' +require 'rspec/matchers' +require 'mocha' + +describe "Testing framework other" do + it "executes" do + user = stub(:money => 50) + order = stub(:total_amount => 49.99) + + user.money.should satisfy { |money| money > order.total_amount } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index 8134b44..0000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -$LOAD_PATH.unshift(File.dirname(__FILE__)) -require 'rspec' -require 'github-api-client' - -# Requires supporting files with custom matchers and macros, etc, -# in ./support/ and its subdirectories. -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} - -RSpec.configure do |config| - config.mock_with :rspec - config.mock_with :mocha -end diff --git a/spec/test_spec.rb b/spec/test_spec.rb new file mode 100644 index 0000000..160b23b --- /dev/null +++ b/spec/test_spec.rb @@ -0,0 +1,13 @@ +require 'minitest/spec' +MiniTest::Unit.autorun +require 'rspec/expectations' +require 'rspec/matchers' +require 'mocha' + +describe "Testing framework" do + it "executes" do + user = Struct.new("User", :name).new('kuba') + user.stubs(:age).returns(3) + 3.should eq(user.age) + end +end