Skip to content

Instantly share code, notes, and snippets.

@dhh
Created March 29, 2011 19:09
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dhh/893027 to your computer and use it in GitHub Desktop.
Save dhh/893027 to your computer and use it in GitHub Desktop.
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
end
# vs
test "GET current (or preferably an explanation WHY we are testing it)" do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
assert respond_with(:success)
assert_equal "#{notices(:permanent).id}", cookies[:hidden_notices]
assert_template 'notices/current'
end
@rubypanther
Copy link

@mattwaynne: I don't think it's a matter of word choice at all. You're still replacing his opinion with lack of knowledge.

He's been quite clear about it. In fact, that's largely his point: it's heavily used because of a cargo cult. The question you'd have him ask is exactly the question to which his answer brought us all here.

@igbanam
Copy link

igbanam commented Jul 28, 2011

@jrwest there is no need for the r variable.

describe "GET current" do
  it "does the same thing as your example" do
    @request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
    get :current, :format => 'js'

    response.should respond_with(:success) }
    response.should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
    response.should render_template('notices/current') }
  end
end

But in the end still it comes down to taste.

@justinko
Copy link

@StevenGerrard

You have great code ... I love it

Thanks bro!

@cameron-martin
Copy link

I can't take a design opinion seriously from the person who built rails.

Plus all the things that other people have pointed out about these examples being no way near equivalent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment