Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8134643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:06:38+00:00 2026-06-06T10:06:38+00:00

Hi I am learning to write test cases with Rspec in ruby and am

  • 0

Hi I am learning to write test cases with Rspec in ruby and am following this link. So while testing the following case

 require 'spec_helper'

describe "Library object" do
before :all do
    lib_obj = [
        Book.new ("Javascript: The Good Parts", "Douglas Crockford", :development),
        Book.new ("Designing with Web Standards", "Jeffrey Zeldman", :design),
        Book.new ("Don't make me Think", "Steve krug", :usability),
        Book.new ("Javascript Patterns", "Stoyam Stefanov", :development),
        Book.new ("Responsive Web Design", "Ethan Marcotte", :design)
    ]       
    File.open "books.yml", "w" do |f|
        f.write YAML::dump lib_obj
    end
end

before :each do
    @lib = Library.new "books.yml"
end

describe "#new" do
    context "with no parameters" do
        it "has no books" do
            lib = Library.new
            lib.should have(0).books
        end
    end
    context "with a yaml file paramater" do
        it "has five books" do
            @lib.should have(5).books
        end
    end
end

it "returns all the books in a given category" do
    @lib.get_books_in_category(:development).length.should == 2
end

it "accepts new books" do
    @lib.add_book(Book.new("Designing for the Web", "Mark Boulton", :design))
    @lib.get_book("Designing for the Web").should be_an_instance_of Book
end

it "saves the library" do
    books = @lib.books.map { |book| book.title  }
    @lib.save
    lib2 = Library.new "books.yml"
    books2 = lib2.books.map { |book| book.title  }
    books.should eql books2
end

end

I am getting the following error:-

syntax error, unexpected ',', expecting keyword_end
 Book.new ("Don't make me Think", "Steve krug", :usability),

This stands for all the entries in array lib_obj.
I am using ruby 1.9.3 and rails 3.2.6

Kindly help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:06:40+00:00Added an answer on June 6, 2026 at 10:06 am

    You have an extra space between your method calls and argument lists.

    Book.new (...)
    

    …is not the same as:

    Book.new(...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning how to write test cases using Rspec. I have a simple
I'm learning SAS and write this macro: %macro firstMacro(mvLO, OLO); %local Count; %local Wordy;
I'm still learning about REST and, in my test, came up with this scenario
I am learning how to write tests with cucumber/webrat. One of my test scenarios
I just start learning to write web services yesterday, kinda fascinating. I created an
I'm learning to write non-blocking server and client applications using epoll, poll, etc. and
I'm learning jQuery and am about to write some pages using intensively that library.
I trying to write a PowerShell script (learning at the same time). I have
I am learning emacs at the moment and tried to write an easy vhdl
I have started learning Java and I have 1 issue: I write a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.