Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Setup MiniTest. Let unknown attributes be ignored during initializati…

…on in RunKeeper::Activity
  • Loading branch information...
commit 705f06f50437423acc2849eed92bc4000b3d8576 1 parent b1ecc5c
@tatey tatey authored
View
25 Rakefile
@@ -1 +1,24 @@
-require 'bundler/gem_tasks'
+begin
+ require 'rubygems'
+ require 'bundler'
+rescue LoadError
+ raise 'Could not load the bundler gem. Install it with `gem install bundler`.'
+end
+
+begin
+ Bundler.setup
+rescue Bundler::GemNotFound
+ raise RuntimeError, "Bundler couldn't find some gems." +
+ "Did you run `bundle install`?"
+end
+
+Bundler::GemHelper.install_tasks
+
+require 'rake/testtask'
+
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'test'
+ test.pattern = 'test/**/*_test.rb'
+end
+
+task :default => :test
View
2  lib/run_keeper/activity.rb
@@ -5,7 +5,7 @@ class Activity
def initialize attributes = {}
attributes.each do |attribute, value|
- send :"#{attribute}=", value
+ send :"#{attribute}=", value if respond_to? :"#{attribute}="
end
end
View
1  run_keeper.gemspec
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
+ s.add_development_dependency 'rake', '~> 0.9.2'
s.add_dependency 'activesupport', '~> 3.1.0'
s.add_dependency 'oauth2', '~> 0.5.0'
end
View
7 test/activity_test.rb
@@ -0,0 +1,7 @@
+require 'helper'
+
+class ActivityTest < MiniTest::Unit::TestCase
+ def test_initailization_ignores_unknown_attributes
+ refute_match Activity.new(:foo => 'bar').instance_variables, /foo/
+ end
+end
View
4 test/helper.rb
@@ -0,0 +1,4 @@
+require 'minitest/autorun'
+require 'run_keeper'
+
+include RunKeeper
Please sign in to comment.
Something went wrong with that request. Please try again.