[rspec-users] undefined method `run_all' for []:Array

2011-01-02 Thread Kristian Mandrup
I'm using the latest ruby 1.9.3-head and recently whenever I run rspec (2.2+) I get the following error: I have seen others have run into this issue, but to resolve it just rolled back to a previous version of rspec or it there a better way? ruby-1.9.3-head/gems/rspec-core-2.3.1/lib/rspec/core/ho

[rspec-users] RSpec ActionView released - simplifies creating specs for your View helpers

2010-08-25 Thread Kristian Mandrup
http://github.com/kristianmandrup/rspec-action_view --- require 'spec_helper' module MyView module Tab def tab_for(clazz, &block) content = with_output_buffer(&block) content_tag :li, content, :class => clazz end end module Say def hello(clazz, &block) conten

Re: [rspec-users] How do I write specs for Rails 3 view block helpers that use #with_output_buffer(&block) ?

2010-08-23 Thread Kristian Mandrup
hould match /kristian/ view.hello('david') { 'hello' }.should match /david/ with_action_view do |view| view.with_template(%{ <%= tab_for('kristian') { 'hello' } %> }).should match /hello/ end end end Enjoy! On Aug 23, 8:

Re: [rspec-users] How do I write specs for Rails 3 view block helpers that use #with_output_buffer(&block) ?

2010-08-23 Thread Kristian Mandrup
t; do it "works" do ActionViewTester.tests MyViewHelper, MyOtherViewHelper ActionViewTester.new do |helper| helper.tab_for('kristian') { 'hello' }.should match /kristian/ helper.hello('david') { 'hello' }.should match /david/

Re: [rspec-users] Rails View spec testing for content in

2010-08-23 Thread Kristian Mandrup
I found this at: http://github.com/rspec/rspec-rails describe EventsHelper do describe "#link_to_event" do it "displays the title, and formatted date" do event = Event.new("Ruby Kaigi", Date.new(2010, 8, 27)) # helper is an instance of ActionView::Base configured with the #

Re: [rspec-users] Rails View spec testing for content in

2010-08-23 Thread Kristian Mandrup
I wonder if I can just "stub out" #with_output_buffer to yield the block immediately, and then assume it will work just as well in a Rails view template? class MyView < ActionView::Base attr_accessor :current_user def with_output_buffer yield end end

[rspec-users] How do I write specs for Rails 3 view block helpers that use #with_output_buffer(&block) ?

2010-08-23 Thread Kristian Mandrup
I found this: http://stackoverflow.com/questions/197164/how-do-i-test-rails-block-helpers-with-rspec it 'should do something' do helper.some_block_helper { the_block_code }.should end but not sure how to use it I have a module which is extended on top of ActiveView::Base module My

Re: [rspec-users] Rails View spec testing for content in

2010-08-23 Thread Kristian Mandrup
I am trying to test methods I have added to ActionView::Base through a Rails 3 plugin. Basically, I have been trying to test it "outside of Rails" if possible, that is, to only load the bare minimum functionality. Here is my Rails view with a custom method #area added, which uses #with_output_buff

Re: [rspec-users] Rails 3 plugin development - recommended RSpec practices?

2010-08-21 Thread Kristian Mandrup
Looking at Ryan B's CanCan for inspiration require 'rspec' require 'rspec/autorun' require 'active_support' require 'active_record' require 'action_controller' require 'action_view' require 'rails3_plugin_toolbox' RSpec.configure do |config| config.mock_with :rr end --- require "spec_helper"

[rspec-users] Rails 3 plugin development - recommended RSpec practices?

2010-08-21 Thread Kristian Mandrup
I have been thinking that there must be some better ways of doing Rails plugin development than my current approach. Currently I tend to have my plugin in one location as a gem and then link to it from some fresh Rails 3 app, from the vendor/plugins folder, with a symlink. Then I have to carry arou

[rspec-users] RSpec 2 matchers 'code-spec' and 'file-spec' released

2010-08-16 Thread Kristian Mandrup
Spec your generated Ruby code files code-spec at: http://github.com/kristianmandrup/code-spec Spec your file structure (files, dirs, symlinks) file-spec at: http://github.com/kristianmandrup/file-spec More to come... ___ rspec-users mailing list rspec

Re: [rspec-users] generator-spec release 0.4.8

2010-08-14 Thread Kristian Mandrup
Just released 0.5.0, a pretty stable release with a large rspec test suite to show it off and ensure it works as it should :) On Aug 11, 6:02 pm, Kristian Mandrup wrote: > Now with an almost complete test suite to ensure it all works as it > should and to demonstrate how to use it. > T

Re: [rspec-users] how to place the app in the rails dir

2010-08-12 Thread Kristian Mandrup
To learn Rails, checkout: http://railsnotes.com/rails-3/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] generator-spec release 0.4.8

2010-08-11 Thread Kristian Mandrup
Now with an almost complete test suite to ensure it all works as it should and to demonstrate how to use it. The DSL is better than ever! describe 'model_generator' do # include Rails model helpers for ActiveRecord # available: # Other ORM options - :mongo_mapper, :mongoid and :data_mapper

Re: [rspec-users] how to place the app in the rails dir

2010-08-11 Thread Kristian Mandrup
1) If your app name is "nice-app", make your directory like this railsprojects/nice-app 2) First update rubygems and perhaps use rvm (ruby version manager) http://railscasts.com/episodes?page=3 See railscast 200 and 201. Bundler can also be used for Rails 2 I think ;) Which version of Rails

[rspec-users] Nice little DSL trick for extending ExampleGroups in RSpec

2010-08-10 Thread Kristian Mandrup
describe 'migration_generator' do include RSpec::Rails::Orm::ActiveRecord include RSpec::Rails::Migration ... end Didn't quite feel right. So I made it prettier DSL like using the solution below ;) class Class def use_orm orm class_eval do include "RSpec::Rails::Orm::#{orm.to_s.c

[rspec-users] Release of RSpec for Generators 0.4.0

2010-08-07 Thread Kristian Mandrup
Now with a full RSpec 2 test suite to demonstrate most of its features. Wiki to be updated with latest changes ASAP. http://github.com/kristianmandrup/rspec_for_generators This gem makes it very easy to spec that your generator generates files as expected and also lets you easily verify that the

Re: [rspec-users] How do I extend ExampleGroup in Rspec 2?

2010-08-07 Thread Kristian Mandrup
r.setup_generator test_method_name, &block end end end On Aug 7, 4:09 pm, David Chelimsky wrote: > On Aug 7, 2010, at 8:23 AM, Kristian Mandrup wrote: > > > > > I simply want all methods of a module to be always available within > > the context of an Example gr

[rspec-users] How do I extend ExampleGroup in Rspec 2?

2010-08-07 Thread Kristian Mandrup
I simply want all methods of a module to be always available within the context of an Example group. module RSpec module Generator def with_generator &block ... end def setup_generator test_method_name=nil, &block ... end end end How do I achieve this?

Re: [rspec-users] RSpec 2 add-on for testing and specifying generators - initial release

2010-08-04 Thread Kristian Mandrup
Even simpler config now :) require 'rspec' require 'rspec_for_generators' # configure it like this to use default settings RSpec::Generator.configure_root_dir(__FILE__) ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/

Re: [rspec-users] RSpec 2 add-on for testing and specifying generators - initial release

2010-08-04 Thread Kristian Mandrup
nd end end end end On Aug 4, 5:22 am, David Chelimsky wrote: > On Aug 3, 2010, at 3:06 PM, Kristian Mandrup wrote: > > > > >http://github.com/kristianmandrup/rspec_for_generators > > > When creating Rails generators I noticed that the only option I could >

[rspec-users] RSpec 2 add-on for testing and specifying generators - initial release

2010-08-03 Thread Kristian Mandrup
http://github.com/kristianmandrup/rspec_for_generators When creating Rails generators I noticed that the only option I could find for testing was to use a special Rails TestCase class created specifically for use with Test Unit. So I thought I could wrap it to be used with RSpec 2 instead. I now h

[rspec-users] New project: rspec_for_generators - toolbox for using RSpec 2 to test and spec Rails 3 generators

2010-07-12 Thread Kristian Mandrup
I have created a complete project where I have extracted all my RSpec 2 utilities, configurations, special matchers etc. for creating nice Rails 3 Generator specs. http://github.com/kristianmandrup/rspec_for_generators An example of use where all specs pass: http://github.com/kristianmandrup/can

[rspec-users] RSpec 2 - specs for Rails generators :)

2010-07-11 Thread Kristian Mandrup
http://github.com/kristianmandrup/canable In my fork of jnunemaker's canable I show my port of the unit test way of testing generators for RSpec 2. It still needs some tidying up to make it even more elegant ;) Feel free to provide suggestions etc. Kristian RSpec 2 example --- describe 'Generato

[rspec-users] Experimenting with converting Rails::Generators::TestCase to RSpec 2

2010-07-11 Thread Kristian Mandrup
http://github.com/kristianmandrup/canable/tree/master/spec/ Example: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe 'Generator' do let(:generator) { Rails::Generators::Testcase.new } with generator do destination File.join(Rails.root) tests Canable::Ge

[rspec-users] RSpec 2 equivalent for Rails::Generators::TestCase ?

2010-07-11 Thread Kristian Mandrup
I have been creating a lot of Thor generators and Rails generators during the past 4 months, but only this week did I find some good examples of how to write tests for generators using Rails::Generators::TestCase - in the "rails3-generators" project. I prefer to write my tests in RSpec 2, so I was

Re: [rspec-users] undefined local variable or method `assigns'

2010-06-14 Thread Kristian Mandrup
Thanks again David :) Pure magic to me, I don't really understand how/ why that makes it work. But it does! On Jun 14, 2:30 am, David Chelimsky wrote: > On Jun 13, 2010, at 5:32 PM, Kristian Mandrup   > wrote: > > > > > shared_examples_for "a template that render

Re: [rspec-users] undefined local variable or method `assigns'

2010-06-13 Thread Kristian Mandrup
shared_examples_for "a template that renders the messages/form partial" do it "renders the messages/form partial" do view.should_receive(:_render_partial). with(hash_including(:partial => "form")) render end end # new.html.erb <%= render "sidebar", :recent_messages => @recent_me

Re: [rspec-users] undefined local variable or method `assigns'

2010-06-13 Thread Kristian Mandrup
Thanks! Just what I needed :) ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] undefined local variable or method `assigns'

2010-06-13 Thread Kristian Mandrup
orm", :locals=>{:message=>nil}}) got: ({:template=>"messages/edit.html.erb"}, {}) But this is my edit.html <%= render "form", :message => @message %> So _view only contains info on the view. How do I get info on the templates called as part of the rend

Re: [rspec-users] RSpec 2: uninitialized constant - mocking belongs_to AR relation

2010-06-13 Thread Kristian Mandrup
Cause of error: class Message < ActiveRecord::Base belongs_to :recipient #, :class_name => User.name -- it then by convention expects there to be a model class called Recipient. should instead be class Message < ActiveRecord::Base belongs_to :recipient, :class_name => User.name But then the

Re: [rspec-users] undefined local variable or method `assigns'

2010-06-13 Thread Kristian Mandrup
assigns(:message).should eq(@message) assign(:message, stub("Message", :text => "Hello world!")) Hmm, so 'assign' to assign a variable and 'assigns' to read an assigned variable? We need to update the RSpec 2 wiki or somewhere with all these API changes so it is clear to everyone. On Jun 11, 9:

[rspec-users] RSpec 2: uninitialized constant - mocking belongs_to AR relation

2010-06-10 Thread Kristian Mandrup
gems/ruby-1.9.2-head/bundler/gems/rspec- core-2398fcadf5beb256bed9c548c59445d3b4c8a047-master/lib/rspec/core/ backward_compatibility.rb:26:in `const_missing': uninitialized constant Message::User (NameError) from /Users/kristianconsult/.rvm/gems/ruby-1.9.2-head/bundler/gems/ rspec-expectati

[rspec-users] RSpec 2: undefined method `controller_name' for :Class (NoMethodError)

2010-06-10 Thread Kristian Mandrup
describe ApplicationController, "handling AccessDenied exceptions" do class FooController < ApplicationController def index raise AccessDenied end end controller_name 'foo' # OUCH!!! it "redirects to the /401.html (access denied) page" do get :index response.should r

[rspec-users] RSpec 2 equivalent for: assigns[:message].should == @message

2010-06-10 Thread Kristian Mandrup
describe MessagesController, "POST create" do before(:each) do @message = mock_model(Message, :save => nil) Message.stub(:new).and_return(@message) end context "when the message fails to save" do before(:each) do @message.stub(:save).and_return(false) end it "ass

[rspec-users] mock_model not working in rspec2?

2010-06-09 Thread Kristian Mandrup
undefined method `model_name' for Message:Class --- # spec/views/messages/new.html.erb_spec.rb class Message; end describe "messages/new.html.erb" do it "renders a form to create a message" do assign(:message, mock_model(Message).as_new_record) render # app/views/messages/new

[rspec-users] RSpec book examples online for RSpec 2.beta11 + Cucumber 0.8 + Rails 3.beta3 + Capybara

2010-06-09 Thread Kristian Mandrup
http://github.com/kristianmandrup/codebreaker With detailed code instructions for each step in the project wiki and in a markdown file within each app. http://github.com/kristianmandrup/rspec-book-movie-app http://github.com/kristianmandrup/rspec-book-views-example Note: The final example is at

[rspec-users] Rspec2 mock assign - how do I get the value out?

2010-06-09 Thread Kristian Mandrup
assign(:message, stub("Message")) In my view I can access the message, but... <%= @message.to_s %> expected the following element's content to include "Hello world!": #[RSpec::Mocks::Mock:0x81bbd81c @name="Message"] Finally after some trial and error I discovered the solution, an option

Re: [rspec-users] assigns in RSpec 2 - deprecation warning on rendered?

2010-06-09 Thread Kristian Mandrup
> assign(:message, stub("Message")) > > That should get rid of your deprecation message. Yeah! But strange deprecation message that it mentions: * response is deprecated. * please use rendered instead. When it should be: * assigns is deprecated. * please use assign instead. Also, how do I use th

[rspec-users] assigns in RSpec 2 - deprecation warning on rendered?

2010-06-09 Thread Kristian Mandrup
I have come to the views_example in the RSpec book, using RSpec 2 all the way. Now I have this spec: -- describe "messages/show.html.erb" do it "displays the text attribute of the message" do assigns[:message] = stub("Message", :text => "Hello world!") puts "assigns @message: #...@message

[rspec-users] Mocking and specing command line (cli) execution, file operations etc. ?

2010-06-06 Thread Kristian Mandrup
What are the options for creating specs for file operations, executing commands in the CLI etc.? If I build a generator or something which runs a lot of things in the command line, how do I check the results of these operations, fx mocking file system updates and/or mocking the STDOUT/STDIN from t

Re: [rspec-users] Problems running RSpec 2 with autotest/autospec

2010-06-05 Thread Kristian Mandrup
Thanks! I solved it all now and updated the RSpec 2 wiki about how to set it all up ;) http://wiki.github.com/rspec/rspec/autotest Hope these instructions provides a good base and is helpful to others! ___ rspec-users mailing list rspec-users@rubyforge.

Re: [rspec-users] Problems running RSpec 2 with autotest/autospec

2010-06-05 Thread Kristian Mandrup
I found the solution here: http://blog.davidchelimsky.net/category/autotest/ -- As of beta.4, you’ll have to do add this configuration manually. Just create an autotest directory in the root of your project, put the following statement in ./autotest/discover.rb: Autotest.add_discovery { "rspec2"

Re: [rspec-users] Problems running RSpec 2 with autotest/autospec

2010-06-05 Thread Kristian Mandrup
Thanks again David :) > Don't use RSPEC=true for rspec-2. > > Also, probably need to set AUTOFEATURE=false. > OK, when I run it like this $ AUTOFEATURE=false autotest I get an empty autotest output whenever I change and save a spec. The above lets me disable features, but how do I ENABLE specs

[rspec-users] Problems running RSpec 2 with autotest/autospec

2010-06-05 Thread Kristian Mandrup
It seems there is no bin/autospec with RSpec 2. So I got it running simply with $ autotest Been looking at instructions here http://wiki.github.com/dchelimsky/rspec/autotest-integration And here http://ph7spot.com/musings/getting-started-with-autotest But... $ RSPEC=true autotest loading autot

Re: [rspec-users] spec.opts is deprecated - Using options file with RSpec 2

2010-06-05 Thread Kristian Mandrup
Thanks ;) I also tried to follow the instructions on using autospec/autotest, first from the RSpec book then from instructions found on the net. I managed to do the following so far: # config/cucumber.yml default: --format profile features html_report: --format progress --format html -- out=feat

[rspec-users] spec.opts is deprecated - Using options file with RSpec 2

2010-06-05 Thread Kristian Mandrup
Using RSpec 2 beta. $ rspec spec * spec/spec.opts is deprecated. * please use .rspec or ~/.rspec instead. I tried renaming the file to .rspec but then it has no effect! # spec/.rspec --format nested --color It works if I copy it to ~/.rspec and it turns out, also if I copy .rspec to the root o

Re: [rspec-users] RSpec book errata #57 - undefined method `include' : what to do?

2010-06-01 Thread Kristian Mandrup
One hack "solution" looks like this :P output.messages.include?(mark).should ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] RSpec book errata #57 - undefined method `include' : what to do?

2010-06-01 Thread Kristian Mandrup
http://pragprog.com/titles/achbd/errata nr 57: Ruby 1.8.7 expected [] to include "Welcome to Codebreaker!" Ruby 1.9.1 undefined method `include' for # (NoMethodError) --- class Output def messages @messages ||= [] end def puts(message) messages << message end end Then /^I shoul

[rspec-users] Configuring RSpec 2

2010-03-02 Thread Kristian Mandrup
# spec_helper.rb $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require '... require 'rspec' require 'rspec/autorun' # doesn't work: just remove it and it works. # But how would you configure the RSpec Runner in RSpec 2 then? Rspec::R

[rspec-users] RSpec Rails 3 generators - first draft

2010-02-05 Thread Kristian Mandrup
I have just finished creating a working set of Rails 3 compatible generators for RSpec. http://github.com/kristianmandrup/rspec_rails3_gen Also available from gemcutter under the same name: rspec_rails3_gen They work pretty well, except for the hooks functionality which still needs some work ho

[rspec-users] CRITICAL: Rspec gem install > spec command not found!

2010-02-02 Thread Kristian Mandrup
I have the beta release of the RSpec book. Trying to run the greeting example 'Hello World' Using brew as package manager Installed rspec gem using $ sudo gem install rspec kristian-mandrups-macbook-pro:rspec-coding kristianconsult$ gem list *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3