Displaying 20 results from an estimated 5000 matches similar to: "Mocking ActiveResource"
2006 Nov 03
10
[PLUGIN] rspec_resource_generator - RESTful scaffold generator with RSpec specifications
rspec_resource_generator
========================
By Pat Maddox
Use this generator to generate RESTful scaffolding with RSpec specifications.
Syntax is exactly the same as the scaffold_resource generator:
./script/generate rspec_resource ModelName [field:type field:type]
When you run this generator, it will create a migration, model, and
model spec file.  In addition, it gives you a RESTful
2006 Aug 05
4
Can we use ActiveResource yet?
I need to split some information up between two servers, and wanted to
use REST for it.  I can write the REST server really easily...but I
don''t know how I can actually use it.  I downloaded Rails trunk to
mess with ActiveResource, but it seems that it doesn''t have create
functionality enabled yet.
Is it possible to use AR fully?  If not, what''s the best way to
consume
2007 Mar 14
5
What''s the new syntax for predicates?
@settings.should allow_publish_ip("127.0.0.1") fails with
undefined method `allow_publish_ip'' for #<#<Class:0x2f8fd48>:0x2f5a968>
@settings.should_allow_publish_ip("127.0.0.1") works fine
This is rspec 0.8.2.
http://rspec.rubyforge.org/documentation/expectations.html says that
matching arbitrary predicates is deprecated and to see
2007 Aug 14
4
Stubbing all methods
Mocha''s mock/stub framework has the ability to stub all methods on a  
mock given.  Does RSpec''s mocking framework have this ability?  And  
if not, is there some reason it shouldn''t be implemeneted?
Regards,
Scott
2007 Feb 23
4
How can I spec this? The method gets passed a block...
I''m using Jim Weirich''s Builder library.  The code I want to spec is
    xml.video do
      xml.id @video_id
      xml.views @views
      xml.date(@date.to_s) if @date
    end
I''d like to mock it, rather than asserting that the XML is the right
string.  I can do one spec:
  specify "should create a video tag" do
    @mock_builder.should_receive(:video)
   
2007 May 21
4
Just upgraded to 1.0.0, should render_text isn''t working for me
I finally got around to upgrading from 0.8.2 (!!).  I had a spec which
looked like
specify "should render abc123" do
  controller.should_render :text => "abc123"
  get :key
end
With 1.0.0, the new spec is
it "should render abc123" do
  get :key
  response.should render_text("abc123")
end
However it doesn''t work, giving me the error:
undefined
2007 Dec 11
6
Rspec 1.0.8 with Rails 2.0
Is it OK to go ahead and generate a Rails 2.0 project with RSpec 1.0.8? Am I
likely to run into problems?
Would it be best advised to wait or can I go ahead now?
Thanks,
Yitzhak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071212/c6fcea0f/attachment.html
2007 Jan 24
2
A spec where interaction-based testing breaks down... (at least for now)
Here are the specs:
context "Finding all the stylesheets available to a company" do
  setup do
    @mock_company = mock("company")
    @mock_company.stub!(:to_param).and_return "1"
    Stylesheet.stub!(:find)
  end
  def do_find
    Stylesheet.find_available_to @mock_company
  end
  specify "should convert the company into a parameter" do
   
2007 Mar 24
15
State Based vs. Behaviour Based Spec/Testing
I''ve notice that a project like Rubinius has both a spec & a test  
directory.  Rspec has only a spec directory.  Obviously I support  
BDD, but isn''t there also a place for state based/verification  
testing?  I sometimes sense that I *do* want to practice Test Driven  
Development. That is, I want some assurance that my production code  
will run as intended.  But I also
2007 Oct 21
18
plain text stories
Thanks to discussions on this list, suggestions from many of you and a
patch from Pat Maddox, we now have Plain Text User Stories in Story
Runner.
Read more:
http://blog.davidchelimsky.net/articles/2007/10/21/story-runner-in-plain-english
Cheers,
David
2007 Feb 22
7
We can''t 100% remove our unit tests from the database, can we?
I hope this isn''t too rambly.  This is sort of a brain dump of a
subject I''ve been thinking about for months as I''ve used RSpec.
Let''s say we''ve got a simple query method, that will find all the
users in the DB older than 18.  Our model could look like
class User < ActiveRecord::Base
  def self.find_older_than(age)
    find :all, :conditions =>
2007 Oct 15
14
Top Quoting?
Sort of off-topic and don''t mean to complain, but many on this list  
use top quoting. That works ok if you don''t quote the whole previous  
thread. However, I''m finding that scrolling forever to locate the  
reply on longer threads is getting tedious. What''s the rationale for  
top-quoting?
Thx.
2007 Oct 17
15
Any tips on teaching BDD with RSpec?
Hi
I hope this is not OT.  I''m training my replacement at work to do BDD  
Rails development.  He''s done a CS/maths degree but has no  
professional programming experience, so he''s never NOT done a project  
without BDD.  In a way I am jealous of his unspoilt situation :)
I''ve gone about things this way:
   * first teach him some Ruby (he did mainly Java at
2009 May 04
6
cucumber - when to stub/mock
I''m just curious about this, since my solution involved stubbing a  
call to GeoIp.
Is there a good rule of thumb for when you make exceptions to the ''no  
stubbing'' philosophy of Cucumber?
My step was: "Given I am accessing the site from Japan," but I can  
think of other situations - mostly when interacting with web services,  
that I''d probably
2009 Mar 19
6
[Cucumber 0.2] Failure to use should
I have a step definition like this:
Then "the account should be created" do
  account = Account.find_by_name("my shiny new account")
  p account.class
  account.should_not be_blank
end
When running this step, I got the error message:
Account(id: integer, name: string, state: string, next_renewal_at: date,
created_at: datetime, updated_at: datetime, full_domain: string,
2006 Jul 24
6
Mocking causes empty specification blocks
I''ve found myself mocking out a published api in my set-up method.
This has led to some contexts having a large set-up and empty
specifications.  As the mocks get auto-verified, the specification
blocks have nothing to do but serve as documentation.  Does this sound
bad?
Chris
2007 Jul 04
1
Edge Rails required for ActiveResource
Just wanted to make sure I''m not missing anything here... I''m trying
to use ActiveResource and I was trying to avoid using Edge Rails.
However, since ActiveResource depends on the edge version of
activesupport, I appear to be stuck going edge... have flailed around
for a while trying to get ActiveResource to work with 1.2.3 but it
just ain''t happening. Am I right?  Gotta
2008 Jan 18
5
How do I pass form values from POST controller specs?
Hi there
I just started my first Merb app and I''m running into some weird
things in Specs. When I do:
  describe "create action" do
    it "should create a new project" do
      project_params = {:name => ''bekkunin''}
      Project.should_receive(:create).with(project_params)
      controller, action = post(''/projects'', :project
2007 Oct 12
3
Strange mock_model behaviour with ActiveResource model
Hi,
I have two models in an app that inherit from ActiveResource::Base.
The scaffold controller tests for one of the models works fine, but
the other one dies when calling mock_model in the "handling GET
/fa_codes" spec:
Specifically, the call to mock model here:
 before do
    @fa_code = mock_model(FaCode)
    FaCode.stub!(:find).and_return([@fa_code])
  end
generates this failure:
2007 Jun 25
5
strange mock error
I''m testing using the rspec mocking framework and rspec 1.0.5 and I''m  
getting the following strange error:
#<Spec::Mocks::Mock:0x337f7c8> expected :set_defaults with (#<Service: 
0x19c4040 @name="Service_1023">, {"1"=>"1", "2"=>"2"}) but received  
it with (#<Service:0x19c4040