Skip to content

Instantly share code, notes, and snippets.

@jcutrell
Forked from r00k/a1.md
Last active August 29, 2015 14:20
Show Gist options
  • Save jcutrell/2bebd6f66e0553ab1b00 to your computer and use it in GitHub Desktop.
Save jcutrell/2bebd6f66e0553ab1b00 to your computer and use it in GitHub Desktop.

Answer to Question 1

That code violates Tell, Don't Ask..

You could also say it exhibits the feature envy smell.

Furthermore, "checking systems" shouldn't, necessarily, sound an alarm. The method both checks and responds to a state, and therefore has side effects. You might prefer to ONLY check the system without sounding an alarm.

(Violating Tell, Don't Ask and having feature envy are pretty much two sides of the same coin.)

Question 2

What testing code smell do we have here?

describe "#full_name" do
  it "returns a concatenated full name" do
    user = User.new
    allow(user).to receive(:first_name).and_return("John")
    allow(user).to receive(:last_name).and_return("Smith")
    
    expect(user.full_name).to eq("John Smith")
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment