spec/helper.rb in flipper-0.3.0 vs spec/helper.rb in flipper-0.4.0
- old
+ new
@@ -9,17 +9,17 @@
log_path.mkpath
require 'rubygems'
require 'bundler'
-Bundler.require(:default, :test)
+Bundler.setup(:default)
require 'flipper'
-Logger.new(log_path.join('test.log'))
-
RSpec.configure do |config|
+ config.fail_fast = true
+
config.filter_run :focused => true
config.alias_example_to :fit, :focused => true
config.alias_example_to :xit, :pending => true
config.run_all_when_everything_filtered = true
@@ -40,7 +40,41 @@
end
it "has a value" do
percentage = described_class.new(19)
percentage.value.should eq(19)
+ end
+
+ it "raises exception for value higher than 100" do
+ expect {
+ described_class.new(101)
+ }.to raise_error(ArgumentError, "value must be a positive number less than or equal to 100, but was 101")
+ end
+
+ it "raises exception for negative value" do
+ expect {
+ described_class.new(-1)
+ }.to raise_error(ArgumentError, "value must be a positive number less than or equal to 100, but was -1")
+ end
+end
+
+shared_examples_for 'a DSL feature' do
+ it "returns instance of feature" do
+ feature.should be_instance_of(Flipper::Feature)
+ end
+
+ it "sets name" do
+ feature.name.should eq(:stats)
+ end
+
+ it "sets adapter" do
+ feature.adapter.should eq(dsl.adapter)
+ end
+
+ it "sets instrumenter" do
+ feature.instrumenter.should eq(dsl.instrumenter)
+ end
+
+ it "memoizes the feature" do
+ dsl.feature(:stats).should equal(feature)
end
end