[rspec-users] using fakeweb only if flag is given

David Chelimsky dchelimsky at gmail.com
Thu Mar 1 11:51:12 UTC 2012


On Mar 1, 2012, at 4:00 AM, bernhard stoecker wrote:

> Hi,
> 
> I'm using the gem fakeweb to simulate the comunication between my
> ruby-app and different other apps when running my rspecs. The advantage
> is, that the specs work much faster and it is not nessessary that the
> other apps are currently avalable. But for testing the integration of my
> app, it is of course nessessary to check weather my component is
> compatible with the others. What im searching is something like a flag
> to the comment bundle exec rspec spec e.g. bundle exec rspec spec --fake
> do decide to run fakeweb or not. Does something like this exist and if
> so how can I realize this.

You could use tags for this:

# CLI
rspec --tags allow_net_connect

# spec/spec_helper.rb
RSpec.configure do |c|
  c.treat_symbols_as_metadata_keys_with_true_values = true
end

# spec
describe "integration with real service", :allow_web_connect do
  # ...
end

HTH,
David


More information about the rspec-users mailing list