I have been an evil coder - working like crazy to get a ROR demo operational and ignoring RSpec. Does anyone have any helpful (aka; friendly) advice on using RSpec to get the current implementation under BDD control? Especially pitfalls to avoid.
Many thanks.
...
I have this Factory:
Factory.define :email_address do |e|
e.sequence(:address) { |n| "factory_#{n}@example.com" }
e.validated true
end
When I run my specs with rake spec, it works fine.
When I run autospec, it fails right away, claiming that the email address is being used twice in two different objects (there is a validation whi...
I might be missing something basic here, but I'm stumped on this error:
model code:
class CachedStat < ActiveRecord::Base
def self.create_stats_days_ago(days_ago, human_id)
d = Date.today - days_ago.day
@prs = PageRequest.find(:all, :conditions => [ "owner_type = 'Human' and owner_id = ? and created_at = ?", human_id, d] )
...
I'm using rspec and cucumber for BBD.
Now I'm migrating to rails 3 and rspec 2 and as I could see both of frameworks (shoulda and remarkable) support rails 3 and rspec 2.
I have never used shoulda or remarkable.
What should I prefer to use with rspec: shoulda or remarkable? And why?
...
Guys,
I'm having trouble understanding why I can't seem to stub this controller method :load_user, since all of my tests fail if I change the actual implementation of :load_user to not return and instance of @user.
Can anybody see why my stub (controller.stub!(:load_user).and_return(@user)) seems to fail to actually get called when ...
I have the following RSpec (1.3.0) task defined in my Rakefile:
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
end
I have the following in spec/spec_helper.rb:
require 'rubygems'
require 'spec'
require 'spec/autorun'
require 'rack...
Please, help me. I'm confused. I know how to write state-driven behavior of model, but I don't know what should I write in specs...
My model.rb file look
class Ratification < ActiveRecord::Base
belongs_to :user
attr_protected :status_events
state_machine :status, :initial => :boss do
state :boss
state :owner
state ...
I'm working with a bit of a bleeding edge rails app. Rails 3, RSpec 2, Rspec-Rails2.
It seems as if RSpec2 doesn't include the spec:rcov rake task that RSpec 1 has. (at least it isn't there yet)
Has anyone had any luck running rcov with rspec 2, or writing their own rake task to make this work?
...
How I can test a send_data method?
...
How can I confirm the absence of a HTML attribute in a Rails RSpec test?
I can verify that an input tag has a value attribute and that it is an empty string like so:
response.should have_tag("input[name=?][value=?]", "user[password]", "")
response.should have_tag("input[name=?][value=?]", "user[password_confirmation]", "")
But what I...
How do I mark a cucumber scenario as pending so it doesn't get counted as a passed?
Scenario: Guest should not see edit link
# pending implementation
Shouldn't I be able to mark is as pending?
...
hey all
im going through the setup on
http://www.railstutorial.org/chapters/static-pages#fig:autotest_green
and im stuck on this particular error:
ERROR READOUT: http://pastie.org/1015405
What i can see being the tell-tale issue here is the
No such file or directory - Files/rubygems-1.3.7/rails_projects/sample_app/spec/controllers...
Let me preface this be saying that I'm newb to both TDD and Ruby on Rails.
I'm using Rspec to perform unit testing of my data layer and to ensure that my database is rejecting invalid input.
My rspec code looks as follows:
it "should fail at saving without name" do
@my_data.attributes = valid_my_data_attributes.except(:name)
@my_d...
Hi,
I was reading up on rspec and I was trying to figure out how rspec's "should" was implemented
Could someone give a hand on how the meta nature of this function works?
The code is located here:
http://github.com/dchelimsky/rspec/blob/master/lib/spec/expectations/extensions/kernel.rb
TIA,
-daniel
Clarification:
target.should =...
I am trying to execute rspec code passed in to a Ruby process as a string. How can I execute rspec from within a Ruby process rather than from the commandline and capture the results?
# Ruby code
code = '
#solution
class User
def in_role?(role)
true
end
end
#Tests to pass
describe User do
it "should be in any roles ass...
I write spec for controllers in rails application. I want to write DRY spec for verifying request parameters check, rspec can be helpful to use shared_example_for.
For example.
shared_example_for "verifying request parameters" do
it "should return success for required parameter" do
get @action, @required_parameters
response.sh...
Hi,
I've got an rspec test which looks something like this:
require 'require_all'
require_rel '../spec_helper'
describe "HtmlEntities" do
...some tests
end
And I'm invoking it from a rake task that looks like
require 'rspec/core/rake_task'
Rspec::Core::RakeTask.new(:spec) do |spec|
# spec.libs << 'lib' << 'spec'
# spec.spec_file...
RSPec is a great ruby test framework (for test driven development),
anyone knows something like rspec but, for PHP?
...
Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to get a standard controller test working - it seems that the 'get' method can't be found.
I have a controller test that looks like this (named discrepancies_controller_spec.rb in spec/controllers directory):
require 'spec_helper'
describe DiscrepanciesControlle...
hey all
ive got a really interesting set of problems
im learning some new development techniques ... ruby on rails :D
so ive run this code numerous times:
spec spec/
as you can see from the code: these are back-to-back runs via terminal of "spec spec/"
http://pastie.org/1020719
returning different results...
i was told that softw...