spec/table_spec.rb in tablestakes-0.9.1 vs spec/table_spec.rb in tablestakes-0.9.2

- old
+ new

@@ -1,9 +1,10 @@ # file: table_spec.rb # # require 'spec_helper' +require 'rspec/its' require_relative '../lib/tablestakes' describe "Table" do @@ -203,11 +204,11 @@ end it "selects columns given as arguments" do expect((t.select("Name","Address","Records")).headers).to eq(["Name","Address","Records"]) end it "does not select columns that are not given as arguments" do - expect((t.select("Name","Address","Records")).headers.include?("Phone")).to be_false + expect((t.select("Name","Address","Records")).headers.include?("Phone")).to eq(false) end it "raise ArgumentError when the given arguments don't match a column" do expect { t.select("Silly") }.to raise_error(ArgumentError) end end @@ -241,13 +242,22 @@ it "returns an instance of Table" do expect(cities.sub("State", /Jersey/, "York")).to be_a(Table) end it "substitutes the values in a given field" do - expect((cities.sub("State", /Jersey/, "York")).count("State", "New York")).to eq(9) + expect(cities.sub("State", /Jersey/, "York").column("State")).to include("New York") end it "raises ArgumentError when the given arguments don't match a column" do expect {cities.sub("Silly", /NJ/, "NY") }.to raise_error(ArgumentError) + end + it "raises ArgumentError when not given a Match string" do + expect {cities.sub("State") }.to raise_error(ArgumentError) + end + it "raises ArgumentError when replacement is not a String or Hash" do + expect {cities.sub("State", /New/, 9)}.to raise_error(ArgumentError) + end + it "does not modify the given table" do + expect(cities.sub("State", /New/, "Old") && cities.column("State")).to include("New York") end end describe ".union" do let (:cities) { Table.new('cities.txt') } \ No newline at end of file