Created
December 2, 2010 17:12
-
-
Save danreedy/725685 to your computer and use it in GitHub Desktop.
Your mission: Make these RSpec tests pass I will be running these tests against Ruby 1.9.2, so ensure that your environment is similar. You can learn about RSpec by visiting http://rspec.info/. If you want a jump start for the user.rb file you can look
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'user' | |
describe User, "#roles" do | |
it "returns 'User' for a new user" do | |
user = User.new | |
user.roles.include?("User").should be(true) | |
end | |
it "returns 'User' and 'Moderator' if user is a moderator" do | |
user = User.new | |
user.make_moderator | |
user.roles.include?("User").should be(true) and user.roles.include?("Moderator").should be(true) | |
end | |
it "returns 'User' and 'Editor' if user is an editor" do | |
user = User.new | |
user.make_editor | |
user.roles.include?("User").should be(true) and user.roles.include?("Editor").should be(true) | |
end | |
it "returns 'User' and 'Administrator' if user is an administrator" do | |
user = User.new | |
user.make_administrator | |
user.roles.include?("User").should be(true) and user.roles.include?("Administrator").should be(true) | |
end | |
end | |
describe User, "#bitmask" do | |
it "returns 8 for new user" do | |
user = User.new | |
user.bitmask.should == 8 | |
end | |
it "returns 12 if user is a moderator" do | |
user = User.new | |
user.make_moderator | |
user.bitmask.should == 12 | |
end | |
it "returns 10 if user is an editor" do | |
user = User.new | |
user.make_editor | |
user.bitmask.should == 10 | |
end | |
it "returns 9 if user is an administrator" do | |
user = User.new | |
user.make_administrator | |
user.bitmask.should == 9 | |
end | |
end | |
describe User, "#make_<role>" do | |
it "should raise an argument error on a role that doesn't exist and display error 'Provided role does not exist'" do | |
user = User.new | |
lambda { user.make_root }.should raise_error(ArgumentError, "Provided role does not exist") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment