Browse files

Move Bang into its own gem

  • Loading branch information...
1 parent f8d412f commit 66da57f816afd61f8be98ba8f35d33d55a8383c8 @jeffkreeftmeijer jeffkreeftmeijer committed Sep 22, 2011
Showing with 9 additions and 54 deletions.
  1. +2 −0 Gemfile
  2. +7 −0 Gemfile.lock
  3. +0 −15 lib/bang.rb
  4. +0 −39 spec/lib/bang_spec.rb
View
2 Gemfile
@@ -32,6 +32,8 @@ gem 'hoptoad_notifier'
gem 'hashr'
gem 'arnold', :git => 'git://github.com/codebrawl/arnold.git', :branch => 'develop'
+gem 'bang', :git => 'git@gist.github.com:1232884.git'
+
group :test do
gem 'rspec-rails'
gem 'shoulda-matchers'
View
7 Gemfile.lock
@@ -24,6 +24,12 @@ GIT
selenium-webdriver (>= 0.0.27)
xpath (~> 0.1.3)
+GIT
+ remote: git@gist.github.com:1232884.git
+ revision: 798e950a55d535ddbb95fee8f6b87a959c7df88e
+ specs:
+ bang (0.1.0)
+
GEM
remote: http://rubygems.org/
specs:
@@ -286,6 +292,7 @@ PLATFORMS
DEPENDENCIES
arnold!
+ bang!
bson_ext (~> 1.3)
capybara!
coffee-script
View
15 lib/bang.rb
@@ -1,15 +0,0 @@
-module Bang
-
- def bang(attributes)
-
- [*attributes].each do |attribute|
- key, value = attribute
-
- define_method("#{key}!") do
- update_attribute(value || key, send(key))
- end
- end
-
- end
-
-end
View
39 spec/lib/bang_spec.rb
@@ -1,39 +0,0 @@
-require 'spec_config'
-require File.expand_path('lib/bang')
-
-class ObjectWithBang
- extend Bang
-end
-
-describe Bang do
-
- let(:object) do
- object = ObjectWithBang.new
- object.stubs(:attribute).returns(1)
- object.stubs(:get_attribute).returns(2)
- object
- end
-
- context 'with one banged attribute' do
-
- before { ObjectWithBang.send(:bang, :attribute) }
-
- it 'should save the attribute value' do
- object.expects(:update_attribute).with(:attribute, 1)
- object.attribute!
- end
-
- end
-
- context 'when the attribute and method names differ' do
-
- before { ObjectWithBang.send(:bang, :get_attribute => :attribute) }
-
- it 'should save the attribute value' do
- object.expects(:update_attribute).with(:attribute, 2)
- object.get_attribute!
- end
-
- end
-
-end

0 comments on commit 66da57f

Please sign in to comment.