Skip to content

Commit 8765e4a

Browse files
committed
Normalize the code style of the specs.
1 parent e0b2314 commit 8765e4a

File tree

8 files changed

+34
-39
lines changed

8 files changed

+34
-39
lines changed

spec/immediate_operand_spec.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'spec_helper'
2-
32
require 'ronin/asm/immediate_operand'
43

54
describe Ronin::ASM::ImmediateOperand do
@@ -18,50 +17,50 @@
1817
end
1918

2019
describe "#width" do
21-
describe "default width for" do
22-
context "0x100000000 .. 0xffffffffffffffff" do
20+
context "when #width is not explicitly set by #initialize" do
21+
context "and when between 0x100000000 .. 0xffffffffffffffff" do
2322
subject { described_class.new(0xffffffffffffffff).width }
2423

2524
it { expect(subject).to be == 8 }
2625
end
2726

28-
context "-0x800000000 .. -0x7fffffffffffffff" do
27+
context "and when between -0x800000000 .. -0x7fffffffffffffff" do
2928
subject { described_class.new(-0x7fffffffffffffff).width }
3029

3130
it { expect(subject).to be == 8 }
3231
end
3332

34-
context "0x10000 .. 0xffffffff" do
33+
context "and when between 0x10000 .. 0xffffffff" do
3534
subject { described_class.new(0xffffffff).width }
3635

3736
it { expect(subject).to be == 4 }
3837
end
3938

40-
context "-0x80000 .. -0x7fffffff" do
39+
context "and when between -0x80000 .. -0x7fffffff" do
4140
subject { described_class.new(-0x7fffffff).width }
4241

4342
it { expect(subject).to be == 4 }
4443
end
4544

46-
context "0x100 .. 0xffff" do
45+
context "and when between 0x100 .. 0xffff" do
4746
subject { described_class.new(0xffff).width }
4847

4948
it { expect(subject).to be == 2 }
5049
end
5150

52-
context "-0x80 .. -0x7fff" do
51+
context "and when between -0x80 .. -0x7fff" do
5352
subject { described_class.new(-0x7fff).width }
5453

5554
it { expect(subject).to be == 2 }
5655
end
5756

58-
context "0x0 .. 0xff" do
57+
context "and when between 0x00 .. 0xff" do
5958
subject { described_class.new(0xff).width }
6059

6160
it { expect(subject).to be == 1 }
6261
end
6362

64-
context "0x0 .. -0x7f" do
63+
context "and when between 0x00 .. -0x7f" do
6564
subject { described_class.new(-0x7f).width }
6665

6766
it { expect(subject).to be == 1 }

spec/instruction_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
2-
32
require 'ronin/asm/instruction'
3+
44
require 'ronin/asm/register'
55
require 'ronin/asm/immediate_operand'
66
require 'ronin/asm/memory_operand'

spec/memory_operand_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
2-
32
require 'ronin/asm/memory_operand'
3+
44
require 'ronin/asm/register'
55

66
describe Ronin::ASM::MemoryOperand do

spec/register_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'spec_helper'
2-
32
require 'ronin/asm/register'
43

54
describe Ronin::ASM::Register do

spec/shellcode_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# encoding: US-ASCII
2-
32
require 'spec_helper'
43
require 'ronin/asm/shellcode'
54

spec/syntax/att_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
2-
32
require 'ronin/asm/syntax/att'
3+
44
require 'ronin/asm/register'
55
require 'ronin/asm/immediate_operand'
66
require 'ronin/asm/memory_operand'
@@ -10,23 +10,23 @@
1010
describe Ronin::ASM::Syntax::ATT do
1111
subject { described_class }
1212

13-
describe "emit_register" do
13+
describe ".emit_register" do
1414
let(:register) { Ronin::ASM::Register.new(:eax, 4) }
1515

1616
it "must prepend a '%' to the register name" do
1717
expect(subject.emit_register(register)).to eq("%eax")
1818
end
1919
end
2020

21-
describe "emit_immediate_operand" do
21+
describe ".emit_immediate_operand" do
2222
let(:operand) { Ronin::ASM::ImmediateOperand.new(255, 1) }
2323

2424
it "must prepend a '$' to the immediate" do
2525
expect(subject.emit_immediate_operand(operand)).to eq("$0xff")
2626
end
2727
end
2828

29-
describe "emit_memory_operand" do
29+
describe ".emit_memory_operand" do
3030
let(:register) { Ronin::ASM::Register.new(:eax, 4) }
3131
let(:operand) { Ronin::ASM::MemoryOperand.new(register) }
3232

@@ -70,7 +70,7 @@
7070
end
7171
end
7272

73-
describe "emit_instruction" do
73+
describe ".emit_instruction" do
7474
context "with no operands" do
7575
let(:instruction) { Ronin::ASM::Instruction.new(:ret, []) }
7676

@@ -105,13 +105,13 @@
105105
end
106106
end
107107

108-
describe "emit_section" do
108+
describe ".emit_section" do
109109
it "must emit the section name" do
110110
expect(subject.emit_section(:text)).to eq(".text")
111111
end
112112
end
113113

114-
describe "emit_program" do
114+
describe ".emit_program" do
115115
let(:program) do
116116
Ronin::ASM::Program.new do
117117
mov eax, 0xff

spec/syntax/common_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
require 'spec_helper'
2-
32
require 'ronin/asm/syntax/common'
3+
44
require 'ronin/asm/label'
55

66
describe Ronin::ASM::Syntax::Common do
77
subject { described_class }
88

9-
describe "emit_keyword" do
9+
describe ".emit_keyword" do
1010
let(:name) { :_start }
1111

1212
it "must convert a keyword to a String" do
1313
expect(subject.emit_keyword(name)).to eq(name.to_s)
1414
end
1515
end
1616

17-
describe "emit_integer" do
18-
let(:integer) { 255 }
19-
let(:hexadecimal) { "0xff" }
17+
describe ".emit_integer" do
18+
let(:int) { 255 }
2019

2120
it "must convert it into a hexadecimal value" do
22-
expect(subject.emit_integer(integer)).to eq(hexadecimal)
21+
expect(subject.emit_integer(int)).to eq("0xff")
2322
end
2423

2524
context "when given a negative number" do
26-
let(:negative) { -255 }
27-
let(:hexadecimal) { "-0xff" }
25+
let(:int) { -255 }
2826

2927
it "must convert it into a hexadecimal value" do
30-
expect(subject.emit_integer(negative)).to eq(hexadecimal)
28+
expect(subject.emit_integer(int)).to eq("-0xff")
3129
end
3230
end
3331
end
3432

35-
describe "emit_label" do
36-
let(:name) { '_start' }
33+
describe ".emit_label" do
34+
let(:name) { :_start }
3735
let(:label) { Ronin::ASM::Label.new(name) }
3836

3937
it "must append a ':' to the name" do

spec/syntax/intel_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
2-
32
require 'ronin/asm/syntax/intel'
3+
44
require 'ronin/asm/register'
55
require 'ronin/asm/immediate_operand'
66
require 'ronin/asm/memory_operand'
@@ -10,23 +10,23 @@
1010
describe Ronin::ASM::Syntax::Intel do
1111
subject { described_class }
1212

13-
describe "emit_register" do
13+
describe ".emit_register" do
1414
let(:register) { Ronin::ASM::Register.new(:eax, 4) }
1515

1616
it "must return the register name" do
1717
expect(subject.emit_register(register)).to eq("eax")
1818
end
1919
end
2020

21-
describe "emit_immediate_operand" do
21+
describe ".emit_immediate_operand" do
2222
let(:operand) { Ronin::ASM::ImmediateOperand.new(255, 1) }
2323

2424
it "must prepend a size specifier" do
2525
expect(subject.emit_immediate_operand(operand)).to eq("BYTE 0xff")
2626
end
2727
end
2828

29-
describe "emit_memory_operand" do
29+
describe ".emit_memory_operand" do
3030
let(:register) { Ronin::ASM::Register.new(:eax, 4) }
3131
let(:operand) { Ronin::ASM::MemoryOperand.new(register) }
3232

@@ -81,7 +81,7 @@
8181
end
8282
end
8383

84-
describe "emit_instruction" do
84+
describe ".emit_instruction" do
8585
context "with no operands" do
8686
let(:instruction) { Ronin::ASM::Instruction.new(:ret, []) }
8787

@@ -101,13 +101,13 @@
101101
end
102102
end
103103

104-
describe "emit_section" do
104+
describe ".emit_section" do
105105
it "must emit the section name" do
106106
expect(subject.emit_section(:text)).to eq("section .text")
107107
end
108108
end
109109

110-
describe "emit_program" do
110+
describe ".emit_program" do
111111
let(:program) do
112112
Ronin::ASM::Program.new do
113113
mov eax, 0xff

0 commit comments

Comments
 (0)