I do have it in my spec_helper, does it have to be inside the RSpec.config
block?
On Wed, Sep 26, 2012 at 11:17 PM, Andy Lindeman wrote:
> On Wed, Sep 26, 2012 at 10:25 PM, S Ahmed wrote:
> > How can I do this?
>
> If it's truly something that just needs to be loaded onc
n the dependancies of Myclass.
On Sun, Sep 23, 2012 at 8:31 PM, David Chelimsky wrote:
> On Sun, Sep 23, 2012 at 7:55 PM, S Ahmed wrote:
> > I have a class that takes a class that inherits from activerecord as a
> > parameter, e.g.:
> >
> > class SomeModel < ActiveRecord:
I have a class that takes a class that inherits from activerecord as a
parameter, e.g.:
class SomeModel < ActiveRecord::Base
end
class MyClass
attr_accessor :model
def initialize(model)
@model = model
end
end
The class MyClass will then iterate over the Models attributes etc.
Also I
I tried adding this to my application.rb:
config.generators do |g|
g.view_specs false
g.helper_specs false
end
But it didn't stop the generator from creating view/helper specs.
What am I doing wrong?
Also also tried doing this the configuration section:
config.view_specs = false
config.he
Other than jumping into the codebase myself, I was wondering if anyone has
done a high-level (or better yet low level) write-up on how rspec works
under the covers?
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listin
sky wrote:
> On Mon, Apr 23, 2012 at 12:26 PM, S Ahmed wrote:
> > My folder structure is as follows:
> >
> > /myapp/
> > /myapp/lib/class1.rb
> >
> > /myapp/rspec/spec_helper.rb
> > /myapp/rspec/lib/class1_spec.rb
> >
> > My spec_helper ha
My folder structure is as follows:
/myapp/
/myapp/lib/class1.rb
/myapp/rspec/spec_helper.rb
/myapp/rspec/lib/class1_spec.rb
My spec_helper has:
require 'rubygems'
require 'rspec'
RSpec.configure do |config|
end
My class1_spec.rb has:
require 'spec_helper'
require '../../lib/class1'
describ
ext:
>
> shared_context :signed_in do
> before do
>sign_in(current_user)
>controller.stub!(:current_user).and_return(current_user)
> end
> end
>
> On Thu, Mar 8, 2012 at 6:15 PM, S Ahmed wrote:
> > In my authenticate_pages.spec (requests) I do the followi
In my authenticate_pages.spec (requests) I do the following to test if the
signin worked:
describe "with valid information" do
#let(:account) { FactoryGirl.create(:account) }
let(:user) { FactoryGirl.create(:user) }
before do
fill_in "Email", with: user.email
fi
Sun, Mar 4, 2012 at 1:34 PM, David Chelimsky wrote:
> On Sun, Mar 4, 2012 at 7:40 AM, S Ahmed wrote:
> > I want to test if my sessions logic works.
> >
> > Session:
> > id
> > user_id
> >
> > When I create a new session, if there was a previous se
I want to test if my sessions logic works.
Session:
id
user_id
When I create a new session, if there was a previous session row in the db
with user_id = xxx, it should delete it first, then create a new row.
How could I test this scenerio?
So far I have:
require 'spec_helper'
describe Sessi
12:35 PM, S Ahmed wrote:
>
> > I'm testing my controller, and confirming that a logged-in user can view
> the page.
> >
> > I have a session_helper that does this:
> >
> > def signed_in?
> > !current_user.nil?
> > end
> >
> >
I'm testing my controller, and confirming that a logged-in user can view
the page.
I have a session_helper that does this:
def signed_in?
!current_user.nil?
end
And the current_user is set with:
def user_from_remember_token
remember_token = cookies[:remember_token]
User.find_by_reme
I am not sure why my form submission is failing (request test).
I am calling:
# form is filled in a 'before do' block.
it "should create an account" do
expect { click_button "Create" }.to change(Account, :count).by(1)
end
Could I somehow view the HTML after the click_button call?
Manually su
ing.pry above that line, and then
> run it, and then poke around in the repl and see if you've got the right
> context. You did make the request to get that page, right?
>
> Ben
>
> On Wed, Feb 29, 2012 at 10:04 PM, S Ahmed wrote:
>
>> My html looks like:
>
I'm trying to use factory for a test case, but the model I am creating via
the factory depends on another model, how do you setup a factory like this?
Model Account has a location_id attribute (where Location is another model)
So how do I set it?
FactoryGirl. do
location_id /
en
My html looks like:
Acura Honda Ford
Toyota GM
My requests spec looks like:
before do
select '7', :from => "account[car_type]"
fill_in ..
..
end
I get the error message:
Failure/Error: select '7', :from => "account[car_type]"
Capybara::ElementNotFound:
cannot select option
ahh, nice makes sense thanks!
On Sun, Feb 26, 2012 at 12:25 PM, Andrew Premdas wrote:
> On 26 February 2012 16:36, S Ahmed wrote:
>
>> I'm testing my signup page, and I want to minimize the duplication of
>> the fill_in code for filling in the form fields and testin
I'm testing my signup page, and I want to minimize the duplication of the
fill_in code for filling in the form fields and testing how my page reacts
when someone forgets to enter input.
fill_in "", with: "abc123"
Any tricks of doing this?
Say I have 10 fill_in calls, so say I want to test to
For those of you who have used both rspec requests and cucumber, could you
summarize the main differences between the two?
Do they both serve the same purpose but with different implementation
styles or they really aren't the same thing?
I havent' used requests before, but I like the idea of bein
an 16, 2012 at 10:51 PM, Justin Ko wrote:
>
> On Jan 16, 2012, at 7:35 PM, S Ahmed wrote:
>
> > With jruby and rspec requests, do you have to use selenium webdriver?
> >
> > I'm confused, with ruby and rubyonrails using cucumber with capybara, I
> didn't have
With jruby and rspec requests, do you have to use selenium webdriver?
I'm confused, with ruby and rubyonrails using cucumber with capybara, I
didn't have to set the default driver, what was it using and can i use that
with jruby? Things just worked w/o me even having to know about it :)
_
I'm trying to run rspec requests, using jruby, and I set the defaults in a
env.rb file, but it doesn't seem to be loaded when I run the specs.
My folder setup is:
/spec/requests/
/spec/requests/section/section_spec.rb
/spec/support/env.rb (where I configured selenium as the driver etc.)
I also
Oh and I am grateful for your refactoring and explanations, simplies my code
and tests (and understanding!)
On Wed, Jun 29, 2011 at 3:19 PM, S Ahmed wrote:
> Ok I got it working, and honestly I have no idea why it is working.
>
> There was a test below it which I modified (I had u
PM, S Ahmed wrote:
> Your code worked, let me try and figure out why mine isn't working
>
> Your right it isn't exactly what I have, but pretty much everything is
> identical except for the naming of the model.
>
>
> On Wed, Jun 29, 2011 at 2:20 PM, David Chelim
Your code worked, let me try and figure out why mine isn't working
Your right it isn't exactly what I have, but pretty much everything is
identical except for the naming of the model.
On Wed, Jun 29, 2011 at 2:20 PM, David Chelimsky wrote:
> On Jun 29, 2011, at 12:21 PM,
My method looks like:
def self.can_do_this(user)
return false if user.nil?
( (Time.now >= user.created_at) ? true : false )
end
my spec:
it "should allow you to do this" do
user = stub("user")
user.stub(:nil?).and_return(false)
user.stub(:created_at).and_return(Time.now)
res = Use
Thanks.
I'm trying this now on a Model that is using Mongoid.
I have tried:
it "should ..." do
User.stub(:some_call).and_return(User.new(:name => "blah"))
end
And when running spec on this file I get:
NoMethodError, undefined method "stub" for User:Class
I also tried:
User.stub!(:some_c
I'm a bit confused how to hook into a particular model object instance and
mock/stub it?
I understand how to hook into a class level method like:
User.should_receive(:where).and_return()
but what if my method looks like:
def some_thing
user = User.where("...")
user2 = User.where("
un 13, 2011 at 9:37 PM, David Chelimsky wrote:
> On Jun 13, 2011, at 8:29 PM, S Ahmed wrote:
>
> "How to mock when there seems to be a requirement for chained mocked
> calls?"
>
> There is no such requirement unless you are imposing it by your own design
> decisions
I want to mock the following:
MyModel.where(".").last
I tried:
MyModel.should_receive(:where).and_return(nil)
but this of course doesn't match the expectation since the call to .last was
not mapped in the mock code.
How can I do this?
___
rspec-u
My user controllers 'create' action looks like:
def create
@user = User.new(params[:user])
@user.user_name = params[:user][:user_name]
@user.email = params[:user][:email]
if @user.is_valid?
@user.status = 2
@user.save!
UserMailer.new_user(@user).deliver
redirect_t
class User < ActiveRecord::Base
attr_accessor :password, :password_confirmation
attr_accessible :password, :password_confirmation, ...
validates :password, :presence => true, :confirmation => true, :length =>
{ :within => 6..20 }
end
factory_girl:
Factory.define :user do |u|
u.user_n
will it go and run spec's for you also?
Correct me if I am wrong, but the cucumber step definitions do indeed use
webrat to hit the pages and verify things in the view pages correct?
On Mon, May 9, 2011 at 10:48 AM, Andrew Premdas wrote:
>
>
> On 9 May 2011 15:00, S Ahmed wr
I'm a bit confused as to how cucumber and rspec integrate (if they d at
all?).
You write a cucumber feature, and step definitions.
Now in the step definitions, do you write rspec in the step definitions or
do they somehow link to the spec's written elsewhere?
__
Say I want to test this method:
def modify_user_status(user_id)
..
..
user = User.find(user_id)
..
..
end
Now could I mock the call to User.find()?
I'm just trying to understand, when I run the test, and say I mocked the
call to User.find, then rspec realizes this and replaces
I want my tests to fail if I rename a method in my /lib folder in a rails
app.
Say I have a class like:
/lib
/lib/formatter.rb
class Formatter
def self.do_transforms(text)
text
end
end
And say I reference this in my HomeController's index action:
def index
text = params[:tex
37 matches
Mail list logo