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
describe "/registrations/new" do | |
context "when deciding whether to show the register button" do | |
it "should hide the button when the user is under 13" do | |
# Code to set up the form elided | |
form.age = 12 | |
form.buttons[:submit].should_not be_visible | |
end | |
it "should show the button when the user is at least 13" do | |
# Code to set up the form elided |
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
public class A { | |
public X doingSomething() { | |
// code elided | |
y = doingOtherThing(z); | |
// code elided | |
} | |
public Y doingOtherThing(int z) { | |
// code elided | |
} |
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
public interface OtherThing { | |
Y doingOtherThing(int z); | |
} | |
public class A implements OtherThing { | |
public X doingSomething() { | |
return doingSomethingWith(this); | |
} | |
public X doingSomethingWith(OtherThing otherThing) { |
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
public interface OtherThing { | |
Y doingOtherThing(int z); | |
} | |
public class A { | |
private OtherThing otherThing; | |
public A(OtherThing otherThing) { | |
this.otherThing = otherThing; | |
} |
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
@Test | |
// SMELL This test has a structural name. I don't know the | |
// purpose of configuring these things, so I can't propose | |
// an intention-revealing name | |
public void configuresServiceNameTypeAndMechanismCorrectly throws Exception { | |
properties.setProperty("NegotiateAuthenticator.serviceName", "service"); | |
properties.setProperty("NegotiateAuthenticator.serviceNameType", "1.1"); | |
properties.setProperty("NegotiateAuthenticator.mechanism", "1.2"); | |
// If null causes this class to crash and burn, then either we have |
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
@Test | |
public void producesServerCredentialsOnDemand() throws Exception { | |
GSSCredential gssCredential = mock(GSSCredential.class); | |
// ignore manager.createName() if needed; I don't know how to | |
// type that in Mockito. In JMock, I'd write | |
// allowing(manager).createName(with(anything()), with(anything()), ...) | |
when(manager.createCredential((GSSName) anyObject(), anyInt(), (Oid) anyObject(), anyInt())).thenReturn(gssCredential); | |
NegotiateAuthenticator authenticator = new NegotiateAuthenticator(manager, properties); |
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
@posting = Posting.create!( | |
:title => "irrelevant title", | |
:content => "irrelevant content", | |
:queued_at => nil, | |
:published_at => nil | |
) |
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
describe PostingsController, "when displaying the new entry form" do | |
it "should include the publication queue in the model" do | |
Posting.stub!(:publication_queue).and_return([1,2,3]) | |
get 'new' | |
assigns[:queue].should == [1,2,3] | |
end | |
end |
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
describe PostingsController, "when displaying the new entry form" do | |
it "should include the publication queue in the model" do | |
anything_but_nil = Object.new | |
Posting.stub!(:publication_queue).and_return(anything_but_nil) | |
get 'new' | |
assigns[:queue].should equal(anything_but_nil) | |
end |
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
public abstract class FullRepositoryContractTestTemplate extends TestCase { | |
protected abstract Repository createRepository(); | |
private Repository repository; | |
protected void setUp() throws Exception { | |
repository = createRepository(); | |
} |