Different initial states usually require different setups • Tends to be focused on class and method level tests • It’s missing some functionality (sort of)
do tests_dir = Dir.pwd + "/tmp/spec/" ! if File.exists? tests_dir FileUtils.rm_rf tests_dir end ! FileUtils.mkdir_p tests_dir ! FileUtils.cp_r Dir.pwd + "/spec/fixtures/input/.", tests_dir end ! after(:each) do tests_dir = Dir.pwd + "/tmp/spec/" ! if File.exists? tests_dir FileUtils.rm_rf tests_dir end end ! describe "#process_file" do ! it "manages to update multiple files" do files = Dir.glob Dir.pwd + "/tmp/spec/*.{h,m}" files.each do |f| Fixbraces.process_file f end ! result = `diff -r --brief #{Dir.pwd + "/tmp/spec/"} #{Dir.pwd + "/spec/fixtures/expected/"}` expect(result).to eq "" end
mock = [OCMockObject mockForClass:[SomeClass class]] ! // specify a return when a method is called ! [[[mock stub] andReturn:@"Hello"] greet:[OCMArgAny]; ! // You can now test against it. expect([stub greet]).to.equal(@"Hello");
= [OCMockObject mockForClass:[SomeClass class]] ! // Create a expectation [[mock expect] greet:[OCMArg any]]; ! // Do something that might call the method expect([stub greet]).to.equal(@"Hello"); ! // verify that it is called expect([mock verify]).toNot.raiseAny();
you need to know the endpoint, and the content of the response. • It is useful if the results change, you just need to keep it up to date. • In the context of testing with expectations, it makes sense. i.e. I do something, and I can text against the eventual expected value.