I'm new to ruby and just learning cucumber and rspec. I have some examples(tests) that need to fake a directory structure and file grouping, fake a properly formatted json file and fake a ruby-git interraction (git.fetch, git.merge).
I've been reading about mocks and stubs but still feeling a little in the dark. Given some example tests like the following describe "#update_repo" do it "should update the repository without errors" do git = double('git') # How do I mock this so that the Git object is "faked" and the calls to fetch/merge don't cause an error without actually talking to a remote repo lambda { @app.update_repo git }.should_not raise_error end end describe "#check_json" do it "should check that the har files are valid json if they exist" do # In the real context @app.files contains a list of har json files # How do I mock the json files on the file system test_contents = @app.organize_test_contents @app.files # Can I mock test_contents or use a fixture? result = @app.check_json test_contents result.should =~ /JSON Valid/ end end What are some recommended ways for faking data, faking file systems, faking network interractions -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users