Permalink
Browse files

Add Rake and update RSpec dependency. Update custom matcher.

  • Loading branch information...
1 parent 56233d0 commit 03f93e350723a02b012b87de2f2ddb8baa90f43f @tristandunn tristandunn committed Mar 21, 2012
Showing with 41 additions and 25 deletions.
  1. +11 −9 Gemfile.lock
  2. +2 −1 bartender.gemspec
  3. +1 −0 spec/spec_helper.rb
  4. +27 −15 spec/support/have_configuration_option_matcher.rb
View
@@ -13,14 +13,15 @@ GEM
metaclass (0.0.1)
mocha (0.10.4)
metaclass (~> 0.0.1)
- 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)
+ rake (0.9.2.2)
+ rspec (2.9.0)
+ rspec-core (~> 2.9.0)
+ rspec-expectations (~> 2.9.0)
+ rspec-mocks (~> 2.9.0)
+ rspec-core (2.9.0)
+ rspec-expectations (2.9.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.9.0)
yajl-ruby (1.1.0)
yard (0.7.5)
@@ -31,5 +32,6 @@ DEPENDENCIES
bartender!
bourne (= 1.1.1)
bundler (>= 1.1.0)
- rspec (= 2.8.0)
+ rake (= 0.9.2.2)
+ rspec (= 2.9.0)
yard (= 0.7.5)
View
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "bourne", "1.1.1"
s.add_development_dependency "bundler", ">= 1.1.0"
- s.add_development_dependency "rspec", "2.8.0"
+ s.add_development_dependency "rake", "0.9.2.2"
+ s.add_development_dependency "rspec", "2.9.0"
s.add_development_dependency "yard", "0.7.5"
end
View
@@ -7,4 +7,5 @@
RSpec.configure do |config|
config.mock_with :mocha
+ config.include(BartenderHelper)
end
@@ -1,23 +1,35 @@
-RSpec::Matchers.define :have_configuration_option do |option|
- match do |configuration|
- configuration.should respond_to(option)
+module BartenderHelper
+ class ConfigurationOption
+ def initialize(option)
+ @option = option
+ end
+
+ def matches?(configuration)
+ @configuration = configuration
+
+ @configuration.respond_to?(@option).should == true
+
+ @configuration.__send__(@option).should == @default if instance_variables.include?("@default")
- if instance_variables.include?("@default")
- configuration.send(option).should == @default
+ @configuration.__send__(:"#{@option}=", "value")
+ @configuration.__send__(@option).should == "value"
end
- configuration.__send__(:"#{option}=", "value")
- configuration.__send__(option).should == "value"
- end
+ def default(default)
+ @default = default
+
+ self
+ end
- chain :default do |default|
- @default = default
+ def failure_message
+ description = "expected #{@configuration} to have"
+ description << " configuration option #{@option.inspect}"
+ description << " with a default of #{@default.inspect}" if instance_variables.include?("@default")
+ description
+ end
end
- failure_message do
- description = "expected #{subject} to have"
- description << " configuration option #{option.inspect}"
- description << " with a default of #{@default.inspect}" if instance_variables.include?("@default")
- description
+ def have_configuration_option(option)
+ ConfigurationOption.new(option)
end
end

0 comments on commit 03f93e3

Please sign in to comment.