mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
make Enum#valid? specs test the right thing
This commit is contained in:
parent
9858beb6af
commit
28bc5a6c89
@ -2,39 +2,37 @@ require 'spec_helper'
|
|||||||
require 'email'
|
require 'email'
|
||||||
|
|
||||||
describe Enum do
|
describe Enum do
|
||||||
|
|
||||||
let(:enum) { Enum.new(:jake, :finn, :princess_bubblegum, :peppermint_butler) }
|
let(:enum) { Enum.new(:jake, :finn, :princess_bubblegum, :peppermint_butler) }
|
||||||
|
|
||||||
context ".[]" do
|
describe ".[]" do
|
||||||
it "allows us to look up a number by symbol" do
|
it "looks up a number by symbol" do
|
||||||
enum[:princess_bubblegum].should == 3
|
enum[:princess_bubblegum].should == 3
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows us to look up a symbol by number" do
|
it "looks up a symbol by number" do
|
||||||
enum[2].should == :finn
|
enum[2].should == :finn
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context ".valid?" do
|
describe ".valid?" do
|
||||||
it "returns true for a value that exists" do
|
it "returns true if a key exists" do
|
||||||
enum.valid?(4).should be_false
|
enum.valid?(:finn).should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true for a key that doesn't exist" do
|
it "returns false if a key does not exist" do
|
||||||
enum.valid?(:ice_king).should be_false
|
enum.valid?(:obama).should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context ".only" do
|
describe ".only" do
|
||||||
it "returns only the values we ask for" do
|
it "returns only the values we ask for" do
|
||||||
enum.only(:jake, :princess_bubblegum).should == {jake: 1, princess_bubblegum: 3}
|
enum.only(:jake, :princess_bubblegum).should == { jake: 1, princess_bubblegum: 3 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context ".except" do
|
describe ".except" do
|
||||||
it "doesn't return the values we don't want" do
|
it "returns everything but the values we ask to delete" do
|
||||||
enum.except(:jake, :princess_bubblegum).should == {finn: 2, peppermint_butler: 4}
|
enum.except(:jake, :princess_bubblegum).should == { finn: 2, peppermint_butler: 4 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user