ghempton / camcorder Goto Github PK
View Code? Open in Web Editor NEWVCR not enough? Record arbitrary method invocations for later playback.
License: MIT License
VCR not enough? Record arbitrary method invocations for later playback.
License: MIT License
Hey @ghempton!
Thank you for developing this gem! It's been very useful so far. ๐
The only issue that I've found is that it shows this warning:
Deprecation Warnings:
The `:example_group` key in an example group's metadata hash is deprecated. Use the example group's hash directly for the computed keys and `:parent_example_group` to access the parent example group metadata instead. Called from /Users/etagwerker/.rvm/gems/ruby-2.2.1@sender/gems/camcorder-0.0.4/lib/camcorder/rspec.rb:9:in `yield'.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
1 deprecation warning total
This happens because Rspec has deprecated the usage of metadata[:example_group]
- See: rspec/rspec-rails#1035
I tried to write a PR to fix this but I couldn't find a decent way to keep the current tree structure for the recordings.
Instead of using the recursive code that generates the nested folder, I could write an implementation that uses metadata[:full_description]
to generate the recording file. The problem with this solution is that it wouldn't be backwards compatible. :(
What do you think?
Thanks!
I'm struggling to get this to work how I'd expect.
I have one ActiveJob
that loops through emails in an inbox, finds a record based on the contents of each email, performs a state machine transition on the record and then moves that email to an 'Archive' folder via uid_copy
and uid_store
. After the loop has finished, the job calls imap.expunge
, imap.logout
and imap.disconnect
.
The problem is that I need to run multiple tests for this worker, but the first time it runs it is archiving all mail and fails on subsequent tests.
How would I record once and perform multiple test?
For future people including me, if you get a Camcorder::ProxyPlaybackError
because it can't find a recording, it could be due to psych changes.
Because camcorder uses yaml to dump the args for each method call, if you upgrade to newer versions of psych that change the format (even slightly), you may have to rerecord your cassettes:
camcorder/lib/camcorder/proxy.rb
Lines 28 to 30 in f2591cf
For example, psych 2.0.17 to 2.1.0 introduced this change.
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> Psych::VERSION
=> "2.0.17"
irb(main):003:0> YAML.dump "078123423"
=> "--- 078123423\n...\n"
irb(main):004:0> require 'digest'
=> true
irb(main):005:0> Digest::MD5.hexdigest(YAML.dump("078123423"))
=> "9ad7bbd6de568e136bf7f30105dcbb8d"
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> Psych::VERSION
=> "2.1.0"
irb(main):003:0> YAML.dump "078123423"
=> "--- '078123423'\n"
irb(main):004:0> require 'digest'
=> true
irb(main):005:0> Digest::MD5.hexdigest(YAML.dump("078123423"))
=> "884af5b4d3e7878a214262fca58a9ae6"
See also: ManageIQ/manageiq-gems-pending#344
Given the code below:
require 'net/imap'
require 'camcorder'
Camcorder.intercept_constructor(Net::IMAP)
imap = Net::IMAP.new('outlook.office365.com', 993, ssl: true)
imap.login('[email protected]', 'password')
imap.select('INBOX')
imap.search(%w(NOT FLAGGED SINCE 21-Dec-2016))
imap.disconnect
I get the following exception:
camcorder-0.0.5/lib/camcorder/proxy.rb:42:in `_record': undefined method `record' for nil:NilClass (NoMethodError)
from camcorder-0.0.5/lib/camcorder/proxy.rb:52:in `method_missing'
from cam_test.rb:7:in `<main>'
Is there more setup needed?
I'm trying this on irb console i.e
2.2.0 :001 > require 'gmail'
2.2.0 :002 > require 'camcorder'
2.2.0 :003> imap = Camcorder::Proxy.new(Net::IMAP,'imap.gmail.com', 993, true, nil, false)
this gives successful response as---- --
"Camcorder::Proxy:0x00000001c5c028 @klass="imap.gmail.com", @init_args=[993, true, nil, false], @recorder=Net::IMAP, @side_effects="e6bd2fbfc8ef76c22f26bd5758f20098" "
but after that I'm requesting for login i.e
2.2.0 :004 > imap.login('amolishere', 'amol123')
then i got response as ----------
NoMethodError: undefined method name' for "imap.gmail.com":String from /home/amol/.rvm/gems/ruby-2.2.0/gems/camcorder-0.0.4/lib/camcorder/proxy.rb:41:in
_record'
from /home/amol/.rvm/gems/ruby-2.2.0/gems/camcorder-0.0.4/lib/camcorder/proxy.rb:52:in method_missing' from (irb):4 from /home/amol/.rvm/rubies/ruby-2.2.0/bin/irb:11:in
Please help me to solve this?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.