# Rspec2+Factory girl, how to test a change?

**URL:** <https://www.ruby-forum.com/t/rspec2-factory-girl-how-to-test-a-change/202590>\
**Category:** Rails\
**Created:** [February 2, 2011, 2:57am UTC](https://www.ruby-forum.com/t/rspec2-factory-girl-how-to-test-a-change/202590 "2011-02-02T02:57:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 2, 2011, 2:57am UTC](https://www.ruby-forum.com/t/rspec2-factory-girl-how-to-test-a-change/202590/1 "2011-02-02T02:57:47Z")

</div>

Hi, I’m new on tests but trying to test the following method, but it  
gives me an error message about “nil is not a symbol”.

# job.rb

==  
def publish(url)  
update\_attributes(:available =\> true, :locked =\> false)  
tweet(url)  
end

# job\_spec.rb

===  
it “should publish a job” do  
@job = Factory(:job, :available =\> false)  
lambda { @job.publish }.should  
change(@job.available).from(false).to(true)  
end

# error

==

1. Job Job publish should publish a job  
Failure/Error: lambda { @job.publish }.should  
change(@job.available).from(false).to(true)  
nil is not a symbol
# ./spec/models/job\_spec.rb:128:in `block (3 levels) in \<top

(required)\>’

Finished in 1.12 seconds  
47 examples, 1 failure, 4 pending

any idea?

---

<div class="post-metadata">

**Author:** ![tenshi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tenshi](https://www.ruby-forum.com/u/tenshi)\
**Post date:** [February 2, 2011, 10:48am UTC](https://www.ruby-forum.com/t/rspec2-factory-girl-how-to-test-a-change/202590/2 "2011-02-02T10:48:41Z")

</div>

How does your factory declaration look like?

---

<div class="post-metadata">

**Author:** ![tenshi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tenshi](https://www.ruby-forum.com/u/tenshi)\
**Post date:** [February 2, 2011, 6:11pm UTC](https://www.ruby-forum.com/t/rspec2-factory-girl-how-to-test-a-change/202590/3 "2011-02-02T18:11:08Z")

</div>

In this block:  
lambda { @job.publish }.should  
change(@job.available).from(false).to(true)  
end

try putting the arguments to the change method in curly braces:

lambda { @job.publish }.should  
change{@job.available}.from(false).to(true)  
end

If you pass the method parameters, which is what it expects with  
parantheses, it expects two arguments, the second of which would be  
the method name in the form of a symbol, which I think explains the  
‘nil is not a symbol’ error you’re getting.

By the way, if you’re upgrading RSpec1 to RSpec2, there’s a cheat  
sheet of changes here:

> **[RSpec 2 changes from RSpec 1](http://snyderscribbles.blogspot.com/2011/01/rspec-2-changes-from-rspec-1.html)**
>
> A quick list of changes we've discovered in moving from RSpec 2 to RSpec 1. Some may produce deprecation warnings -- other changes simply...
