File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ require_relative '../../spec_helper'
2
+ require_relative 'fixtures/classes'
3
+
4
+ ruby_version_is "3.2" do
5
+ describe "Data#with" do
6
+ it "returns self if given no arguments" do
7
+ data = DataSpecs ::Measure . new ( amount : 42 , unit : "km" )
8
+ data = data . with . should . equal? ( data )
9
+ end
10
+
11
+ it "accepts keyword arguments" do
12
+ data = DataSpecs ::Measure . new ( amount : 42 , unit : "km" )
13
+ data = data . with ( amount : 4 , unit : "m" )
14
+
15
+ data . amount . should == 4
16
+ data . unit . should == "m"
17
+ end
18
+
19
+ it "accepts String keyword arguments" do
20
+ data = DataSpecs ::Measure . new ( amount : 42 , unit : "km" )
21
+ data = data . with ( "amount" => 4 , "unit" => "m" )
22
+
23
+ data . amount . should == 4
24
+ data . unit . should == "m"
25
+ end
26
+
27
+ it "raises ArgumentError if no keyword arguments are given" do
28
+ data = DataSpecs ::Measure . new ( amount : 42 , unit : "km" )
29
+
30
+ -> {
31
+ data . with ( 4 , "m" )
32
+ } . should raise_error ( ArgumentError , "wrong number of arguments (given 2, expected 0)" )
33
+ end
34
+ end
35
+ end
You can’t perform that action at this time.
0 commit comments