mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 19:42:32 -05:00
3e50313fdc
Since rspec-rails 3, the default installation creates two helper files: * `spec_helper.rb` * `rails_helper.rb` `spec_helper.rb` is intended as a way of running specs that do not require Rails, whereas `rails_helper.rb` loads Rails (as Discourse's current `spec_helper.rb` does). For more information: https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#default-helper-files In this commit, I've simply replaced all instances of `spec_helper` with `rails_helper`, and renamed the original `spec_helper.rb`. This brings the Discourse project closer to the standard usage of RSpec in a Rails app. At present, every spec relies on loading Rails, but there are likely many that don't need to. In a future pull request, I hope to introduce a separate, minimal `spec_helper.rb` which can be used in tests which don't rely on Rails.
38 lines
956 B
Ruby
38 lines
956 B
Ruby
require 'rails_helper'
|
|
require 'email'
|
|
|
|
describe Enum do
|
|
let(:enum) { Enum.new(:jake, :finn, :princess_bubblegum, :peppermint_butler) }
|
|
|
|
describe ".[]" do
|
|
it "looks up a number by symbol" do
|
|
expect(enum[:princess_bubblegum]).to eq(3)
|
|
end
|
|
|
|
it "looks up a symbol by number" do
|
|
expect(enum[2]).to eq(:finn)
|
|
end
|
|
end
|
|
|
|
describe ".valid?" do
|
|
it "returns true if a key exists" do
|
|
expect(enum.valid?(:finn)).to eq(true)
|
|
end
|
|
|
|
it "returns false if a key does not exist" do
|
|
expect(enum.valid?(:obama)).to eq(false)
|
|
end
|
|
end
|
|
|
|
describe ".only" do
|
|
it "returns only the values we ask for" do
|
|
expect(enum.only(:jake, :princess_bubblegum)).to eq({ jake: 1, princess_bubblegum: 3 })
|
|
end
|
|
end
|
|
|
|
describe ".except" do
|
|
it "returns everything but the values we ask to delete" do
|
|
expect(enum.except(:jake, :princess_bubblegum)).to eq({ finn: 2, peppermint_butler: 4 })
|
|
end
|
|
end
|
|
end
|