Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Peter Mellett
@wadtech
I know how you feel. The secret for me is 'why' not 'what', coupled with good naming it really helps.
Also I'm so bad at code reading JavaScript it's not funny
Philipp Fehre
@sideshowcoder
Yeah true, JavaScript is not a great language to come back too after a couple of weeks
Rashid Jilani
@rashidjilani_twitter
guys trying to install canned on ubuntu preice 64 but no luck

npm ERR! Linux 3.2.0-101-virtual
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "canned"
npm ERR! node v5.11.0
npm ERR! npm v3.8.6
npm ERR! path /managedaccountpoc/trp_poc/node_modules/.staging/canned-47567533/spec/test_responses/_a?name=Batman&age=30.get.html
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall open

npm ERR! EPROTO: protocol error, open '/managedaccountpoc/trp_poc/node_modules/.staging/canned-47567533/spec/test_responses/_a?name=Batman&age=30.get.html'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! /managedaccountpoc/trp_poc/npm-debug.log

Peter Mellett
@wadtech
Hi Rashid, did you have any luck? I've not come across EPROTO before with npm. Could it be directory permissions?
Rob Styles
@mmmmmrob
Hi, just found canned while looking for a way to mock out a 3rd party api in my mocha-casperjs functional tests.
Does canned have any methods for setting or verifying expectations? I'd like to test that my app posts the right thing to the 3rd party api when the UI gets prodded.
Peter Mellett
@wadtech
You can set responses and status codes based on received headers, body and url params so you could ensure that a call is made correctly in your test by returning yourself a status code or known response that can be confirmed in your test.
Rob Styles
@mmmmmrob
This message was deleted
This will return the 200 success: true response if the 'required' parameter is provided with that value, otherwise you get 500 success: false
So for your example you want to annotate the mocked return bodies in that fashion and compare against what you think your app sends to the API (awkward if dynamic, but presumably there's some sort of fixture or mocking to have a reliable lastPostTo result)
Rob Styles
@mmmmmrob
I can't see how that approach allows me to assert that my app made a call at all? Maybe my app made the wrong call, and swallowed the 500, or maybe it made no call at all.
Peter Mellett
@wadtech
Well your test suite in your app will deal with the expectations, canned only needs to respond to your parameters and return the correct response (this will let you make those assertions and infer that you must have made the correct call in your app to receive the correct response from canned)
Rob Styles
@mmmmmrob
I'm driving a UI with functional tests, hence the need to use a mock api server rather than just nock. My tests can inspect the response from the mock api as they're not inside the app (integration/functional tests) and the app shows a UI response that may or may not change.
How can my tests ensure the api was called when they can't see inside the app?
Does canned have any mechanism for inspecting the calls that were made to it?
Peter Mellett
@wadtech
I think I misunderstood your gist from before. Canned can accept a custom logger, so you could inject something that gives you the lastPostTo method maybe?
But natively I don't think it has any support for what you need
Rob Styles
@mmmmmrob
OK, thanks
Peter Mellett
@wadtech
Sorry for the misunderstanding :-)
pcdwr
@pcdwr
Has anyone attempted to make this project Windows friendly? I need to use it in both OS X and Windows and I am running into a number of problems.
Philipp Fehre
@sideshowcoder
There has been some work towards what you are trying @pcdwr but not much, what kind of problems are you seeing?
pcdwr
@pcdwr
There appear to be issues with the regular expressions parsing files that have special characters and they use the //! params syntax. I have an index.get.json file that has several results depending on the query params. The server works perfectly on OS X but I have issues on Windows. I am still playing with it but I know if I have to limit the file to one result and remove any single quotes from the body of the JSON to keep from getting parsing errors on Windows.
I apologize for the long post. I will try to get some specific examples today. I have forked the project so I can play with it but unfortunately I can't pull it to Windows and write tests because of the invalid file names.
Philipp Fehre
@sideshowcoder
Yes the invalid file names thing is a pain, the feature has been deprecated for quite a while so possibly we can just remove it and remove the files as well and make live on windows easier, at least for dev. I'm happy to have a PR in this regard!
I'm not aware of any regex difference between windows and MacOS os I'm quite confused about this, if you could create a minimal case file that would be so helpful, feel free to open an issue about it
pcdwr
@pcdwr
I successfully removed the ability to use file names for query params but I still have lots of issues developing on Windows with make. Are you interested in a pull request that just removes the file name issue? If not, I will create one big one when I get a successful Windows development environment. Our problem with Windows appears to have gone away with the forked repo. Any chance what's on NPM is not current?
Kefeng Deng
@kdeng
Hello everyone, I am new there. Currently, I am experiencing the error about CORS_ENABLE (sideshowcoder/canned#23), just wonder is there anyone see this error before? cheers
Philipp Fehre
@sideshowcoder
Hey @kdeng are your files setup correctly? by that I mean does the example folder run? Also what version of canned are you on?
Eric Gonzalez
@egonzalez777
Hello everyone.

Quick question on how to create a resource that is random?

Let's say I have:

/resource1/:dynamic1/inner-resource1

How do I setup the folder for :dynamic1 resource?

Philipp Fehre
@sideshowcoder
That is not possible as of right now, as far as I'm aware, you would mock a specific instance of that, aka /res1/mydynamicexample/inner
Eric Gonzalez
@egonzalez777
That is what I thought.
Ok thanks!
Philipp Fehre
@sideshowcoder
Happy to help, even if it is not really helping I guess :D
I'm open to suggestions on how to handle that.
Eric Gonzalez
@egonzalez777
I would say, like you have for the identifier key :id which is set for any.get.json, you can have an any folder that follows the resource pattern.
The algorithm would swap the value, and map it to the any folder following the resource pattern.
Philipp Fehre
@sideshowcoder
makes sense to me yes :) currently not implemented sadly but would be a nice piece of work. If you like outline in a Issue on github and mark as a new feature and hopefully we can get that in
Alphonse Delaporte
@Alphon_sh_twitter
Hey there !
Trying to setup canned, but always getting not found error when trying to curl on my local :/
I must have forgot something but don't know what :)
Alphonse Delaporte
@Alphon_sh_twitter
Any help ? :/
Philipp Fehre
@sideshowcoder
What's your setup? Did you try to curl 127.0.0.1:port as well as local host? Did you try 0.0.0.0:port ... Sometimes routes are messed up so local host fails when hosts file is messed up by other tools
Khaled
@kkebb
is canned dockerized?
also, can we run multiple instances of canned
Khaled
@kkebb
?