username into the right place when fetching the
item name" do
i = Item.new(:description => 'foo User_1 bar')
User.stub!(:find).with('1').and_return( mock_model(User, :name => 'a
name') )
i.name.should == 'foo a name bar'
end
On Thu,
Some of my specs fail after adding the rails "memoize" feature to model some
model methods, producing the error "Can't modify frozen class/module" (these
specs all passed before). This only happens if I try to use "and_return"
within my spec, and those returned values affect the output of the meth
Beyond that, without spending more time going
over the details of this particular method, I'll just say that I think we
are in fact in agreement about the overall testing strategy and
considerations you described :)
On Tue, Jul 21, 2009 at 10:22 AM, Stephen Eley wrote:
> On Tue, Jul 21, 20
nks!
On Tue, Jul 21, 2009 at 9:24 AM, David Chelimsky wrote:
> On Tue, Jul 21, 2009 at 8:15 AM, Barun Singh wrote:
> > I completely agree that testability is a huge benefit, and if changing
> code
> > structure makes that easier then I'm all for it. My statement was only
ast this is what it seems like to me; if I'm missing something
glaringly obvious (possible) please do point it out to me.
Hopefully with this concrete example of a set of specs that you've provided
my question is a bit clearer.
On Tue, Jul 21, 2009 at 5:49 AM, David Chelimsky wrote:
>
m out in testing the outer method then refactoring hasn't made
any tests any easier either).
Anyway, if anyone is left reading who hasn't gotten bogged down in this
email chain, and has any other suggestions, please feel free to let me
know. thanks..
On Tue, Jul 21, 2009 at 2:31 AM, St
hat Mocha is available to assist with this, but I'd
rather not switch to an entirely different framework for mocks & stubs just
because of this one method...
On Mon, Jul 20, 2009 at 11:45 PM, Stephen Eley wrote:
> On Mon, Jul 20, 2009 at 8:33 PM, Barun Singh wrote:
> >
> &
I have a recursive class-level method that I'd like to spec. the logic of
it essentially does something like this:
def self.mymethod(inputs)
If x =
x.do_something
else
mymethod(inputs)
end
end
I want to find a way to write a spec for this method that does both of these
things
Solved; I just remembered that after installing Textmate this time I forgot
to set the PATH shell variable. After setting that, textmate is able to
find all the files it needs.
On Sun, Jul 5, 2009 at 8:48 PM, Barun Singh wrote:
> I've set up a new environment where I'm runnin
I've set up a new environment where I'm running Rails 2.3.2, and have the
rspec 1.2.7 and rspec-rails 1.2.7.1 gems installed. I can run spec commands
from the console without a problem. However, if I try to run a spec via
textmate (command-R or command-shift-R), I get an error saying that the
bun
Suppose a User has many Items, and I want to spec that when a user is
destroyed its associated items are destroyed. I'm seeing some unexpected
behavior:
describe User do
before(:each) do
@user = create_user # helper method that actually creates & saves a
user
@item = create_item
@
alidation since that is tested elsewhere already. But, not having found a
way to do that I am now using more realistic mocks so that the
new_widget.save! method does not raise an error anymore.
On Mon, May 11, 2009 at 1:48 PM, Matt Wynne wrote:
>
> On 11 May 2009, at 17:05, Barun Singh
Suppose a "User" has many "widgets", and that we have a method in the User
class that does something like:
def update_widgets
x = ... code to do some calculations ...
if x > 5
new_widget = widgets.new
new_widget.save!
else
widgets.first.destroy
end
widgets.reload
end
How wo
I've set up my cucumber.yml file so that i have a default profile and a
selenium profile as described at the end of this wiki page:
http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium
This works great when I run 'cucumber' from the command line, but I don't
seem to be able to run a s
20, 2009 at 3:10 PM, Barun Singh wrote:
> I'm trying to use Cucumber with Selenium to test my app. I have a method
> called "login_as" defined as follows:
>
> def login_as(user, password)
> visit new_session_path
> fill_in "username", :wit
I'm trying to use Cucumber with Selenium to test my app. I have a method
called "login_as" defined as follows:
def login_as(user, password)
visit new_session_path
fill_in "username", :with => user.username
fill_in "password", :with => password
click_button('Go')
response.bo
ng"
>
> subject { new_foo }
>
> def do_action
>subject.save!
> end
> end
>
> describe Foo, "when do_something is called" do
> it_should_behave_like "do_something"
>
> subject { new_foo }
>
> def do_action
>subjec
I use this sort of technique at time to keep my specs dry, simple and
behavior-driven at the same time, but I find it can make the spec files a
bit hard to read through so I try not to use it unless it is really
needed...
On Thu, Apr 16, 2009 at 1:25 PM, Barun Singh wrote:
> In many of my m
In many of my models, I have callback methods like this:
class MyModel < ActiveRecord::Base
before_save :do_something
def do_something
some code here...
end
end
The do_something method is a public method that is sometimes called on its
own, and also called whenever the model is sav
s could be refactored.
Thanks (and sorry for the non-issue problem).
On Fri, Apr 10, 2009 at 5:57 PM, David Chelimsky wrote:
> On Fri, Apr 10, 2009 at 6:55 PM, Ashley Moran
> wrote:
> > On 10 Apr 2009, at 22:27, Barun Singh wrote:
> >>
> >> This may work fo
iour, then your specs shuould still pass. In your case
> they would not.
>
> Cheers
> Nigel
>
> 2009/4/11 Barun Singh
>
>> A model I'm trying to spec looks something like this
>>
>> class MyClass
>> def methodA
>> do some stuff
>
A model I'm trying to spec looks something like this
class MyClass
def methodA
do some stuff
methodB
end
def methodB
do some stuff
end
end
my spec looks something like this:
x = MyClass.new
x.should_receive(:methodB)
lambda{ x.methodA }
In the situation outlined above, the
22 matches
Mail list logo